|
| 1 | +# Enforce alphabetical ordering of options arrays in n8n node properties (`@n8n/community-nodes/options-sorted-alphabetically`) |
| 2 | + |
| 3 | +⚠️ This rule _warns_ in the following configs: ✅ `recommended`, ☑️ `recommendedWithoutN8nCloudSupport`. |
| 4 | + |
| 5 | +<!-- end auto-generated rule header --> |
| 6 | + |
| 7 | +## Rule Details |
| 8 | + |
| 9 | +Warns when an `options`-type parameter has its options array not sorted alphabetically by name. Applies to all `type: 'options'` parameters — including `resource`, `operation`, and any other dropdowns. |
| 10 | + |
| 11 | +Alphabetical ordering is an [official n8n UI design requirement](https://docs.n8n.io/integrations/creating-nodes/plan/node-ui-design/#lists) and the most frequently flagged issue in community node reviews. |
| 12 | + |
| 13 | +Comparison is case-insensitive and locale-aware (handles non-ASCII names such as Spanish or Portuguese labels). |
| 14 | + |
| 15 | +## Examples |
| 16 | + |
| 17 | +### ❌ Incorrect |
| 18 | + |
| 19 | +```typescript |
| 20 | +export class MyNode implements INodeType { |
| 21 | + description: INodeTypeDescription = { |
| 22 | + displayName: 'My Service', |
| 23 | + name: 'myService', |
| 24 | + properties: [ |
| 25 | + { |
| 26 | + displayName: 'Resource', |
| 27 | + name: 'resource', |
| 28 | + type: 'options', |
| 29 | + options: [ |
| 30 | + { name: 'User', value: 'user' }, |
| 31 | + { name: 'Contact', value: 'contact' }, // out of order |
| 32 | + { name: 'Project', value: 'project' }, |
| 33 | + ], |
| 34 | + default: 'user', |
| 35 | + }, |
| 36 | + ], |
| 37 | + }; |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +### ✅ Correct |
| 42 | + |
| 43 | +```typescript |
| 44 | +export class MyNode implements INodeType { |
| 45 | + description: INodeTypeDescription = { |
| 46 | + displayName: 'My Service', |
| 47 | + name: 'myService', |
| 48 | + properties: [ |
| 49 | + { |
| 50 | + displayName: 'Resource', |
| 51 | + name: 'resource', |
| 52 | + type: 'options', |
| 53 | + options: [ |
| 54 | + { name: 'Contact', value: 'contact' }, |
| 55 | + { name: 'Project', value: 'project' }, |
| 56 | + { name: 'User', value: 'user' }, |
| 57 | + ], |
| 58 | + default: 'contact', |
| 59 | + }, |
| 60 | + ], |
| 61 | + }; |
| 62 | +} |
| 63 | +``` |
0 commit comments