From 88724bb056cc27d0bc64e6bbde92f34140cef2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 25 Apr 2023 11:47:03 +0200 Subject: [PATCH] ci: Enforce no unused imports (no-changelog) (#6073) --- packages/@n8n_io/eslint-config/base.js | 12 ++++ packages/@n8n_io/eslint-config/package.json | 1 + .../UserManagement/UserManagementHelper.ts | 2 - packages/cli/src/WorkflowRunner.ts | 1 - packages/editor-ui/src/Interface.ts | 1 - .../server/factories/credentialType.ts | 1 - .../editor-ui/src/api/workflow-webhooks.ts | 1 - packages/editor-ui/src/api/workflows.ts | 1 - .../editor-ui/src/components/CodeEdit.vue | 1 - .../CredentialEdit/CredentialEdit.vue | 2 +- .../CredentialEdit/CredentialSharing.ee.vue | 2 - .../components/CredentialEdit/OauthButton.vue | 1 - .../src/components/CredentialsSelect.vue | 2 +- .../src/components/Error/NodeErrorView.vue | 1 - .../components/MainHeader/WorkflowDetails.vue | 1 - .../src/components/NDVDraggablePanels.vue | 2 - packages/editor-ui/src/components/Node.vue | 3 +- .../components/Node/NodeCreator/MainPanel.vue | 4 +- .../editor-ui/src/components/NodeSettings.vue | 1 - .../editor-ui/src/components/OutputPanel.vue | 3 +- .../src/components/ParameterInput.vue | 2 +- .../src/components/ParameterInputFull.vue | 1 - .../src/components/ParameterInputWrapper.vue | 3 +- .../ResourceLocator/ResourceLocator.vue | 3 - .../editor-ui/src/components/RunDataTable.vue | 1 - .../EventDestinationCard.ee.vue | 1 - packages/editor-ui/src/components/Sticky.vue | 3 +- .../components/TagsManager/TagsManager.vue | 1 - .../editor-ui/src/components/TriggerPanel.vue | 1 - .../src/components/VariableSelector.vue | 1 - .../editor-ui/src/components/VariablesRow.vue | 1 - .../editor-ui/src/components/WorkflowCard.vue | 1 - .../src/components/WorkflowSettings.vue | 1 - .../src/components/WorkflowShareModal.ee.vue | 1 - .../__tests__/ExecutionsList.test.ts | 2 +- .../__tests__/PersonalizationModal.spec.ts | 2 +- .../layouts/ResourcesListLayout.vue | 1 - .../src/composables/useCanvasMouseSelect.ts | 2 +- .../src/composables/useHistoryHelper.ts | 2 +- packages/editor-ui/src/mixins/nodeHelpers.ts | 6 +- .../editor-ui/src/mixins/workflowHelpers.ts | 4 +- packages/editor-ui/src/permissions.ts | 1 - .../plugins/connectors/N8nCustomConnector.ts | 2 +- packages/editor-ui/src/plugins/i18n/index.ts | 1 - .../editor-ui/src/stores/environments.ee.ts | 2 - packages/editor-ui/src/stores/history.ts | 3 +- packages/editor-ui/src/stores/nodeCreator.ts | 1 - packages/editor-ui/src/stores/sso.ts | 2 +- packages/editor-ui/src/stores/users.ts | 7 +- .../editor-ui/src/utils/nodeTypesUtils.ts | 3 +- packages/editor-ui/src/utils/nodeViewUtils.ts | 3 +- packages/editor-ui/src/utils/typesUtils.ts | 2 - .../editor-ui/src/views/CredentialsView.vue | 1 - packages/editor-ui/src/views/NodeView.vue | 1 - .../src/views/SettingsCommunityNodesView.vue | 1 - .../src/views/SettingsPersonalView.vue | 2 +- .../editor-ui/src/views/SettingsUsersView.vue | 1 - .../editor-ui/src/views/WorkflowsView.vue | 3 +- .../src/views/__tests__/VariablesView.spec.ts | 1 - .../nodes/QuickChart/QuickChart.node.ts | 1 - pnpm-lock.yaml | 71 ++++++++++++++++--- 61 files changed, 98 insertions(+), 94 deletions(-) diff --git a/packages/@n8n_io/eslint-config/base.js b/packages/@n8n_io/eslint-config/base.js index db7803a40c..6c89ea6e52 100644 --- a/packages/@n8n_io/eslint-config/base.js +++ b/packages/@n8n_io/eslint-config/base.js @@ -36,6 +36,9 @@ const config = (module.exports = { */ 'eslint-plugin-n8n-local-rules', + /** https://github.com/sweepline/eslint-plugin-unused-imports */ + 'unused-imports', + /** https://github.com/sindresorhus/eslint-plugin-unicorn */ 'eslint-plugin-unicorn', ], @@ -426,6 +429,15 @@ const config = (module.exports = { */ 'import/prefer-default-export': 'off', + // ---------------------------------- + // no-unused-imports + // ---------------------------------- + + /** + * https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/no-unused-imports.md + */ + 'unused-imports/no-unused-imports': process.env.NODE_ENV === 'development' ? 'warn' : 'error', + /** https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-await.md */ 'unicorn/no-unnecessary-await': 'error', diff --git a/packages/@n8n_io/eslint-config/package.json b/packages/@n8n_io/eslint-config/package.json index 65c1b7c745..34e0abc03a 100644 --- a/packages/@n8n_io/eslint-config/package.json +++ b/packages/@n8n_io/eslint-config/package.json @@ -16,6 +16,7 @@ "eslint-plugin-n8n-local-rules": "~1.0", "eslint-plugin-prettier": "~4.2", "eslint-plugin-unicorn": "~46.0", + "eslint-plugin-unused-imports": "~2.0", "eslint-plugin-vue": "~7.17" }, "scripts": { diff --git a/packages/cli/src/UserManagement/UserManagementHelper.ts b/packages/cli/src/UserManagement/UserManagementHelper.ts index 88927f4c73..e299544840 100644 --- a/packages/cli/src/UserManagement/UserManagementHelper.ts +++ b/packages/cli/src/UserManagement/UserManagementHelper.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { In } from 'typeorm'; -import type express from 'express'; import { compare, genSaltSync, hash } from 'bcryptjs'; import { Container } from 'typedi'; @@ -12,7 +11,6 @@ import type { User } from '@db/entities/User'; import { MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH } from '@db/entities/User'; import type { Role } from '@db/entities/Role'; import { RoleRepository } from '@db/repositories'; -import type { AuthenticatedRequest } from '@/requests'; import config from '@/config'; import { getWebhookBaseUrl } from '@/WebhookHelpers'; import { License } from '@/License'; diff --git a/packages/cli/src/WorkflowRunner.ts b/packages/cli/src/WorkflowRunner.ts index 8e42685023..c785a2fa22 100644 --- a/packages/cli/src/WorkflowRunner.ts +++ b/packages/cli/src/WorkflowRunner.ts @@ -21,7 +21,6 @@ import type { IRun, WorkflowExecuteMode, WorkflowHooks, - WorkflowSettings, } from 'n8n-workflow'; import { ErrorReporterProxy as ErrorReporter, diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index d058b37f7e..0b0a578fe2 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -28,7 +28,6 @@ import type { INodeActionTypeDescription, IDisplayOptions, IExecutionsSummary, - IAbstractEventMessage, FeatureFlags, ExecutionStatus, ITelemetryTrackProperties, diff --git a/packages/editor-ui/src/__tests__/server/factories/credentialType.ts b/packages/editor-ui/src/__tests__/server/factories/credentialType.ts index 517e4e7207..7fdd221cf8 100644 --- a/packages/editor-ui/src/__tests__/server/factories/credentialType.ts +++ b/packages/editor-ui/src/__tests__/server/factories/credentialType.ts @@ -1,5 +1,4 @@ import { Factory } from 'miragejs'; -import { faker } from '@faker-js/faker'; import type { ICredentialType } from 'n8n-workflow'; const credentialTypes = [ diff --git a/packages/editor-ui/src/api/workflow-webhooks.ts b/packages/editor-ui/src/api/workflow-webhooks.ts index a6f4e92a67..601073a7b0 100644 --- a/packages/editor-ui/src/api/workflow-webhooks.ts +++ b/packages/editor-ui/src/api/workflow-webhooks.ts @@ -1,5 +1,4 @@ import type { IOnboardingCallPrompt, IUser } from '@/Interface'; -import { IOnboardingCallPromptResponse } from '@/Interface'; import { get, post } from '@/utils'; const N8N_API_BASE_URL = 'https://api.n8n.io/api'; diff --git a/packages/editor-ui/src/api/workflows.ts b/packages/editor-ui/src/api/workflows.ts index 508ed74e4a..7b2d1133cb 100644 --- a/packages/editor-ui/src/api/workflows.ts +++ b/packages/editor-ui/src/api/workflows.ts @@ -1,6 +1,5 @@ import type { IExecutionsCurrentSummaryExtended, IRestApiContext } from '@/Interface'; import type { ExecutionFilters, ExecutionOptions, IDataObject } from 'n8n-workflow'; -import { ExecutionStatus, WorkflowExecuteMode } from 'n8n-workflow'; import { makeRestApiRequest } from '@/utils'; export async function getNewWorkflow(context: IRestApiContext, name?: string) { diff --git a/packages/editor-ui/src/components/CodeEdit.vue b/packages/editor-ui/src/components/CodeEdit.vue index b798e5d9fb..287409312b 100644 --- a/packages/editor-ui/src/components/CodeEdit.vue +++ b/packages/editor-ui/src/components/CodeEdit.vue @@ -26,7 +26,6 @@ import { workflowHelpers } from '@/mixins/workflowHelpers'; import mixins from 'vue-typed-mixins'; import type { INodeUi } from '@/Interface'; -import { IExecutionResponse } from '@/Interface'; import type { IBinaryKeyData, IDataObject, diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue index f7b6f81609..f26b98036b 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue @@ -111,7 +111,7 @@