refactor: change most eslint rules to only warn the user, re-enable some eslint rules and change code accordingly

This commit is contained in:
Xymorot 2021-01-24 19:48:06 +01:00
parent 6b2824daab
commit 8eac33e231
3 changed files with 47 additions and 42 deletions

View File

@ -11,21 +11,21 @@
"node": true "node": true
}, },
"rules": { "rules": {
"no-shadow": "error", "no-shadow": "warn",
"no-magic-numbers": ["error", { "ignore": [-1, 0, 1, 2, 10, 100, 1000] }], "no-magic-numbers": ["warn", { "ignore": [-1, 0, 1, 2, 10, 100, 1000] }],
"no-param-reassign": "error", "no-param-reassign": "warn",
"prefer-template": "error", "prefer-template": "warn",
"prefer-arrow-callback": "error", "prefer-arrow-callback": "warn",
"arrow-body-style": ["error", "as-needed"], "arrow-body-style": ["warn", "as-needed"],
"no-unused-expressions": "error", "no-unused-expressions": "warn",
"prefer-const": "error", "prefer-const": "warn",
"max-classes-per-file": "error", "max-classes-per-file": "warn",
"object-shorthand": ["error", "methods"], "object-shorthand": ["warn", "methods"],
"no-useless-rename": "error", "no-useless-rename": "warn",
"prefer-promise-reject-errors": "error", "prefer-promise-reject-errors": "error",
"eqeqeq": "error", "eqeqeq": "warn",
"prefer-destructuring": [ "prefer-destructuring": [
"error", "warn",
{ {
"VariableDeclarator": { "VariableDeclarator": {
"array": false, "array": false,
@ -37,9 +37,9 @@
} }
} }
], ],
"no-constant-condition": ["error", { "checkLoops": false }], "no-constant-condition": ["warn", { "checkLoops": false }],
"no-throw-literal": "error", "no-throw-literal": "error",
"curly": "error", "curly": "warn",
"no-promise-executor-return": "error", "no-promise-executor-return": "error",
"no-return-await": "error", "no-return-await": "error",
@ -82,10 +82,10 @@
] ]
} }
], ],
"import/no-default-export": "error", "import/no-default-export": "warn",
"import/first": "error", "import/first": "warn",
"import/order": [ "import/order": [
"error", "warn",
{ {
"alphabetize": { "alphabetize": {
"order": "asc" "order": "asc"
@ -115,12 +115,12 @@
} }
}, },
"rules": { "rules": {
"no-console": "error", "no-console": "warn",
"no-magic-numbers": "off", "no-magic-numbers": "off",
"no-shadow": "off", "no-shadow": "off",
"@typescript-eslint/ban-types": [ "@typescript-eslint/ban-types": [
"error", "warn",
{ {
"extendDefaults": true, "extendDefaults": true,
"types": { "types": {
@ -128,10 +128,10 @@
} }
} }
], ],
"@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-magic-numbers": [ "@typescript-eslint/no-magic-numbers": [
"error", "warn",
{ {
"ignore": [-1, 0, 1, 2, 10, 100, 1000], "ignore": [-1, 0, 1, 2, 10, 100, 1000],
"ignoreNumericLiteralTypes": true, "ignoreNumericLiteralTypes": true,
@ -140,16 +140,21 @@
} }
], ],
"@typescript-eslint/no-inferrable-types": [ "@typescript-eslint/no-inferrable-types": [
"error", "warn",
{ {
"ignoreParameters": true, "ignoreParameters": true,
"ignoreProperties": true "ignoreProperties": true
} }
], ],
"@typescript-eslint/prefer-for-of": "error", "@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-empty-function": [
"warn",
{
"allow": ["arrowFunctions", "private-constructors", "protected-constructors"]
}
],
"@typescript-eslint/naming-convention": [ "@typescript-eslint/naming-convention": [
"error", "warn",
{ {
"selector": "default", "selector": "default",
"format": ["camelCase"], "format": ["camelCase"],
@ -181,15 +186,11 @@
"suffix": ["Interface"] "suffix": ["Interface"]
} }
], ],
"@typescript-eslint/explicit-member-accessibility": "error", "@typescript-eslint/explicit-member-accessibility": "warn",
"@typescript-eslint/unbound-method": "off", "@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/ban-ts-ignore": "off", "@typescript-eslint/array-type": ["warn", { "default": "array-simple" }],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/array-type": ["error", { "default": "array-simple" }],
"@typescript-eslint/restrict-template-expressions": [ "@typescript-eslint/restrict-template-expressions": [
"error", "warn",
{ {
"allowNumber": true, "allowNumber": true,
"allowBoolean": false, "allowBoolean": false,
@ -197,7 +198,7 @@
"allowNullish": false "allowNullish": false
} }
], ],
"@typescript-eslint/no-shadow": ["error"] "@typescript-eslint/no-shadow": ["warn"]
} }
}, },
{ {

View File

@ -37,19 +37,21 @@ async function createWindow(): Promise<void> {
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.on('ready', createWindow); app.on('ready', () => {
void createWindow();
});
// Quit when all windows are closed. // Quit when all windows are closed.
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
app.quit(); app.quit();
}); });
app.on('activate', async () => { app.on('activate', () => {
// On OS X it"s common to re-create a window in the app when the // On OS X it"s common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open. // dock icon is clicked and there are no other windows open.
const appWindowMain: AppWindowInterface = container.get('app-window-main'); const appWindowMain: AppWindowInterface = container.get('app-window-main');
if (appWindowMain.isClosed()) { if (appWindowMain.isClosed()) {
await createWindow(); void createWindow();
} }
}); });

View File

@ -75,8 +75,8 @@ export abstract class AppWindow implements AppWindowInterface {
this._window.webContents.openDevTools(); this._window.webContents.openDevTools();
} }
this._window.webContents.on('will-navigate', this.onWillNavigate); this._window.webContents.on('will-navigate', (...args) => this.onWillNavigate(...args));
this._window.webContents.on('new-window', this.onNewWindow); this._window.webContents.on('new-window', (...args) => this.onNewWindow(args[0]));
return this.load(this._window); return this.load(this._window);
} }
@ -115,7 +115,9 @@ export abstract class AppWindow implements AppWindowInterface {
event.preventDefault(); event.preventDefault();
} }
protected onClosed(): void {} protected onClosed(): void {
// do nothing by default
}
protected getInnerHtml(selector: string): Promise<string> { protected getInnerHtml(selector: string): Promise<string> {
return new Promise<string>((resolve) => { return new Promise<string>((resolve) => {