Skip to content

Commit

Permalink
chore: Remove broken autofix for `node-param-collection-type-unsorted…
Browse files Browse the repository at this point in the history
…-items`
  • Loading branch information
ivov committed Oct 6, 2024
1 parent dc11061 commit 57549e2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ In the `community` ruleset, the five `*-still-default` rules allow you to define
| [node-filename-against-convention](docs/rules/node-filename-against-convention.md) | `name` in node class description must match the node filename without the `.node.ts` suffix. Example: If `description.name` is `Test`, then filename must be `Test.node.ts`. Version suffix in filename (e.g. `-V2`) is disregarded. | No |
| [node-param-array-type-assertion](docs/rules/node-param-array-type-assertion.md) | Array of node parameters must be typed, not type-asserted. | Yes |
| [node-param-collection-type-item-required](docs/rules/node-param-collection-type-item-required.md) | Items in collection-type node parameter must not have a `required` property. | Yes |
| [node-param-collection-type-unsorted-items](docs/rules/node-param-collection-type-unsorted-items.md) | Items in collection-type node parameter must be alphabetized by `name` if five or more than five. | Yes |
| [node-param-collection-type-unsorted-items](docs/rules/node-param-collection-type-unsorted-items.md) | Items in collection-type node parameter must be alphabetized by `name` if five or more than five. | No |
| [node-param-color-type-unused](docs/rules/node-param-color-type-unused.md) | `string`-type color-related node parameter must be `color`-type. | Yes |
| [node-param-default-missing](docs/rules/node-param-default-missing.md) | `default` must be present in a node parameter, except in node parameters under `modes`. | Yes |
| [node-param-default-wrong-for-boolean](docs/rules/node-param-default-wrong-for-boolean.md) | `default` for boolean-type node parameter must be a boolean. | Yes |
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/node-param-collection-type-unsorted-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Items in collection-type node parameter must be alphabetized by `name` if five o

📋 This rule is part of the `plugin:n8n-nodes-base/nodes` config.

🔧 Run ESLint with `--fix` option to autofix the issue flagged by this rule.

## Examples

❌ Example of **incorrect** code:
Expand Down
9 changes: 1 addition & 8 deletions lib/rules/node-param-collection-type-unsorted-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ export default utils.createRule({
description: `Items in collection-type node parameter must be alphabetized by \`name\` if ${MIN_ITEMS_TO_ALPHABETIZE_SPELLED_OUT} or more than ${MIN_ITEMS_TO_ALPHABETIZE_SPELLED_OUT}.`,
recommended: "strict",
},
fixable: "code",
schema: [],
messages: {
sortItems:
"Alphabetize by 'name'. Order: {{ displayOrder }} [autofixable]",
"Alphabetize by 'name'. Order: {{ displayOrder }} [non-autofixable]",
},
},
defaultOptions: [],
Expand All @@ -45,18 +44,12 @@ export default utils.createRule({
sortedOptions
)
) {
const baseIndentation = utils.getBaseIndentationForOption(options);

const sorted = utils.formatItems(sortedOptions, baseIndentation);

const displayOrder = utils.toDisplayOrderForCollection(sortedOptions);

context.report({
messageId: "sortItems",
node: options.ast,
data: { displayOrder },
fix: (fixer) =>
fixer.replaceText(options.ast, `options: ${sorted}`),
});
}
},
Expand Down
39 changes: 0 additions & 39 deletions tests/node-param-collection-type-unsorted-items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,45 +120,6 @@ ruleTester().run(getRuleName(module), rule, {
errors: [
{ messageId: "sortItems", data: { displayOrder: "A | B | C | D | E" } },
],
output: outdent`
const test = {
displayName: 'Test',
name: 'test',
type: 'collection',
default: {},
options: [
{
displayName: 'A',
name: 'a',
type: 'boolean',
default: true,
},
{
displayName: 'B',
name: 'b',
type: 'boolean',
default: true,
},
{
displayName: 'C',
name: 'c',
type: 'boolean',
default: true,
},
{
displayName: 'D',
name: 'd',
type: 'boolean',
default: true,
},
{
displayName: 'E',
name: 'e',
type: 'boolean',
default: true,
},
],
};`,
},
],
});

0 comments on commit 57549e2

Please sign in to comment.