refactor: Clear unused ESLint directives from BE packages (no-changelog) (#6798)

This commit is contained in:
Iván Ovejero
2023-07-31 11:00:48 +02:00
committed by GitHub
parent 11567f946b
commit 72523462ea
110 changed files with 160 additions and 415 deletions

View File

@@ -29,8 +29,8 @@
"typecheck": "tsc",
"build": "tsc -p tsconfig.build.json",
"format": "prettier --write . --ignore-path ../../.prettierignore",
"lint": "eslint --quiet .",
"lintfix": "eslint . --fix",
"lint": "eslint . --quiet --report-unused-disable-directives",
"lintfix": "eslint . --fix --report-unused-disable-directives",
"watch": "tsc -p tsconfig.build.json --watch",
"test": "jest",
"test:dev": "jest --watch"

View File

@@ -88,7 +88,6 @@ export function augmentObject<T extends object>(data: T): T {
return newData[key];
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const value = Reflect.get(target, key, receiver);
if (typeof value !== 'object' || value === null) return value;

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
export const BINARY_ENCODING = 'base64';
export const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z';

View File

@@ -52,7 +52,7 @@ const AsyncFunction = (async () => {}).constructor as FunctionConstructor;
const fnConstructors = {
sync: Function.prototype.constructor,
// eslint-disable-next-line @typescript-eslint/ban-types
async: AsyncFunction.prototype.constructor,
mock: () => {
throw new ExpressionError('Arbitrary code execution detected');
@@ -130,7 +130,7 @@ export class Expression {
// Is an expression
// Remove the equal sign
// eslint-disable-next-line no-param-reassign
parameterValue = parameterValue.substr(1);
// Generate a data proxy which allows to query workflow data
@@ -573,7 +573,7 @@ export class Expression {
// Data is an object
const returnData: INodeParameters = {};
// eslint-disable-next-line no-restricted-syntax
for (const [key, value] of Object.entries(parameterValue)) {
returnData[key] = resolveParameterValue(
value as NodeParameterValueType,

View File

@@ -182,7 +182,7 @@ function chunk(value: unknown[], extraArgs: number[]) {
const chunks: unknown[][] = [];
for (let i = 0; i < value.length; i += chunkSize) {
// I have no clue why eslint thinks 2 numbers could be anything but that but here we are
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
chunks.push(value.slice(i, i + chunkSize));
}
return chunks;
@@ -275,7 +275,6 @@ function union(value: unknown[], extraArgs: unknown[][]): unknown[] {
}
const newArr: unknown[] = Array.from(value);
for (const v of others) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (newArr.findIndex((w) => deepEqual(w, v, { strict: true })) === -1) {
newArr.push(v);
}
@@ -313,7 +312,6 @@ function intersection(value: unknown[], extraArgs: unknown[][]): unknown[] {
}
}
for (const v of others) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (value.findIndex((w) => deepEqual(w, v, { strict: true })) !== -1) {
newArr.push(v);
}

View File

@@ -1,6 +1,5 @@
import { ExpressionExtensionError } from './../ExpressionError';
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import { DateTime } from 'luxon';
import type {
DateTimeUnit,

View File

@@ -88,7 +88,6 @@ export const hasNativeMethod = (method: string): boolean => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseWithEsprimaNext(source: string, options?: any): any {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const ast = esprimaParse(source, {
loc: true,
locations: true,
@@ -451,7 +450,6 @@ interface FoundFunction {
function: Function;
}
// eslint-disable-next-line @typescript-eslint/ban-types
function findExtendedFunction(input: unknown, functionName: string): FoundFunction | undefined {
// eslint-disable-next-line @typescript-eslint/ban-types
let foundFunction: Function | undefined;
@@ -479,12 +477,7 @@ function findExtendedFunction(input: unknown, functionName: string): FoundFuncti
const inputAny: any = input;
// This is likely a builtin we're implementing for another type
// (e.g. toLocaleString). We'll return that instead
if (
inputAny &&
functionName &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
typeof inputAny[functionName] === 'function'
) {
if (inputAny && functionName && typeof inputAny[functionName] === 'function') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
return { type: 'native', function: inputAny[functionName] };
}
@@ -508,7 +501,6 @@ function findExtendedFunction(input: unknown, functionName: string): FoundFuncti
* ```
*/
export function extend(input: unknown, functionName: string, args: unknown[]) {
// eslint-disable-next-line @typescript-eslint/ban-types
const foundFunction = findExtendedFunction(input, functionName);
// No type specific or generic function found. Check to see if
@@ -522,7 +514,6 @@ export function extend(input: unknown, functionName: string, args: unknown[]) {
}
if (haveFunction.length > 1) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const lastType = `"${haveFunction.pop()!.typeName}"`;
const typeNames = `${haveFunction.map((v) => `"${v.typeName}"`).join(', ')}, and ${lastType}`;
throw new ExpressionExtensionError(

View File

@@ -64,7 +64,7 @@ export function compact(value: object): object {
if (val !== null && val !== undefined && val !== 'nil' && val !== '') {
if (typeof val === 'object') {
if (Object.keys(val as object).length === 0) continue;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
newObj[key] = compact(val);
} else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/unbound-method */
// import { createHash } from 'crypto';
import { titleCase } from 'title-case';
import * as ExpressionError from '../ExpressionError';
@@ -295,7 +294,6 @@ function toSentenceCase(value: string) {
const charIndex = current.search(CHAR_TEST_REGEXP);
current =
current.slice(0, charIndex) +
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
current[charIndex]!.toLocaleUpperCase() +
current.slice(charIndex + 1).toLocaleLowerCase();
const puncIndex = current.search(PUNC_TEST_REGEXP);

View File

@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// eslint-disable-next-line max-classes-per-file
import type * as express from 'express';
import type FormData from 'form-data';
import type { IncomingHttpHeaders } from 'http';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import type { ILogger, LogTypes } from './Interfaces';
let logger: ILogger | undefined;

View File

@@ -1,11 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
// eslint-disable-next-line max-classes-per-file
import { parseString } from 'xml2js';
import { removeCircularRefs, isTraversableObject } from './utils';
import type { IDataObject, INode, IStatusCodeMessages, JsonObject } from './Interfaces';
@@ -146,7 +143,6 @@ export abstract class NodeError extends ExecutionBaseError {
potentialKeys: string[],
traversalKeys: string[] = [],
): string | null {
// eslint-disable-next-line no-restricted-syntax
for (const key of potentialKeys) {
const value = jsonError[key];
if (value) {
@@ -178,7 +174,6 @@ export abstract class NodeError extends ExecutionBaseError {
}
}
// eslint-disable-next-line no-restricted-syntax
for (const key of traversalKeys) {
const value = jsonError[key];
if (isTraversableObject(value)) {
@@ -356,14 +351,13 @@ export class NodeApiError extends NodeError {
}
private setDescriptionFromXml(xml: string) {
// eslint-disable-next-line @typescript-eslint/naming-convention
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, @typescript-eslint/no-unsafe-argument
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
result[topLevelKey],
ERROR_MESSAGE_PROPERTIES,
['Error'].concat(ERROR_NESTING_PROPERTIES),

View File

@@ -1,17 +1,13 @@
/* 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 */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable no-param-reassign */
/* eslint-disable no-continue */
/* eslint-disable prefer-spread */
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import get from 'lodash/get';
import isEqual from 'lodash/isEqual';
@@ -415,7 +411,6 @@ export function getContext(
}
if (runExecutionData.executionData.contextData[key] === undefined) {
// eslint-disable-next-line no-param-reassign
runExecutionData.executionData.contextData[key] = {};
}
@@ -1258,7 +1253,6 @@ export const tryToParseObject = (value: unknown): object => {
return value;
}
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const o = JSON.parse(String(value));
if (typeof o !== 'object' || Array.isArray(o)) {
throw new Error(`The value "${String(value)}" is not a valid object.`);
@@ -1318,7 +1312,7 @@ export const validateResourceMapperParameter = (
const key = `${nodeProperties.name}.${field.id}`;
const fieldErrors: string[] = [];
if (field.required && !skipRequiredCheck) {
if (value.value === null || fieldValue === null || fieldValue === undefined) {
if (value.value === null || fieldValue === undefined) {
const error = `${fieldWordSingular} "${field.id}" is required`;
fieldErrors.push(error);
}

View File

@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable no-param-reassign */
/* eslint-disable no-underscore-dangle */
import type { IDataObject, IObservableObject } from './Interfaces';
interface IObservableOptions {
@@ -14,14 +13,13 @@ export function create(
option?: IObservableOptions,
depth?: number,
): IDataObject {
// eslint-disable-next-line no-param-reassign, @typescript-eslint/prefer-nullish-coalescing
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
depth = depth || 0;
// Make all the children of target also observable
// eslint-disable-next-line no-restricted-syntax
for (const key in target) {
if (typeof target[key] === 'object' && target[key] !== null) {
// eslint-disable-next-line no-param-reassign
target[key] = create(
target[key] as IDataObject,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
@@ -37,7 +35,6 @@ export function create(
writable: true,
});
return new Proxy(target, {
// eslint-disable-next-line @typescript-eslint/no-shadow
deleteProperty(target, name) {
if (parent === undefined) {
// If no parent is given mark current data as changed
@@ -65,7 +62,6 @@ export function create(
typeof value === 'object' &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
Object.keys(value).length === 0
// eslint-disable-next-line no-empty
) {
} else {
(target as IObservableObject).__dataChanged = true;

View File

@@ -1,14 +1,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable no-param-reassign */
/* eslint-disable no-continue */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
import get from 'lodash/get';
import merge from 'lodash/merge';
import set from 'lodash/set';
@@ -359,7 +355,6 @@ export class RoutingNode {
if (action.type === 'setKeyValue') {
const returnData: INodeExecutionData[] = [];
// eslint-disable-next-line @typescript-eslint/no-loop-func
inputData.forEach((item) => {
const returnItem: IDataObject = {};
for (const key of Object.keys(action.properties)) {
@@ -454,7 +449,7 @@ export class RoutingNode {
}
} else {
// No postReceive functionality got defined so simply add data as it is
// eslint-disable-next-line no-lonely-if
if (Array.isArray(responseData.body)) {
returnData = responseData.body.map((json) => {
return {
@@ -814,7 +809,7 @@ export class RoutingNode {
if (nodeProperties.routing.send.type === 'body') {
// Send in "body"
// eslint-disable-next-line no-lonely-if
if (nodeProperties.routing.send.propertyInDotNotation === false) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(returnData.options.body as Record<string, any>)![propertyName] = value;
@@ -823,7 +818,7 @@ export class RoutingNode {
}
} else {
// Send in "query"
// eslint-disable-next-line no-lonely-if
if (nodeProperties.routing.send.propertyInDotNotation === false) {
returnData.options.qs![propertyName] = value;
} else {

View File

@@ -161,7 +161,7 @@ export function generateNodesGraph(
nodeItem.src_instance_id = options.sourceInstanceId;
}
if (node.id && options?.nodeIdMap && options.nodeIdMap[node.id]) {
if (node.id && options?.nodeIdMap?.[node.id]) {
nodeItem.src_node_id = options.nodeIdMap[node.id];
}

View File

@@ -1,18 +1,11 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable no-await-in-loop */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-for-in-array */
/* eslint-disable no-prototype-builtins */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-continue */
/* eslint-disable no-restricted-syntax */
import type {
IConnections,
@@ -214,7 +207,6 @@ export class Workflow {
continue;
}
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
if (ignoreNodeTypes !== undefined && ignoreNodeTypes.includes(node.type)) {
continue;
}
@@ -482,7 +474,6 @@ export class Workflow {
const returnData: any = {};
for (const parameterName of Object.keys(parameterValue || {})) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
returnData[parameterName] = this.renameNodeInParameterValue(
parameterValue![parameterName as keyof typeof parameterValue],
currentName,

View File

@@ -1,11 +1,8 @@
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/no-this-alias */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable no-prototype-builtins */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { DateTime, Duration, Interval, Settings } from 'luxon';
import * as jmespath from 'jmespath';
@@ -163,7 +160,7 @@ export class WorkflowDataProxy {
},
get(target, name, receiver) {
if (name === 'isProxy') return true;
// eslint-disable-next-line no-param-reassign
name = name.toString();
const contextData = NodeHelpers.getContext(that.runExecutionData!, 'node', node);
@@ -183,7 +180,7 @@ export class WorkflowDataProxy {
ownKeys(target) {
return Reflect.ownKeys(target);
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
get(target, name, receiver) {
if (name === 'isProxy') return true;
name = name.toString();
@@ -326,7 +323,7 @@ export class WorkflowDataProxy {
const taskData = that.runExecutionData.resultData.runData[nodeName][runIndex].data!;
if (taskData.main === null || !taskData.main.length || taskData.main[0] === null) {
if (!taskData.main?.length || taskData.main[0] === null) {
// throw new Error(`No data found for item-index: "${itemIndex}"`);
throw new ExpressionError('No data found from "main" input.', {
runIndex: that.runIndex,
@@ -425,7 +422,7 @@ export class WorkflowDataProxy {
for (const propertyName in binaryData) {
if (propertyName === 'data') {
// Skip the data property
// eslint-disable-next-line no-continue
continue;
}
(returnData[keyName] as IDataObject)[propertyName] = binaryData[propertyName];
@@ -440,10 +437,7 @@ export class WorkflowDataProxy {
// Get node parameter data
return that.nodeParameterGetter(nodeName);
} else if (name === 'runIndex') {
if (
that.runExecutionData === null ||
!that.runExecutionData.resultData.runData[nodeName]
) {
if (!that.runExecutionData?.resultData.runData[nodeName]) {
return -1;
}
return that.runExecutionData.resultData.runData[nodeName].length - 1;

View File

@@ -25,7 +25,7 @@ export class WorkflowHooks {
workflowData: IWorkflowBase,
optionalParameters?: IWorkflowHooksOptionalParameters,
) {
// eslint-disable-next-line no-param-reassign, @typescript-eslint/prefer-nullish-coalescing
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
optionalParameters = optionalParameters || {};
this.hookFunctions = hookFunctions;
@@ -37,12 +37,10 @@ export class WorkflowHooks {
this.retryOf = optionalParameters.retryOf ?? undefined;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async executeHookFunctions(hookName: string, parameters: any[]) {
if (this.hookFunctions[hookName] !== undefined && Array.isArray(this.hookFunctions[hookName])) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, no-restricted-syntax
for (const hookFunction of this.hookFunctions[hookName]!) {
// eslint-disable-next-line no-await-in-loop
await hookFunction.apply(this, parameters);
}
}

View File

@@ -131,13 +131,7 @@ export function assert<T>(condition: T, msg?: string): asserts condition {
}
export const isTraversableObject = (value: any): value is JsonObject => {
return (
value &&
typeof value === 'object' &&
!Array.isArray(value) &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
!!Object.keys(value).length
);
return value && typeof value === 'object' && !Array.isArray(value) && !!Object.keys(value).length;
};
export const removeCircularRefs = (obj: JsonObject, seen = new Set()) => {

View File

@@ -79,7 +79,6 @@ export class Credentials extends ICredentials {
throw new Error('No data was set.');
}
// eslint-disable-next-line no-prototype-builtins
if (!fullData.hasOwnProperty(key)) {
throw new Error(`No data for key "${key}" exists.`);
}
@@ -327,7 +326,6 @@ export function getExecuteFunctions(
additionalData.sendMessageToUI(node.name, args);
}
} catch (error) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
console.error(`There was a problem sending message to UI: ${error.message}`);
}
},