eslint-plugin-perfectionist 3.7.0 → 3.9.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 (67) hide show
  1. package/dist/index.d.ts +91 -31
  2. package/dist/index.js +7 -4
  3. package/dist/index.mjs +7 -4
  4. package/dist/rules/sort-array-includes.js +17 -3
  5. package/dist/rules/sort-array-includes.mjs +17 -3
  6. package/dist/rules/sort-astro-attributes.js +18 -1
  7. package/dist/rules/sort-astro-attributes.mjs +19 -3
  8. package/dist/rules/sort-classes-utils.js +62 -8
  9. package/dist/rules/sort-classes-utils.mjs +56 -8
  10. package/dist/rules/sort-classes.js +52 -63
  11. package/dist/rules/sort-classes.mjs +48 -60
  12. package/dist/rules/sort-classes.types.js +4 -0
  13. package/dist/rules/sort-classes.types.mjs +4 -0
  14. package/dist/rules/sort-enums.js +24 -3
  15. package/dist/rules/sort-enums.mjs +18 -3
  16. package/dist/rules/sort-exports.js +23 -3
  17. package/dist/rules/sort-exports.mjs +17 -3
  18. package/dist/rules/sort-imports.js +234 -238
  19. package/dist/rules/sort-imports.mjs +219 -227
  20. package/dist/rules/sort-interfaces.js +37 -10
  21. package/dist/rules/sort-interfaces.mjs +32 -12
  22. package/dist/rules/sort-intersection-types.js +24 -4
  23. package/dist/rules/sort-intersection-types.mjs +18 -4
  24. package/dist/rules/sort-jsx-props.js +18 -3
  25. package/dist/rules/sort-jsx-props.mjs +19 -5
  26. package/dist/rules/sort-maps.js +17 -3
  27. package/dist/rules/sort-maps.mjs +17 -3
  28. package/dist/rules/sort-named-exports.js +23 -3
  29. package/dist/rules/sort-named-exports.mjs +17 -3
  30. package/dist/rules/sort-named-imports.js +22 -3
  31. package/dist/rules/sort-named-imports.mjs +16 -3
  32. package/dist/rules/sort-object-types.js +37 -8
  33. package/dist/rules/sort-object-types.mjs +31 -10
  34. package/dist/rules/sort-objects.js +35 -16
  35. package/dist/rules/sort-objects.mjs +33 -15
  36. package/dist/rules/sort-sets.js +2 -0
  37. package/dist/rules/sort-sets.mjs +2 -0
  38. package/dist/rules/sort-svelte-attributes.js +21 -6
  39. package/dist/rules/sort-svelte-attributes.mjs +22 -8
  40. package/dist/rules/sort-switch-case.js +10 -1
  41. package/dist/rules/sort-switch-case.mjs +10 -1
  42. package/dist/rules/sort-union-types.js +24 -4
  43. package/dist/rules/sort-union-types.mjs +18 -4
  44. package/dist/rules/sort-variable-declarations.js +23 -3
  45. package/dist/rules/sort-variable-declarations.mjs +17 -3
  46. package/dist/rules/sort-vue-attributes.js +18 -1
  47. package/dist/rules/sort-vue-attributes.mjs +19 -3
  48. package/dist/utils/compare.js +26 -6
  49. package/dist/utils/compare.mjs +26 -6
  50. package/dist/utils/get-node-range.js +11 -3
  51. package/dist/utils/get-node-range.mjs +13 -3
  52. package/dist/utils/get-options-with-clean-groups.js +13 -0
  53. package/dist/utils/get-options-with-clean-groups.mjs +11 -0
  54. package/dist/utils/get-settings.js +9 -10
  55. package/dist/utils/get-settings.mjs +9 -10
  56. package/dist/utils/is-partition-comment.js +8 -10
  57. package/dist/utils/is-partition-comment.mjs +8 -10
  58. package/dist/utils/matches.js +15 -0
  59. package/dist/utils/matches.mjs +13 -0
  60. package/dist/utils/sort-nodes-by-groups.js +33 -7
  61. package/dist/utils/sort-nodes-by-groups.mjs +33 -7
  62. package/dist/utils/use-groups.js +4 -8
  63. package/dist/utils/use-groups.mjs +4 -13
  64. package/dist/utils/validate-groups-configuration.js +11 -0
  65. package/dist/utils/validate-groups-configuration.mjs +11 -1
  66. package/{license → license.md} +1 -1
  67. package/package.json +3 -3
@@ -37,11 +37,22 @@ const sortEnums = createEslintRule({
37
37
  type: 'string',
38
38
  enum: ['asc', 'desc'],
39
39
  },
40
+ matcher: {
41
+ description: 'Specifies the string matcher.',
42
+ type: 'string',
43
+ enum: ['minimatch', 'regex'],
44
+ },
40
45
  ignoreCase: {
41
46
  description:
42
47
  'Controls whether sorting should be case-sensitive or not.',
43
48
  type: 'boolean',
44
49
  },
50
+ specialCharacters: {
51
+ description:
52
+ 'Controls how special characters should be handled before sorting.',
53
+ type: 'string',
54
+ enum: ['remove', 'trim', 'keep'],
55
+ },
45
56
  sortByValue: {
46
57
  description: 'Compare enum values instead of names.',
47
58
  type: 'boolean',
@@ -89,6 +100,8 @@ const sortEnums = createEslintRule({
89
100
  type: 'alphabetical',
90
101
  order: 'asc',
91
102
  ignoreCase: true,
103
+ specialCharacters: 'keep',
104
+ matcher: 'minimatch',
92
105
  sortByValue: false,
93
106
  partitionByComment: false,
94
107
  partitionByNewLine: false,
@@ -117,7 +130,9 @@ const sortEnums = createEslintRule({
117
130
  partitionByComment: false,
118
131
  partitionByNewLine: false,
119
132
  type: 'alphabetical',
133
+ matcher: 'minimatch',
120
134
  ignoreCase: true,
135
+ specialCharacters: 'keep',
121
136
  order: 'asc',
122
137
  sortByValue: false,
123
138
  forceNumericSort: false,
@@ -176,6 +191,7 @@ const sortEnums = createEslintRule({
176
191
  hasPartitionComment(
177
192
  partitionComment,
178
193
  getCommentsBefore(member, sourceCode),
194
+ options.matcher,
179
195
  )) ||
180
196
  (options.partitionByNewLine &&
181
197
  lastSortingNode &&
@@ -203,6 +219,7 @@ const sortEnums = createEslintRule({
203
219
  : options.type,
204
220
  order: options.order,
205
221
  ignoreCase: options.ignoreCase,
222
+ specialCharacters: options.specialCharacters,
206
223
  // Get the enum value rather than the name if needed
207
224
  nodeValueGetter:
208
225
  options.sortByValue || (isNumericEnum && options.forceNumericSort)
@@ -250,9 +267,7 @@ const sortEnums = createEslintRule({
250
267
  },
251
268
  node: right.node,
252
269
  fix: fixer =>
253
- makeFixes(fixer, nodes, sortedNodes, sourceCode, {
254
- partitionComment,
255
- }),
270
+ makeFixes(fixer, nodes, sortedNodes, sourceCode, options),
256
271
  })
257
272
  }
258
273
  })
@@ -33,11 +33,22 @@ const sortExports = createEslintRule.createEslintRule({
33
33
  type: 'string',
34
34
  enum: ['asc', 'desc'],
35
35
  },
36
+ matcher: {
37
+ description: 'Specifies the string matcher.',
38
+ type: 'string',
39
+ enum: ['minimatch', 'regex'],
40
+ },
36
41
  ignoreCase: {
37
42
  description:
38
43
  'Controls whether sorting should be case-sensitive or not.',
39
44
  type: 'boolean',
40
45
  },
46
+ specialCharacters: {
47
+ description:
48
+ 'Controls how special characters should be handled before sorting.',
49
+ type: 'string',
50
+ enum: ['remove', 'trim', 'keep'],
51
+ },
41
52
  partitionByComment: {
42
53
  description:
43
54
  'Allows you to use comments to separate the exports into logical groups.',
@@ -79,6 +90,8 @@ const sortExports = createEslintRule.createEslintRule({
79
90
  type: 'alphabetical',
80
91
  order: 'asc',
81
92
  ignoreCase: true,
93
+ specialCharacters: 'keep',
94
+ matcher: 'minimatch',
82
95
  partitionByComment: false,
83
96
  partitionByNewLine: false,
84
97
  groupKind: 'mixed',
@@ -89,7 +102,9 @@ const sortExports = createEslintRule.createEslintRule({
89
102
  let options = complete.complete(context.options.at(0), settings, {
90
103
  type: 'alphabetical',
91
104
  ignoreCase: true,
105
+ specialCharacters: 'keep',
92
106
  order: 'asc',
107
+ matcher: 'minimatch',
93
108
  partitionByComment: false,
94
109
  partitionByNewLine: false,
95
110
  groupKind: 'mixed',
@@ -110,6 +125,7 @@ const sortExports = createEslintRule.createEslintRule({
110
125
  isPartitionComment.hasPartitionComment(
111
126
  partitionComment,
112
127
  getCommentsBefore.getCommentsBefore(node, sourceCode),
128
+ options.matcher,
113
129
  )) ||
114
130
  (options.partitionByNewLine &&
115
131
  lastNode &&
@@ -166,9 +182,13 @@ const sortExports = createEslintRule.createEslintRule({
166
182
  },
167
183
  node: right.node,
168
184
  fix: fixer =>
169
- makeFixes.makeFixes(fixer, nodes, sortedNodes, sourceCode, {
170
- partitionComment,
171
- }),
185
+ makeFixes.makeFixes(
186
+ fixer,
187
+ nodes,
188
+ sortedNodes,
189
+ sourceCode,
190
+ options,
191
+ ),
172
192
  })
173
193
  }
174
194
  })
@@ -32,11 +32,22 @@ const sortExports = createEslintRule({
32
32
  type: 'string',
33
33
  enum: ['asc', 'desc'],
34
34
  },
35
+ matcher: {
36
+ description: 'Specifies the string matcher.',
37
+ type: 'string',
38
+ enum: ['minimatch', 'regex'],
39
+ },
35
40
  ignoreCase: {
36
41
  description:
37
42
  'Controls whether sorting should be case-sensitive or not.',
38
43
  type: 'boolean',
39
44
  },
45
+ specialCharacters: {
46
+ description:
47
+ 'Controls how special characters should be handled before sorting.',
48
+ type: 'string',
49
+ enum: ['remove', 'trim', 'keep'],
50
+ },
40
51
  partitionByComment: {
41
52
  description:
42
53
  'Allows you to use comments to separate the exports into logical groups.',
@@ -78,6 +89,8 @@ const sortExports = createEslintRule({
78
89
  type: 'alphabetical',
79
90
  order: 'asc',
80
91
  ignoreCase: true,
92
+ specialCharacters: 'keep',
93
+ matcher: 'minimatch',
81
94
  partitionByComment: false,
82
95
  partitionByNewLine: false,
83
96
  groupKind: 'mixed',
@@ -88,7 +101,9 @@ const sortExports = createEslintRule({
88
101
  let options = complete(context.options.at(0), settings, {
89
102
  type: 'alphabetical',
90
103
  ignoreCase: true,
104
+ specialCharacters: 'keep',
91
105
  order: 'asc',
106
+ matcher: 'minimatch',
92
107
  partitionByComment: false,
93
108
  partitionByNewLine: false,
94
109
  groupKind: 'mixed',
@@ -109,6 +124,7 @@ const sortExports = createEslintRule({
109
124
  hasPartitionComment(
110
125
  partitionComment,
111
126
  getCommentsBefore(node, sourceCode),
127
+ options.matcher,
112
128
  )) ||
113
129
  (options.partitionByNewLine &&
114
130
  lastNode &&
@@ -162,9 +178,7 @@ const sortExports = createEslintRule({
162
178
  },
163
179
  node: right.node,
164
180
  fix: fixer =>
165
- makeFixes(fixer, nodes, sortedNodes, sourceCode, {
166
- partitionComment,
167
- }),
181
+ makeFixes(fixer, nodes, sortedNodes, sourceCode, options),
168
182
  })
169
183
  }
170
184
  })