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
},
"rules": {
"no-shadow": "error",
"no-magic-numbers": ["error", { "ignore": [-1, 0, 1, 2, 10, 100, 1000] }],
"no-param-reassign": "error",
"prefer-template": "error",
"prefer-arrow-callback": "error",
"arrow-body-style": ["error", "as-needed"],
"no-unused-expressions": "error",
"prefer-const": "error",
"max-classes-per-file": "error",
"object-shorthand": ["error", "methods"],
"no-useless-rename": "error",
"no-shadow": "warn",
"no-magic-numbers": ["warn", { "ignore": [-1, 0, 1, 2, 10, 100, 1000] }],
"no-param-reassign": "warn",
"prefer-template": "warn",
"prefer-arrow-callback": "warn",
"arrow-body-style": ["warn", "as-needed"],
"no-unused-expressions": "warn",
"prefer-const": "warn",
"max-classes-per-file": "warn",
"object-shorthand": ["warn", "methods"],
"no-useless-rename": "warn",
"prefer-promise-reject-errors": "error",
"eqeqeq": "error",
"eqeqeq": "warn",
"prefer-destructuring": [
"error",
"warn",
{
"VariableDeclarator": {
"array": false,
@ -37,9 +37,9 @@
}
}
],
"no-constant-condition": ["error", { "checkLoops": false }],
"no-constant-condition": ["warn", { "checkLoops": false }],
"no-throw-literal": "error",
"curly": "error",
"curly": "warn",
"no-promise-executor-return": "error",
"no-return-await": "error",
@ -82,10 +82,10 @@
]
}
],
"import/no-default-export": "error",
"import/first": "error",
"import/no-default-export": "warn",
"import/first": "warn",
"import/order": [
"error",
"warn",
{
"alphabetize": {
"order": "asc"
@ -115,12 +115,12 @@
}
},
"rules": {
"no-console": "error",
"no-console": "warn",
"no-magic-numbers": "off",
"no-shadow": "off",
"@typescript-eslint/ban-types": [
"error",
"warn",
{
"extendDefaults": true,
"types": {
@ -128,10 +128,10 @@
}
}
],
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-magic-numbers": [
"error",
"warn",
{
"ignore": [-1, 0, 1, 2, 10, 100, 1000],
"ignoreNumericLiteralTypes": true,
@ -140,16 +140,21 @@
}
],
"@typescript-eslint/no-inferrable-types": [
"error",
"warn",
{
"ignoreParameters": true,
"ignoreProperties": true
}
],
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/no-empty-function": [
"warn",
{
"allow": ["arrowFunctions", "private-constructors", "protected-constructors"]
}
],
"@typescript-eslint/naming-convention": [
"error",
"warn",
{
"selector": "default",
"format": ["camelCase"],
@ -181,15 +186,11 @@
"suffix": ["Interface"]
}
],
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@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/explicit-member-accessibility": "warn",
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/array-type": ["warn", { "default": "array-simple" }],
"@typescript-eslint/restrict-template-expressions": [
"error",
"warn",
{
"allowNumber": true,
"allowBoolean": false,
@ -197,7 +198,7 @@
"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
// initialization and is ready to create browser windows.
// 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.
app.on('window-all-closed', () => {
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
// dock icon is clicked and there are no other windows open.
const appWindowMain: AppWindowInterface = container.get('app-window-main');
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.on('will-navigate', this.onWillNavigate);
this._window.webContents.on('new-window', this.onNewWindow);
this._window.webContents.on('will-navigate', (...args) => this.onWillNavigate(...args));
this._window.webContents.on('new-window', (...args) => this.onNewWindow(args[0]));
return this.load(this._window);
}
@ -115,7 +115,9 @@ export abstract class AppWindow implements AppWindowInterface {
event.preventDefault();
}
protected onClosed(): void {}
protected onClosed(): void {
// do nothing by default
}
protected getInnerHtml(selector: string): Promise<string> {
return new Promise<string>((resolve) => {