web: Enforce camelCase
This commit is contained in:
parent
1519642a9a
commit
bccdaf77d4
|
@ -18,6 +18,13 @@
|
|||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_" }]
|
||||
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_" }],
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"error",
|
||||
{
|
||||
"selector": ["variable", "function"],
|
||||
"format": ["camelCase", "UPPER_CASE"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint @typescript-eslint/naming-convention:off */
|
||||
|
||||
declare let __webpack_public_path__: string;
|
||||
declare let runtime_path: string;
|
||||
declare let __CHANNEL__: string;
|
||||
|
|
|
@ -28,11 +28,11 @@ async function fetch_ruffle(): Promise<{ new (...args: any[]): Ruffle }> {
|
|||
|
||||
//We currently assume that if we are not executing inside the extension,
|
||||
//then we can use webpack to get Ruffle.
|
||||
const ruffle_module = await import("../pkg/ruffle_web");
|
||||
return ruffle_module.Ruffle;
|
||||
const module = await import("../pkg/ruffle_web");
|
||||
return module.Ruffle;
|
||||
}
|
||||
|
||||
let last_loaded_ruffle: Promise<{ new (...args: any[]): Ruffle }> | null = null;
|
||||
let lastLoaded: Promise<{ new (...args: any[]): Ruffle }> | null = null;
|
||||
|
||||
/**
|
||||
* Obtain an instance of `Ruffle`.
|
||||
|
@ -40,9 +40,9 @@ let last_loaded_ruffle: Promise<{ new (...args: any[]): Ruffle }> | null = null;
|
|||
* This function returns a promise which yields `Ruffle` asynchronously.
|
||||
*/
|
||||
export function load_ruffle(): Promise<{ new (...args: any[]): Ruffle }> {
|
||||
if (last_loaded_ruffle == null) {
|
||||
last_loaded_ruffle = fetch_ruffle();
|
||||
if (lastLoaded == null) {
|
||||
lastLoaded = fetch_ruffle();
|
||||
}
|
||||
|
||||
return last_loaded_ruffle;
|
||||
return lastLoaded;
|
||||
}
|
||||
|
|
|
@ -127,10 +127,10 @@ export class PublicAPI {
|
|||
|
||||
for (const k in this.sources) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.sources, k)) {
|
||||
const k_version = Version.fromSemver(this.sources[k].version);
|
||||
if (k_version.hasPrecedenceOver(newestVersion)) {
|
||||
const kVersion = Version.fromSemver(this.sources[k].version);
|
||||
if (kVersion.hasPrecedenceOver(newestVersion)) {
|
||||
newestName = k;
|
||||
newestVersion = k_version;
|
||||
newestVersion = kVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,15 +21,15 @@ import { Config } from "./config";
|
|||
* @returns The public path for the given source.
|
||||
*/
|
||||
export function public_path(config: Config, source_name: string): string {
|
||||
let public_path = "";
|
||||
let path = "";
|
||||
if (
|
||||
config !== undefined &&
|
||||
config.public_paths !== undefined &&
|
||||
config.public_paths[source_name] !== undefined
|
||||
) {
|
||||
public_path = config.public_paths[source_name];
|
||||
path = config.public_paths[source_name];
|
||||
} else if (config !== undefined && config.public_path !== undefined) {
|
||||
public_path = config.public_path;
|
||||
path = config.public_path;
|
||||
} else if (
|
||||
document.currentScript !== undefined &&
|
||||
document.currentScript !== null &&
|
||||
|
@ -37,16 +37,16 @@ export function public_path(config: Config, source_name: string): string {
|
|||
) {
|
||||
// Default to the directory where this script resides.
|
||||
try {
|
||||
public_path = new URL(".", document.currentScript.src).href;
|
||||
path = new URL(".", document.currentScript.src).href;
|
||||
} catch (e) {
|
||||
console.warn("Unable to get currentScript URL");
|
||||
}
|
||||
}
|
||||
|
||||
// Webpack expects the paths to end with a /.
|
||||
if (public_path !== "" && !public_path.endsWith("/")) {
|
||||
public_path += "/";
|
||||
if (path !== "" && !path.endsWith("/")) {
|
||||
path += "/";
|
||||
}
|
||||
|
||||
return public_path;
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
* @internal
|
||||
*/
|
||||
export function copyToAudioBuffer(
|
||||
audio_buffer: AudioBuffer,
|
||||
left_data: ArrayLike<number>,
|
||||
right_data: ArrayLike<number>
|
||||
audioBuffer: AudioBuffer,
|
||||
leftData: ArrayLike<number>,
|
||||
rightData: ArrayLike<number>
|
||||
): void {
|
||||
if (left_data) {
|
||||
const dst_buffer = audio_buffer.getChannelData(0);
|
||||
dst_buffer.set(left_data);
|
||||
if (leftData) {
|
||||
const dstBuffer = audioBuffer.getChannelData(0);
|
||||
dstBuffer.set(leftData);
|
||||
}
|
||||
|
||||
if (right_data) {
|
||||
const dst_buffer = audio_buffer.getChannelData(1);
|
||||
dst_buffer.set(right_data);
|
||||
if (rightData) {
|
||||
const dstBuffer = audioBuffer.getChannelData(1);
|
||||
dstBuffer.set(rightData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ export class RufflePlayer extends HTMLElement {
|
|||
private _trace_observer: ((message: string) => void) | null;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private Ruffle: Promise<{ new (...args: any[]): Ruffle }>;
|
||||
private ruffleConstructor: Promise<{ new (...args: any[]): Ruffle }>;
|
||||
private panicked = false;
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ export class RufflePlayer extends HTMLElement {
|
|||
this.allowScriptAccess = false;
|
||||
this._trace_observer = null;
|
||||
|
||||
this.Ruffle = load_ruffle();
|
||||
this.ruffleConstructor = load_ruffle();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ export class RufflePlayer extends HTMLElement {
|
|||
console.log("Ruffle instance destroyed.");
|
||||
}
|
||||
|
||||
const Ruffle = await this.Ruffle.catch((e) => {
|
||||
const ruffleConstructor = await this.ruffleConstructor.catch((e) => {
|
||||
console.error("Serious error loading Ruffle: " + e);
|
||||
|
||||
// Serious duck typing. In error conditions, let's not make assumptions.
|
||||
|
@ -278,7 +278,7 @@ export class RufflePlayer extends HTMLElement {
|
|||
throw e;
|
||||
});
|
||||
|
||||
this.instance = new Ruffle(
|
||||
this.instance = new ruffleConstructor(
|
||||
this.container,
|
||||
this,
|
||||
this.allowScriptAccess
|
||||
|
|
Loading…
Reference in New Issue