@n8n/eslint-plugin-community-nodes 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/README.md +39 -52
  3. package/dist/plugin.d.ts +0 -78
  4. package/dist/plugin.d.ts.map +1 -1
  5. package/dist/plugin.js +0 -26
  6. package/dist/plugin.js.map +1 -1
  7. package/dist/rules/index.d.ts +0 -13
  8. package/dist/rules/index.d.ts.map +1 -1
  9. package/dist/rules/index.js +0 -26
  10. package/dist/rules/index.js.map +1 -1
  11. package/dist/typecheck.tsbuildinfo +1 -1
  12. package/docs/rules/no-forbidden-lifecycle-scripts.md +1 -1
  13. package/package.json +4 -4
  14. package/src/plugin.ts +0 -26
  15. package/src/rules/index.ts +0 -26
  16. package/dist/rules/cred-class-name-field-conventions.d.ts +0 -2
  17. package/dist/rules/cred-class-name-field-conventions.d.ts.map +0 -1
  18. package/dist/rules/cred-class-name-field-conventions.js +0 -89
  19. package/dist/rules/cred-class-name-field-conventions.js.map +0 -1
  20. package/dist/rules/cred-class-name-suffix.d.ts +0 -2
  21. package/dist/rules/cred-class-name-suffix.d.ts.map +0 -1
  22. package/dist/rules/cred-class-name-suffix.js +0 -53
  23. package/dist/rules/cred-class-name-suffix.js.map +0 -1
  24. package/dist/rules/cred-filename-against-convention.d.ts +0 -2
  25. package/dist/rules/cred-filename-against-convention.d.ts.map +0 -1
  26. package/dist/rules/cred-filename-against-convention.js +0 -42
  27. package/dist/rules/cred-filename-against-convention.js.map +0 -1
  28. package/dist/rules/no-asterisk-in-option-names.d.ts +0 -2
  29. package/dist/rules/no-asterisk-in-option-names.d.ts.map +0 -1
  30. package/dist/rules/no-asterisk-in-option-names.js +0 -90
  31. package/dist/rules/no-asterisk-in-option-names.js.map +0 -1
  32. package/dist/rules/no-duplicate-param-options.d.ts +0 -2
  33. package/dist/rules/no-duplicate-param-options.d.ts.map +0 -1
  34. package/dist/rules/no-duplicate-param-options.js +0 -97
  35. package/dist/rules/no-duplicate-param-options.js.map +0 -1
  36. package/dist/rules/node-class-description-name-camelcase.d.ts +0 -2
  37. package/dist/rules/node-class-description-name-camelcase.d.ts.map +0 -1
  38. package/dist/rules/node-class-description-name-camelcase.js +0 -92
  39. package/dist/rules/node-class-description-name-camelcase.js.map +0 -1
  40. package/dist/rules/node-filename-against-convention.d.ts +0 -2
  41. package/dist/rules/node-filename-against-convention.d.ts.map +0 -1
  42. package/dist/rules/node-filename-against-convention.js +0 -61
  43. package/dist/rules/node-filename-against-convention.js.map +0 -1
  44. package/dist/rules/node-operation-error-itemindex.d.ts +0 -12
  45. package/dist/rules/node-operation-error-itemindex.d.ts.map +0 -1
  46. package/dist/rules/node-operation-error-itemindex.js +0 -184
  47. package/dist/rules/node-operation-error-itemindex.js.map +0 -1
  48. package/dist/rules/options-sorted-alphabetically.d.ts +0 -2
  49. package/dist/rules/options-sorted-alphabetically.d.ts.map +0 -1
  50. package/dist/rules/options-sorted-alphabetically.js +0 -95
  51. package/dist/rules/options-sorted-alphabetically.js.map +0 -1
  52. package/dist/rules/require-community-node-keyword.d.ts +0 -2
  53. package/dist/rules/require-community-node-keyword.d.ts.map +0 -1
  54. package/dist/rules/require-community-node-keyword.js +0 -65
  55. package/dist/rules/require-community-node-keyword.js.map +0 -1
  56. package/dist/rules/require-continue-on-fail.d.ts +0 -2
  57. package/dist/rules/require-continue-on-fail.d.ts.map +0 -1
  58. package/dist/rules/require-continue-on-fail.js +0 -76
  59. package/dist/rules/require-continue-on-fail.js.map +0 -1
  60. package/dist/rules/require-mit-license.d.ts +0 -2
  61. package/dist/rules/require-mit-license.d.ts.map +0 -1
  62. package/dist/rules/require-mit-license.js +0 -57
  63. package/dist/rules/require-mit-license.js.map +0 -1
  64. package/dist/rules/require-param-default.d.ts +0 -15
  65. package/dist/rules/require-param-default.d.ts.map +0 -1
  66. package/dist/rules/require-param-default.js +0 -75
  67. package/dist/rules/require-param-default.js.map +0 -1
  68. package/docs/rules/cred-class-name-field-conventions.md +0 -38
  69. package/docs/rules/cred-class-name-suffix.md +0 -46
  70. package/docs/rules/cred-filename-against-convention.md +0 -42
  71. package/docs/rules/no-asterisk-in-option-names.md +0 -61
  72. package/docs/rules/no-duplicate-param-options.md +0 -46
  73. package/docs/rules/node-class-description-name-camelcase.md +0 -41
  74. package/docs/rules/node-filename-against-convention.md +0 -50
  75. package/docs/rules/node-operation-error-itemindex.md +0 -81
  76. package/docs/rules/options-sorted-alphabetically.md +0 -63
  77. package/docs/rules/require-community-node-keyword.md +0 -45
  78. package/docs/rules/require-continue-on-fail.md +0 -56
  79. package/docs/rules/require-mit-license.md +0 -38
  80. package/docs/rules/require-param-default.md +0 -60
  81. package/src/rules/cred-class-name-field-conventions.test.ts +0 -121
  82. package/src/rules/cred-class-name-field-conventions.ts +0 -102
  83. package/src/rules/cred-class-name-suffix.test.ts +0 -74
  84. package/src/rules/cred-class-name-suffix.ts +0 -57
  85. package/src/rules/cred-filename-against-convention.test.ts +0 -72
  86. package/src/rules/cred-filename-against-convention.ts +0 -48
  87. package/src/rules/no-asterisk-in-option-names.test.ts +0 -185
  88. package/src/rules/no-asterisk-in-option-names.ts +0 -111
  89. package/src/rules/no-duplicate-param-options.test.ts +0 -125
  90. package/src/rules/no-duplicate-param-options.ts +0 -125
  91. package/src/rules/node-class-description-name-camelcase.test.ts +0 -121
  92. package/src/rules/node-class-description-name-camelcase.ts +0 -114
  93. package/src/rules/node-filename-against-convention.test.ts +0 -115
  94. package/src/rules/node-filename-against-convention.ts +0 -76
  95. package/src/rules/node-operation-error-itemindex.test.ts +0 -280
  96. package/src/rules/node-operation-error-itemindex.ts +0 -223
  97. package/src/rules/options-sorted-alphabetically.test.ts +0 -468
  98. package/src/rules/options-sorted-alphabetically.ts +0 -129
  99. package/src/rules/require-community-node-keyword.test.ts +0 -82
  100. package/src/rules/require-community-node-keyword.ts +0 -78
  101. package/src/rules/require-continue-on-fail.test.ts +0 -129
  102. package/src/rules/require-continue-on-fail.ts +0 -88
  103. package/src/rules/require-mit-license.test.ts +0 -67
  104. package/src/rules/require-mit-license.ts +0 -65
  105. package/src/rules/require-param-default.test.ts +0 -227
  106. package/src/rules/require-param-default.ts +0 -89
@@ -1,227 +0,0 @@
1
- import { RuleTester } from '@typescript-eslint/rule-tester';
2
-
3
- import { RequireParamDefaultRule } from './require-param-default.js';
4
-
5
- const ruleTester = new RuleTester();
6
-
7
- function createNodeCode(properties: string): string {
8
- return `
9
- import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
10
-
11
- export class TestNode implements INodeType {
12
- description: INodeTypeDescription = {
13
- displayName: 'Test Node',
14
- name: 'testNode',
15
- group: ['input'],
16
- version: 1,
17
- description: 'A test node',
18
- defaults: { name: 'Test Node' },
19
- inputs: [],
20
- outputs: [],
21
- properties: [
22
- ${properties}
23
- ],
24
- };
25
- }
26
- `;
27
- }
28
-
29
- ruleTester.run('require-param-default', RequireParamDefaultRule, {
30
- valid: [
31
- {
32
- name: 'class that does not implement INodeType',
33
- filename: '/tmp/TestNode.node.ts',
34
- code: `
35
- export class NotANode {
36
- description = {
37
- properties: [{ displayName: 'Field', name: 'field', type: 'string' }],
38
- };
39
- }
40
- `,
41
- },
42
- {
43
- name: 'param-shaped object outside description (e.g. in a method) is ignored',
44
- filename: '/tmp/TestNode.node.ts',
45
- code: `
46
- import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
47
-
48
- export class TestNode implements INodeType {
49
- description: INodeTypeDescription = {
50
- displayName: 'Test Node',
51
- name: 'testNode',
52
- properties: [],
53
- };
54
-
55
- methods = {
56
- loadOptions: {
57
- async getThings() {
58
- const config = { displayName: 'X', name: 'x', type: 'string' };
59
- return [config];
60
- },
61
- },
62
- };
63
- }
64
- `,
65
- },
66
- {
67
- name: 'non .node.ts file is ignored',
68
- filename: '/tmp/helper.ts',
69
- code: `
70
- export class TestNode {
71
- description = {
72
- properties: [{ displayName: 'Field', name: 'field', type: 'string' }],
73
- };
74
- }
75
- `,
76
- },
77
- {
78
- name: 'string parameter with default',
79
- filename: '/tmp/TestNode.node.ts',
80
- code: createNodeCode(`
81
- {
82
- displayName: 'Field',
83
- name: 'field',
84
- type: 'string',
85
- default: '',
86
- },
87
- `),
88
- },
89
- {
90
- name: 'options parameter with default',
91
- filename: '/tmp/TestNode.node.ts',
92
- code: createNodeCode(`
93
- {
94
- displayName: 'Operation',
95
- name: 'operation',
96
- type: 'options',
97
- options: [{ name: 'Create', value: 'create' }],
98
- default: 'create',
99
- },
100
- `),
101
- },
102
- {
103
- name: 'notice parameter with empty default',
104
- filename: '/tmp/TestNode.node.ts',
105
- code: createNodeCode(`
106
- {
107
- displayName: 'Some notice',
108
- name: 'notice',
109
- type: 'notice',
110
- default: '',
111
- },
112
- `),
113
- },
114
- {
115
- name: 'options-array entries (name/value, no displayName) are not parameters',
116
- filename: '/tmp/TestNode.node.ts',
117
- code: createNodeCode(`
118
- {
119
- displayName: 'Operation',
120
- name: 'operation',
121
- type: 'options',
122
- options: [{ name: 'Create', value: 'create', type: 'whatever' }],
123
- default: 'create',
124
- },
125
- `),
126
- },
127
- {
128
- name: 'object with name and type but no displayName is not a parameter',
129
- filename: '/tmp/TestNode.node.ts',
130
- code: createNodeCode(`
131
- {
132
- displayName: 'Routing',
133
- name: 'routing',
134
- type: 'string',
135
- default: '',
136
- routing: { request: { method: 'GET', name: 'x', type: 'y' } },
137
- },
138
- `),
139
- },
140
- {
141
- name: 'nested collection options all have defaults',
142
- filename: '/tmp/TestNode.node.ts',
143
- code: createNodeCode(`
144
- {
145
- displayName: 'Additional Fields',
146
- name: 'additionalFields',
147
- type: 'collection',
148
- default: {},
149
- options: [
150
- {
151
- displayName: 'Limit',
152
- name: 'limit',
153
- type: 'number',
154
- default: 50,
155
- },
156
- ],
157
- },
158
- `),
159
- },
160
- ],
161
- invalid: [
162
- {
163
- name: 'string parameter missing default',
164
- filename: '/tmp/TestNode.node.ts',
165
- code: createNodeCode(`
166
- {
167
- displayName: 'Field',
168
- name: 'field',
169
- type: 'string',
170
- },
171
- `),
172
- errors: [{ messageId: 'missingDefault', data: { name: 'field' } }],
173
- },
174
- {
175
- name: 'notice parameter missing default',
176
- filename: '/tmp/TestNode.node.ts',
177
- code: createNodeCode(`
178
- {
179
- displayName: 'Some notice',
180
- name: 'notice',
181
- type: 'notice',
182
- },
183
- `),
184
- errors: [{ messageId: 'missingDefault', data: { name: 'notice' } }],
185
- },
186
- {
187
- name: 'nested collection option missing default',
188
- filename: '/tmp/TestNode.node.ts',
189
- code: createNodeCode(`
190
- {
191
- displayName: 'Additional Fields',
192
- name: 'additionalFields',
193
- type: 'collection',
194
- default: {},
195
- options: [
196
- {
197
- displayName: 'Limit',
198
- name: 'limit',
199
- type: 'number',
200
- },
201
- ],
202
- },
203
- `),
204
- errors: [{ messageId: 'missingDefault', data: { name: 'limit' } }],
205
- },
206
- {
207
- name: 'multiple parameters missing defaults',
208
- filename: '/tmp/TestNode.node.ts',
209
- code: createNodeCode(`
210
- {
211
- displayName: 'First',
212
- name: 'first',
213
- type: 'string',
214
- },
215
- {
216
- displayName: 'Second',
217
- name: 'second',
218
- type: 'boolean',
219
- },
220
- `),
221
- errors: [
222
- { messageId: 'missingDefault', data: { name: 'first' } },
223
- { messageId: 'missingDefault', data: { name: 'second' } },
224
- ],
225
- },
226
- ],
227
- });
@@ -1,89 +0,0 @@
1
- /**
2
- * Requires every node parameter to declare a `default` property.
3
- *
4
- * A parameter is detected structurally: an object literal inside a node's
5
- * `description` with `displayName`, `name`, and `type` all set to string
6
- * literals — the shape every `INodeProperties` entry has. This avoids
7
- * hardcoding the `NodePropertyTypes` union (which would silently go stale as
8
- * new types are added) and naturally excludes `options`-array entries, which
9
- * carry `name`/`value` but no `displayName`/`type`.
10
- *
11
- * Without a `default`, n8n cannot reliably initialise the parameter's value,
12
- * which leads to inconsistent runtime behaviour in the editor and on execution.
13
- */
14
-
15
- import { simpleTraverse } from '@typescript-eslint/typescript-estree';
16
- import type { TSESTree } from '@typescript-eslint/utils';
17
- import { AST_NODE_TYPES } from '@typescript-eslint/utils';
18
-
19
- import {
20
- createRule,
21
- findClassProperty,
22
- findObjectProperty,
23
- getStringLiteralValue,
24
- isFileType,
25
- isNodeTypeClass,
26
- } from '../utils/index.js';
27
-
28
- /** Property keys an `INodeProperties` parameter always carries as string literals. */
29
- const REQUIRED_PARAM_KEYS = ['displayName', 'name', 'type'] as const;
30
-
31
- /** Returns true when the object literal has the shape of a node parameter. */
32
- function isNodeParameter(node: TSESTree.ObjectExpression): boolean {
33
- return REQUIRED_PARAM_KEYS.every((key) => {
34
- const property = findObjectProperty(node, key);
35
- return property !== null && getStringLiteralValue(property.value) !== null;
36
- });
37
- }
38
-
39
- export const RequireParamDefaultRule = createRule({
40
- name: 'require-param-default',
41
- meta: {
42
- type: 'problem',
43
- docs: {
44
- description: 'Require every node parameter to declare a default value.',
45
- },
46
- messages: {
47
- missingDefault:
48
- "Node parameter '{{ name }}' is missing a `default` value. Add a `default` property so the parameter initialises consistently.",
49
- },
50
- schema: [],
51
- },
52
- defaultOptions: [],
53
- create(context) {
54
- if (!isFileType(context.filename, '.node.ts')) {
55
- return {};
56
- }
57
-
58
- const reportIfMissingDefault = (node: TSESTree.ObjectExpression): void => {
59
- if (!isNodeParameter(node) || findObjectProperty(node, 'default') !== null) {
60
- return;
61
- }
62
- const nameProperty = findObjectProperty(node, 'name');
63
- context.report({
64
- node,
65
- messageId: 'missingDefault',
66
- data: { name: getStringLiteralValue(nameProperty?.value ?? null) ?? '' },
67
- });
68
- };
69
-
70
- return {
71
- // Scope to an INodeType class's `description`, then walk only that
72
- // subtree, so helper classes and object literals elsewhere in the file
73
- // (e.g. in method bodies) that share the parameter shape are ignored.
74
- ClassDeclaration(node) {
75
- if (!isNodeTypeClass(node)) return;
76
- const description = findClassProperty(node, 'description');
77
- if (description?.value?.type !== AST_NODE_TYPES.ObjectExpression) return;
78
-
79
- simpleTraverse(description.value, {
80
- enter(child) {
81
- if (child.type === AST_NODE_TYPES.ObjectExpression) {
82
- reportIfMissingDefault(child);
83
- }
84
- },
85
- });
86
- },
87
- };
88
- },
89
- });