web: Cleanup ESLint configuration

* Cleanup .eslintrc.json files.
* Avoid unnecessary eslint-* directives.
This commit is contained in:
relrelb 2021-04-30 22:59:59 +03:00 committed by Mike Welsh
parent e8ec02418b
commit f8a8b82c04
14 changed files with 34 additions and 45 deletions

View File

@ -10,10 +10,6 @@
"commonjs": true
},
"rules": {
"no-console": "off",
"no-constant-condition": ["error", { "checkLoops": false }]
},
"globals": {
"navigator": true
"no-console": "off"
}
}

View File

@ -2,9 +2,6 @@
"env": {
"browser": true
},
"globals": {
"__webpack_public_path__": true
},
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint", "jsdoc"

View File

@ -1,5 +1,4 @@
/* eslint @typescript-eslint/naming-convention:off */
// eslint-disable-next-line @typescript-eslint/naming-convention
declare let __webpack_public_path__: string;
interface Error {

View File

@ -1,9 +1,6 @@
/* eslint @typescript-eslint/no-explicit-any: "off" */
/* eslint @typescript-eslint/ban-types: "off" */
declare global {
interface Window {
Prototype?: any;
Prototype?: any; // eslint-disable-line @typescript-eslint/no-explicit-any
}
}
@ -15,9 +12,9 @@ declare global {
* https://tc39.github.io/ecma262/#sec-array.prototype.reduce
*
*/
function polyfillArrayPrototypeReduce(): any {
function polyfillArrayPrototypeReduce() {
Object.defineProperty(Array.prototype, "reduce", {
value: function (...args: any) {
value(...args: unknown[]) {
if (
args.length === 0 &&
window.Prototype &&
@ -99,14 +96,14 @@ function tryPolyfillReflect(): void {
}
if (typeof Reflect.get !== "function") {
Object.defineProperty(Reflect, "get", {
value: function (target: any, key: any) {
value<T>(target: T, key: keyof T) {
return target[key];
},
});
}
if (typeof Reflect.set !== "function") {
Object.defineProperty(Reflect, "set", {
value: function (target: any, key: any, value: any) {
value<T>(target: T, key: keyof T, value: T[keyof T]) {
target[key] = value;
},
});
@ -119,6 +116,7 @@ function tryPolyfillReflect(): void {
* @param func The function to test.
* @returns True if the function hasn't been overridden.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function isNativeFunction(func: Function): boolean {
const val =
typeof Function.prototype.toString === "function"

View File

@ -1,5 +1,3 @@
/* eslint @typescript-eslint/no-explicit-any: "off" */
/**
* Conditional ruffle loader
*/
@ -17,7 +15,7 @@ import { setPolyfillsOnLoad } from "./js-polyfills";
* @returns A ruffle constructor that may be used to create new Ruffle
* instances.
*/
async function fetchRuffle(): Promise<{ new (...args: any[]): Ruffle }> {
async function fetchRuffle(): Promise<typeof Ruffle> {
// Apply some pure JavaScript polyfills to prevent conflicts with external
// libraries, if needed.
setPolyfillsOnLoad();
@ -33,7 +31,7 @@ async function fetchRuffle(): Promise<{ new (...args: any[]): Ruffle }> {
return Ruffle;
}
let lastLoaded: Promise<{ new (...args: any[]): Ruffle }> | null = null;
let lastLoaded: Promise<typeof Ruffle> | null = null;
/**
* Obtain an instance of `Ruffle`.
@ -43,7 +41,7 @@ let lastLoaded: Promise<{ new (...args: any[]): Ruffle }> | null = null;
* @returns A ruffle constructor that may be used to create new Ruffle
* instances.
*/
export function loadRuffle(): Promise<{ new (...args: any[]): Ruffle }> {
export function loadRuffle(): Promise<typeof Ruffle> {
if (lastLoaded == null) {
lastLoaded = fetchRuffle();
}

View File

@ -132,8 +132,7 @@ export class RufflePlayer extends HTMLElement {
private _metadata: MovieMetadata | null;
private _readyState: ReadyState;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private ruffleConstructor: Promise<{ new (...args: any[]): Ruffle }>;
private ruffleConstructor: Promise<typeof Ruffle>;
private panicked = false;
/**

View File

@ -12,6 +12,7 @@
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off"
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_" }]
}
}

View File

@ -67,10 +67,7 @@ function disable() {
}
utils.storage.onChanged.addListener((changes, namespace) => {
if (
namespace === "sync" &&
Object.prototype.hasOwnProperty.call(changes, "ruffleEnable")
) {
if (namespace === "sync" && "ruffleEnable" in changes) {
if (changes.ruffleEnable.newValue) {
enable();
} else {

View File

@ -79,16 +79,15 @@ async function queryTabStatus(
optionsChanged();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function objectsEqual(x: any, y: any) {
function objectsEqual<T>(x: T, y: T) {
for (const [key, value] of Object.entries(x)) {
if (y[key] !== value) {
if (y[key as keyof T] !== value) {
return false;
}
}
for (const [key, value] of Object.entries(y)) {
if (x[key] !== value) {
if (x[key as keyof T] !== value) {
return false;
}
}

View File

@ -1,10 +0,0 @@
{
"env": {
"browser": true,
"node": true
},
"globals": {
"__webpack_public_path__": true
},
"ignorePatterns": ["swfobject.js"]
}

View File

@ -0,0 +1,8 @@
{
"env": {
"browser": true
},
"globals": {
"__webpack_public_path__": "writable"
}
}

View File

@ -1,8 +1,10 @@
{
"env": {
"node": true,
"browser": true,
"mocha": true
},
"globals": {
"browser": true
"browser": "readonly"
}
}

View File

@ -0,0 +1,3 @@
{
"ignorePatterns": ["swfobject.js"]
}

View File

@ -1,3 +1,5 @@
/* eslint-env node */
let chrome_binary = undefined;
if (process.platform === "win32" && process.env.CI) {