From bb4582fa2f05ca388739d5a292c47d68e9ede159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 15 Aug 2024 16:00:11 +0200 Subject: [PATCH] ci: Introduce lint rule `no-untyped-config-class-field` (no-changelog) (#10436) --- packages/@n8n/config/.eslintrc.js | 9 ++++++++ packages/@n8n_io/eslint-config/local-rules.js | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/packages/@n8n/config/.eslintrc.js b/packages/@n8n/config/.eslintrc.js index 032e99b09e..e5a8f3f0f9 100644 --- a/packages/@n8n/config/.eslintrc.js +++ b/packages/@n8n/config/.eslintrc.js @@ -7,4 +7,13 @@ module.exports = { extends: ['@n8n_io/eslint-config/node'], ...sharedOptions(__dirname), + + overrides: [ + { + files: ['**/*.config.ts'], + rules: { + 'n8n-local-rules/no-untyped-config-class-field': 'error', + }, + }, + ], }; diff --git a/packages/@n8n_io/eslint-config/local-rules.js b/packages/@n8n_io/eslint-config/local-rules.js index 09a9c00f0f..92b0f6669e 100644 --- a/packages/@n8n_io/eslint-config/local-rules.js +++ b/packages/@n8n_io/eslint-config/local-rules.js @@ -492,6 +492,29 @@ module.exports = { }; }, }, + + 'no-untyped-config-class-field': { + meta: { + type: 'problem', + docs: { + description: 'Enforce explicit typing of config class fields', + recommended: 'error', + }, + messages: { + noUntypedConfigClassField: + 'Class field must have an explicit type annotation, e.g. `field: type = value`. See: https://github.com/n8n-io/n8n/pull/10433', + }, + }, + create(context) { + return { + PropertyDefinition(node) { + if (!node.typeAnnotation) { + context.report({ node: node.key, messageId: 'noUntypedConfigClassField' }); + } + }, + }; + }, + }, }; const isJsonParseCall = (node) =>