refactor: Upgrade to ESLint 8 (#3722)

* ⬆️ Upgrade to ESLint 8

* 📦 Update package-lock.json

* 👕 Add lint exceptions

* 👕 Add more lint exceptions

*  Remove `tslint` from some packages

* 👕 Except init file

* 📦 Update `package-lock.json`

* 📦 Update `package-lock.json`

* 👕 Add exceptions to new lines coming from `master `

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Iván Ovejero 2022-07-24 17:25:01 +02:00 committed by GitHub
parent 8be36c261b
commit f9f05621a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 1809 additions and 2230 deletions

View file

@ -13,6 +13,7 @@ module.exports = {
sourceType: 'module',
},
ignorePatterns: [
'n8n',
'.eslintrc.js',
'**/*.js',
'**/node_modules/**',

3950
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
#!/usr/bin/env node
var path = require('path'); // tslint:disable-line:no-var-keyword
var path = require('path');
// Make sure that it also find the config folder when it
// did get started from another folder that the root one.
process.env.NODE_CONFIG_DIR = process.env.NODE_CONFIG_DIR || path.join(__dirname, 'config');
// Check if version should be displayed
var versionFlags = [ // tslint:disable-line:no-var-keyword
var versionFlags = [
'-v',
'-V',
'--version',

View file

@ -52,6 +52,7 @@ export class DbRevertMigrationCommand extends Command {
if (connection) await connection.close();
console.error('Error reverting last migration. See log messages for details.');
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
logger.error(error.message);
this.exit(1);
}

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable no-console */
import { promises as fs } from 'fs';

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable no-console */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable no-console */
import { Command, flags } from '@oclif/command';

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/no-unsafe-call */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-shadow */

View file

@ -327,6 +327,7 @@ export class Start extends Command {
if (error.toString().includes('ECONNREFUSED') === true) {
logger.warn('Redis unavailable - trying to reconnect...');
} else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
logger.warn('Error with Redis: ', error);
}
});
@ -415,6 +416,7 @@ export class Start extends Command {
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding('utf8');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let inputText = '';
if (flags.open) {

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable no-console */
import { Command, flags } from '@oclif/command';

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { IBinaryDataConfig } from '../../core/dist/src';

View file

@ -93,7 +93,6 @@
"supertest": "^6.2.2",
"ts-jest": "^27.1.3",
"ts-node": "^8.9.1",
"tslint": "^6.1.2",
"typescript": "~4.6.0"
},
"dependencies": {

View file

@ -121,6 +121,7 @@ export class ActiveWorkflowRunner {
workflowName: workflowData.name,
workflowId: workflowData.id,
});
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.executeErrorWorkflow(error, workflowData, 'internal');
}
}

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-underscore-dangle */
import { ICredentialDataDecryptedObject } from 'n8n-workflow';

View file

@ -40,6 +40,7 @@ export class Logger implements ILogger {
winston.format.printf(({ level, message, timestamp, metadata }) => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return `${timestamp} | ${level.padEnd(18)} | ${message}${
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
Object.keys(metadata).length ? ` ${JSON.stringify(inspect(metadata))}` : ''
}`;
}),

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import express from 'express';
import { CredentialsHelper } from '../../../../CredentialsHelper';

View file

@ -158,6 +158,7 @@ export function send(processFunction: (req: Request, res: Response) => Promise<a
error.message = 'There is already an entry with this name';
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
sendErrorResponse(res, error);
}
};

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
/* eslint-disable @typescript-eslint/no-use-before-define */

View file

@ -254,6 +254,7 @@ export async function compareHash(plaintext: string, hashed: string): Promise<bo
'. Comparison against unhashed string. Please check that the value compared against has been hashed.';
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
throw new Error(error);
}
}

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable import/no-cycle */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable no-param-reassign */
@ -125,6 +126,7 @@ export function encodeWebhookResponse(
): IExecuteResponsePromiseData {
if (typeof response === 'object' && Buffer.isBuffer(response.body)) {
response.body = {
// eslint-disable-next-line @typescript-eslint/naming-convention
'__@N8nEncodedBuffer@__': response.body.toString(BINARY_ENCODING),
};
}

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-console */
/* eslint-disable consistent-return */
/* eslint-disable @typescript-eslint/restrict-plus-operands */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable import/no-cycle */
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/restrict-plus-operands */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-non-null-assertion */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable consistent-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

View file

@ -83,6 +83,7 @@ credentialsController.get(
});
}
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
LoggerProxy.error('Request to list credentials failed', error);
throw error;
}

View file

@ -61,7 +61,7 @@ nodesController.post(
try {
parsedPackageName = parsePackageName(name);
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
throw new ResponseHelper.ResponseError(error.message, undefined, 400);
}
@ -166,14 +166,14 @@ nodesController.get(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
if (error.code === 1) {
// Updates available
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
pendingUpdates = JSON.parse(error.stdout);
}
}
let hydratedPackages = matchPackagesWithUpdates(packages, pendingUpdates);
try {
if (config.get('nodes.packagesMissing')) {
// eslint-disable-next-line prettier/prettier
// eslint-disable-next-line prettier/prettier, @typescript-eslint/no-unsafe-argument
hydratedPackages = matchMissingPackages(hydratedPackages, config.get('nodes.packagesMissing'));
}
} catch (error) {

View file

@ -338,6 +338,7 @@ oauth2CredentialController.get(
return res.sendFile(pathResolve(__dirname, '../../../templates/oauth-callback.html'));
} catch (error) {
// Error response
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return ResponseHelper.sendErrorResponse(res, error);
}
},

View file

@ -39,7 +39,6 @@
"jest": "^27.4.7",
"source-map-support": "^0.5.9",
"ts-jest": "^27.1.3",
"tslint": "^6.1.2",
"typescript": "~4.6.0"
},
"dependencies": {

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-continue */
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable no-lonely-if */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable no-prototype-builtins */
@ -955,8 +956,10 @@ export async function requestOAuth2(
newRequestOptions?.headers?.Authorization.split(' ')[1];
}
// @ts-ignore
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
Object.assign(newRequestOptions.headers, {
// @ts-ignore
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
});
}
@ -1011,8 +1014,10 @@ export async function requestOAuth2(
);
const refreshedRequestOption = newToken.sign(requestOptions as clientOAuth2.RequestObject);
// @ts-ignore
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
Object.assign(newRequestOptions.headers, {
// @ts-ignore
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
});
}
@ -1088,8 +1093,10 @@ export async function requestOAuth2(
// Make the request again with the new token
const newRequestOptions = newToken.sign(requestOptions as clientOAuth2.RequestObject);
// @ts-ignore
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
Object.assign(newRequestOptions.headers, {
// @ts-ignore
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
});
}

View file

@ -215,6 +215,7 @@ export async function getUserSettings(
const settingsFile = await fsReadFile(settingsPath, 'utf8');
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
settingsCache = JSON.parse(settingsFile);
} catch (error) {
throw new Error(

View file

@ -47,10 +47,10 @@
"@types/jest": "^27.4.0",
"@types/markdown-it": "^12.2.3",
"@types/sanitize-html": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-typescript": "~4.5.6",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-service": "~4.5.0",
@ -60,7 +60,7 @@
"babel-loader": "^8.2.2",
"c8": "7.11.0",
"core-js": "^3.6.5",
"eslint": "^7.32.0",
"eslint": "^8.0.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.16.0",
"gulp": "^4.0.0",

View file

@ -52,10 +52,10 @@
"@types/node": "^16.11.22",
"@types/quill": "^2.0.1",
"@types/uuid": "^8.3.2",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-typescript": "~4.5.6",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-service": "~4.5.0",
@ -67,7 +67,7 @@
"babel-eslint": "^10.0.1",
"cross-env": "^7.0.2",
"dateformat": "^3.0.3",
"eslint": "^7.32.0",
"eslint": "^8.0.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-vue": "^7.16.0",
"file-saver": "^2.0.2",

View file

@ -49,7 +49,7 @@ export class Build extends Command {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access
this.log(`\nGOT ERROR: "${error.message}"`);
this.log('====================================');
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
this.log(error.stack);
}
}

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

View file

@ -50,8 +50,7 @@
"@types/copyfiles": "^2.1.1",
"@types/inquirer": "^6.5.0",
"@types/tmp": "^0.2.0",
"@types/vorpal": "^1.11.0",
"tslint": "^6.1.2"
"@types/vorpal": "^1.11.0"
},
"dependencies": {
"@oclif/command": "^1.5.18",

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { ChildProcess, spawn } from 'child_process';

View file

@ -718,7 +718,7 @@
"@types/tmp": "^0.2.0",
"@types/uuid": "^8.3.2",
"@types/xml2js": "^0.4.3",
"eslint-plugin-n8n-nodes-base": "^1.2.8",
"eslint-plugin-n8n-nodes-base": "^1.5.2",
"gulp": "^4.0.0",
"jest": "^27.4.7",
"n8n-workflow": "~0.109.0",

View file

@ -37,8 +37,8 @@
"@types/luxon": "^2.0.9",
"@types/node": "^16.11.22",
"@types/xml2js": "^0.4.3",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.3.0",
@ -48,7 +48,6 @@
"jest-environment-jsdom": "^27.5.1",
"prettier": "^2.3.2",
"ts-jest": "^27.1.3",
"tslint": "^6.1.2",
"typescript": "~4.6.0"
},
"dependencies": {

View file

@ -273,6 +273,7 @@ export class Expression {
throw new Error('Expression resolved to a function. Please add "()"');
} else if (returnValue !== null && typeof returnValue === 'object') {
if (returnObjectAsString) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return this.convertObjectValueToString(returnValue);
}
}

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable no-param-reassign */
@ -180,6 +181,7 @@ abstract class NodeError extends ExecutionBaseError {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected isTraversableObject(value: any): value is JsonObject {
return (
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
value && typeof value === 'object' && !Array.isArray(value) && !!Object.keys(value).length
);
}
@ -322,9 +324,10 @@ export class NodeApiError extends NodeError {
parseString(xml, { explicitArray: false }, (_, result) => {
if (!result) return;
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const topLevelKey = Object.keys(result)[0];
this.description = this.findProperty(
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
result[topLevelKey],
ERROR_MESSAGE_PROPERTIES,
['Error'].concat(ERROR_NESTING_PROPERTIES),

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

View file

@ -61,6 +61,7 @@ export function create(
depth === 0 &&
target[name.toString()] === undefined &&
typeof value === 'object' &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
Object.keys(value).length === 0
// eslint-disable-next-line no-empty
) {

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable import/no-cycle */