ci: Introduce lint rule no-untyped-config-class-field (no-changelog) (#10436)

This commit is contained in:
Iván Ovejero 2024-08-15 16:00:11 +02:00 committed by GitHub
parent 6bca879d4a
commit bb4582fa2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View file

@ -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',
},
},
],
};

View file

@ -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) =>