Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Enforce noUnusedLocals on all backend and nodes packages (no-changelog) #8428

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/@n8n/nodes-langchain/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
Expand Down
1 change: 0 additions & 1 deletion packages/@n8n/nodes-langchain/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"preserveConstEnums": true,
"esModuleInterop": true,
Expand Down
21 changes: 2 additions & 19 deletions packages/@n8n_io/eslint-config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,9 @@ const config = (module.exports = {
*/
'prefer-spread': 'error',

/**
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unused-vars.md
*/
// These are tuned off since we use `noUnusedLocals` and `noUnusedParameters` now
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
process.env.CI_LINT_MASTER ? 'warn' : 'error',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
Comment on lines -428 to -433
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only doubt was whether we could exempt unused params with underscore, but it looks like the TS setting supports this out of the box 👍🏻

],
'@typescript-eslint/no-unused-vars': 'off',

/**
* https://www.typescriptlang.org/docs/handbook/enums.html#const-enums
Expand Down Expand Up @@ -471,12 +461,6 @@ const config = (module.exports = {
},

overrides: [
{
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['test/**/*.ts', '**/__tests__/*.ts'],
rules: {
Expand All @@ -499,7 +483,6 @@ const config = (module.exports = {
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
Expand Down
33 changes: 9 additions & 24 deletions packages/cli/src/WorkflowExecuteAdditionalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable id-denylist */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { WorkflowExecute } from 'n8n-core';

Expand Down Expand Up @@ -305,11 +304,7 @@ function hookFunctionsPush(): IWorkflowExecuteHooks {
},
],
workflowExecuteAfter: [
async function (
this: WorkflowHooks,
fullRunData: IRun,
newStaticData: IDataObject,
): Promise<void> {
async function (this: WorkflowHooks, fullRunData: IRun): Promise<void> {
const { sessionId, executionId, retryOf } = this;
const { id: workflowId } = this.workflowData;
logger.debug('Executing hook (hookFunctionsPush)', {
Expand Down Expand Up @@ -360,8 +355,7 @@ function hookFunctionsPush(): IWorkflowExecuteHooks {
};
}

export function hookFunctionsPreExecute(parentProcessMode?: string): IWorkflowExecuteHooks {
const logger = Container.get(Logger);
export function hookFunctionsPreExecute(): IWorkflowExecuteHooks {
const externalHooks = Container.get(ExternalHooks);
return {
workflowExecuteBefore: [
Expand Down Expand Up @@ -556,7 +550,7 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
},
],
workflowExecuteBefore: [
async function (workflow: Workflow, data: IRunExecutionData): Promise<void> {
async function (): Promise<void> {
void internalHooks.onWorkflowBeforeExecute(this.executionId, this.workflowData);
},
],
Expand Down Expand Up @@ -625,15 +619,11 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
eventsService.emit('workflowExecutionCompleted', this.workflowData, fullRunData);
}
},
async function (
this: WorkflowHooks,
fullRunData: IRun,
newStaticData: IDataObject,
): Promise<void> {
async function (this: WorkflowHooks, fullRunData: IRun): Promise<void> {
// send tracking and event log events, but don't wait for them
void internalHooks.onWorkflowPostExecute(this.executionId, this.workflowData, fullRunData);
},
async function (this: WorkflowHooks, fullRunData: IRun, newStaticData: IDataObject) {
async function (this: WorkflowHooks, fullRunData: IRun) {
const externalHooks = Container.get(ExternalHooks);
if (externalHooks.exists('workflow.postExecute')) {
try {
Expand Down Expand Up @@ -661,7 +651,6 @@ export async function getRunData(
workflowData: IWorkflowBase,
userId: string,
inputData?: INodeExecutionData[],
parentWorkflowId?: string,
): Promise<IWorkflowExecutionDataProcess> {
const mode = 'integrated';

Expand Down Expand Up @@ -1012,7 +1001,7 @@ function getWorkflowHooksIntegrated(
): WorkflowHooks {
optionalParameters = optionalParameters || {};
const hookFunctions = hookFunctionsSave(optionalParameters.parentProcessMode);
const preExecuteFunctions = hookFunctionsPreExecute(optionalParameters.parentProcessMode);
const preExecuteFunctions = hookFunctionsPreExecute();
for (const key of Object.keys(preExecuteFunctions)) {
if (hookFunctions[key] === undefined) {
hookFunctions[key] = [];
Expand All @@ -1034,7 +1023,7 @@ export function getWorkflowHooksWorkerExecuter(
): WorkflowHooks {
optionalParameters = optionalParameters || {};
const hookFunctions = hookFunctionsSaveWorker();
const preExecuteFunctions = hookFunctionsPreExecute(optionalParameters.parentProcessMode);
const preExecuteFunctions = hookFunctionsPreExecute();
for (const key of Object.keys(preExecuteFunctions)) {
if (hookFunctions[key] === undefined) {
hookFunctions[key] = [];
Expand All @@ -1055,7 +1044,7 @@ export function getWorkflowHooksWorkerMain(
optionalParameters?: IWorkflowHooksOptionalParameters,
): WorkflowHooks {
optionalParameters = optionalParameters || {};
const hookFunctions = hookFunctionsPreExecute(optionalParameters.parentProcessMode);
const hookFunctions = hookFunctionsPreExecute();

// TODO: why are workers pushing to frontend?
// TODO: simplifying this for now to just leave the bare minimum hooks
Expand All @@ -1075,11 +1064,7 @@ export function getWorkflowHooksWorkerMain(
hookFunctions.nodeExecuteBefore = [];
hookFunctions.nodeExecuteAfter = [];
hookFunctions.workflowExecuteAfter = [
async function (
this: WorkflowHooks,
fullRunData: IRun,
newStaticData: IDataObject,
): Promise<void> {
async function (this: WorkflowHooks, fullRunData: IRun): Promise<void> {
const executionStatus = determineFinalExecutionStatus(fullRunData);
const saveSettings = toSaveSettings(this.workflowData.settings);

Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/WorkflowRunnerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ class WorkflowRunnerProcess {
workflowData,
additionalData.userId,
options?.inputData,
options?.parentWorkflowId,
);
await sendToParentProcess('startExecution', { runData });
const executionId: string = await new Promise((resolve) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export class Start extends BaseCommand {
private openBrowser() {
const editorUrl = Container.get(UrlService).baseUrl;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
open(editorUrl, { wait: true }).catch((error: Error) => {
open(editorUrl, { wait: true }).catch(() => {
console.log(
`\nWas not able to open URL in browser. Please open manually by visiting:\n${editorUrl}\n`,
);
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { BinaryData } from 'n8n-core';
import type { schema } from './schema';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unused-vars */

import { MessageEventBusDestination } from './MessageEventBusDestination.ee';
import axios from 'axios';
Expand Down Expand Up @@ -133,7 +132,6 @@ export class MessageEventBusDestinationWebhook

const sendQuery = this.sendQuery;
const specifyQuery = this.specifyQuery;
const sendPayload = this.sendPayload;
const sendHeaders = this.sendHeaders;
const specifyHeaders = this.specifyHeaders;

Expand Down Expand Up @@ -287,8 +285,6 @@ export class MessageEventBusDestinationWebhook
let httpDigestAuth;
let httpHeaderAuth;
let httpQueryAuth;
let oAuth1Api;
let oAuth2Api;

if (this.authentication === 'genericCredentialType') {
if (this.genericAuthType === 'httpBasicAuth') {
Expand All @@ -307,14 +303,6 @@ export class MessageEventBusDestinationWebhook
try {
httpQueryAuth = await this.matchDecryptedCredentialType('httpQueryAuth');
} catch {}
} else if (this.genericAuthType === 'oAuth1Api') {
try {
oAuth1Api = await this.matchDecryptedCredentialType('oAuth1Api');
} catch {}
} else if (this.genericAuthType === 'oAuth2Api') {
try {
oAuth2Api = await this.matchDecryptedCredentialType('oAuth2Api');
} catch {}
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo",
// TODO: remove all options below this line
"strict": false,
"noUnusedLocals": false,
"useUnknownInCatchVariables": false
},
"include": ["src/**/*.ts", "test/**/*.ts", "src/sso/saml/saml-schema-metadata-2.0.xsd"],
Expand Down
17 changes: 4 additions & 13 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-unsafe-call */
Expand Down Expand Up @@ -2527,8 +2526,6 @@ async function getInputConnectionData(
closeFunctions: CloseFunction[],
inputName: ConnectionTypes,
itemIndex: number,
// TODO: Not implemented yet, and maybe also not needed
inputIndex?: number,
): Promise<unknown> {
const node = this.getNode();
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
Expand Down Expand Up @@ -3201,12 +3198,12 @@ export function getExecutePollFunctions(
return ((workflow: Workflow, node: INode) => {
return {
...getCommonWorkflowFunctions(workflow, node, additionalData),
__emit: (data: INodeExecutionData[][]): void => {
__emit: (): void => {
throw new ApplicationError(
'Overwrite NodeExecuteFunctions.getExecutePollFunctions.__emit function!',
);
},
__emitError(error: Error) {
__emitError() {
throw new ApplicationError(
'Overwrite NodeExecuteFunctions.getExecutePollFunctions.__emitError function!',
);
Expand Down Expand Up @@ -3264,12 +3261,12 @@ export function getExecuteTriggerFunctions(
return ((workflow: Workflow, node: INode) => {
return {
...getCommonWorkflowFunctions(workflow, node, additionalData),
emit: (data: INodeExecutionData[][]): void => {
emit: (): void => {
throw new ApplicationError(
'Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function!',
);
},
emitError: (error: Error): void => {
emitError: (): void => {
throw new ApplicationError(
'Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function!',
);
Expand Down Expand Up @@ -3390,8 +3387,6 @@ export function getExecuteFunctions(
async getInputConnectionData(
inputName: ConnectionTypes,
itemIndex: number,
// TODO: Not implemented yet, and maybe also not needed
inputIndex?: number,
): Promise<unknown> {
return await getInputConnectionData.call(
this,
Expand All @@ -3405,7 +3400,6 @@ export function getExecuteFunctions(
closeFunctions,
inputName,
itemIndex,
inputIndex,
);
},

Expand Down Expand Up @@ -3919,8 +3913,6 @@ export function getExecuteWebhookFunctions(
async getInputConnectionData(
inputName: ConnectionTypes,
itemIndex: number,
// TODO: Not implemented yet, and maybe also not needed
inputIndex?: number,
): Promise<unknown> {
// To be able to use expressions like "$json.sessionId" set the
// body data the webhook received to what is normally used for
Expand Down Expand Up @@ -3954,7 +3946,6 @@ export function getExecuteWebhookFunctions(
closeFunctions,
inputName,
itemIndex,
inputIndex,
);
},
getMode: () => mode,
Expand Down
1 change: 0 additions & 1 deletion packages/node-dev/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"preserveSymlinks": true,
"tsBuildInfoFile": "dist/build.tsbuildinfo",
// TODO: remove all options below this line
"noUnusedLocals": false,
"useUnknownInCatchVariables": false
},
"include": ["commands/**/*.ts", "src/**/*.ts"]
Expand Down
1 change: 0 additions & 1 deletion packages/nodes-base/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
Expand Down
Loading
Loading