eslint-plugin-perfectionist 5.7.0 → 5.8.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.
- package/dist/index.js +7 -2
- package/dist/package.json.js +1 -1
- package/dist/rules/sort-array-includes.d.ts +1 -1
- package/dist/rules/sort-array-includes.js +3 -2
- package/dist/rules/{sort-array-includes → sort-arrays}/sort-array.d.ts +2 -0
- package/dist/rules/{sort-array-includes → sort-arrays}/sort-array.js +4 -0
- package/dist/rules/sort-arrays.d.ts +21 -0
- package/dist/rules/sort-arrays.js +108 -0
- package/dist/rules/sort-classes/node-info/common-modifiers.d.ts +3 -3
- package/dist/rules/sort-classes/node-info/common-modifiers.js +23 -16
- package/dist/rules/sort-modules.js +24 -0
- package/dist/rules/sort-sets.d.ts +1 -1
- package/dist/rules/sort-sets.js +2 -1
- package/dist/types/scoped-regex-option.d.ts +1 -3
- package/dist/utils/assert-is-never.d.ts +7 -0
- package/dist/utils/assert-is-never.js +2 -0
- package/package.json +2 -2
- package/readme.md +33 -31
- /package/dist/rules/{sort-array-includes → sort-arrays}/compute-array-elements.d.ts +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/compute-array-elements.js +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/compute-matched-context-options.d.ts +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/compute-matched-context-options.js +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/compute-node-name.d.ts +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/compute-node-name.js +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/types.d.ts +0 -0
- /package/dist/rules/{sort-array-includes → sort-arrays}/types.js +0 -0
package/dist/index.js
CHANGED
|
@@ -18,11 +18,12 @@ import sortImports from './rules/sort-imports.js'
|
|
|
18
18
|
import sortExports from './rules/sort-exports.js'
|
|
19
19
|
import sortObjects from './rules/sort-objects.js'
|
|
20
20
|
import sortModules from './rules/sort-modules.js'
|
|
21
|
+
import sortArrays from './rules/sort-arrays.js'
|
|
21
22
|
import sortEnums from './rules/sort-enums.js'
|
|
22
23
|
import sortMaps from './rules/sort-maps.js'
|
|
23
24
|
import sortSets from './rules/sort-sets.js'
|
|
24
25
|
let pluginName = 'perfectionist'
|
|
25
|
-
let
|
|
26
|
+
let recommendedRules = {
|
|
26
27
|
'sort-variable-declarations': sortVariableDeclarations,
|
|
27
28
|
'sort-intersection-types': sortIntersectionTypes,
|
|
28
29
|
'sort-import-attributes': sortImportAttributes,
|
|
@@ -46,6 +47,10 @@ let rules = {
|
|
|
46
47
|
'sort-sets': sortSets,
|
|
47
48
|
'sort-maps': sortMaps,
|
|
48
49
|
}
|
|
50
|
+
let rules = {
|
|
51
|
+
...recommendedRules,
|
|
52
|
+
'sort-arrays': sortArrays,
|
|
53
|
+
}
|
|
49
54
|
let plugin = {
|
|
50
55
|
meta: {
|
|
51
56
|
version,
|
|
@@ -55,7 +60,7 @@ let plugin = {
|
|
|
55
60
|
}
|
|
56
61
|
function getRules(options) {
|
|
57
62
|
return Object.fromEntries(
|
|
58
|
-
Object.keys(
|
|
63
|
+
Object.keys(recommendedRules).map(ruleName => [
|
|
59
64
|
`${pluginName}/${ruleName}`,
|
|
60
65
|
['error', options],
|
|
61
66
|
]),
|
package/dist/package.json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONSchema4 } from '@typescript-eslint/utils/json-schema'
|
|
2
|
-
import { Options } from './sort-
|
|
2
|
+
import { Options } from './sort-arrays/types.js'
|
|
3
3
|
declare const ORDER_ERROR_ID = 'unexpectedArrayIncludesOrder'
|
|
4
4
|
declare const GROUP_ORDER_ERROR_ID = 'unexpectedArrayIncludesGroupOrder'
|
|
5
5
|
declare const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArrayIncludesMembers'
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
MISSED_SPACING_ERROR,
|
|
16
16
|
} from '../utils/report-errors.js'
|
|
17
17
|
import { buildCommonGroupsJsonSchemas } from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
18
|
-
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-
|
|
18
|
+
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
19
19
|
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
20
20
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
21
|
-
import { sortArray } from './sort-
|
|
21
|
+
import { sortArray } from './sort-arrays/sort-array.js'
|
|
22
22
|
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
23
23
|
const ORDER_ERROR_ID = 'unexpectedArrayIncludesOrder'
|
|
24
24
|
const GROUP_ORDER_ERROR_ID = 'unexpectedArrayIncludesGroupOrder'
|
|
@@ -99,6 +99,7 @@ function sortPotentiallyValidArray({ matchedAstSelectors, context, node }) {
|
|
|
99
99
|
unexpectedGroupOrder: GROUP_ORDER_ERROR_ID,
|
|
100
100
|
unexpectedOrder: ORDER_ERROR_ID,
|
|
101
101
|
},
|
|
102
|
+
mustHaveMatchedContextOptions: false,
|
|
102
103
|
cachedGroupsByModifiersAndSelectors,
|
|
103
104
|
matchedAstSelectors,
|
|
104
105
|
defaultOptions,
|
|
@@ -3,6 +3,7 @@ import { TSESTree } from '@typescript-eslint/types'
|
|
|
3
3
|
import { Options } from './types.js'
|
|
4
4
|
export declare function sortArray<MessageIds extends string>({
|
|
5
5
|
cachedGroupsByModifiersAndSelectors,
|
|
6
|
+
mustHaveMatchedContextOptions,
|
|
6
7
|
availableMessageIds,
|
|
7
8
|
matchedAstSelectors,
|
|
8
9
|
defaultOptions,
|
|
@@ -20,4 +21,5 @@ export declare function sortArray<MessageIds extends string>({
|
|
|
20
21
|
context: Readonly<RuleContext<MessageIds, Options>>
|
|
21
22
|
defaultOptions: Required<Options[number]>
|
|
22
23
|
matchedAstSelectors: ReadonlySet<string>
|
|
24
|
+
mustHaveMatchedContextOptions: boolean
|
|
23
25
|
}): void
|
|
@@ -22,6 +22,7 @@ import { complete } from '../../utils/complete.js'
|
|
|
22
22
|
import { allSelectors } from './types.js'
|
|
23
23
|
function sortArray({
|
|
24
24
|
cachedGroupsByModifiersAndSelectors,
|
|
25
|
+
mustHaveMatchedContextOptions,
|
|
25
26
|
availableMessageIds,
|
|
26
27
|
matchedAstSelectors,
|
|
27
28
|
defaultOptions,
|
|
@@ -42,6 +43,9 @@ function sortArray({
|
|
|
42
43
|
elements,
|
|
43
44
|
context,
|
|
44
45
|
})
|
|
46
|
+
if (mustHaveMatchedContextOptions && !matchedContextOptions) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
45
49
|
let options = complete(matchedContextOptions, settings, defaultOptions)
|
|
46
50
|
validateCustomSortConfiguration(options)
|
|
47
51
|
validateGroupsConfiguration({
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Options } from './sort-arrays/types.js'
|
|
2
|
+
declare const ORDER_ERROR_ID = 'unexpectedArraysOrder'
|
|
3
|
+
declare const GROUP_ORDER_ERROR_ID = 'unexpectedArraysGroupOrder'
|
|
4
|
+
declare const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArraysMembers'
|
|
5
|
+
declare const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenArraysMembers'
|
|
6
|
+
type MessageId =
|
|
7
|
+
| typeof MISSED_SPACING_ERROR_ID
|
|
8
|
+
| typeof EXTRA_SPACING_ERROR_ID
|
|
9
|
+
| typeof GROUP_ORDER_ERROR_ID
|
|
10
|
+
| typeof ORDER_ERROR_ID
|
|
11
|
+
declare const _default: import('@typescript-eslint/utils/ts-eslint').RuleModule<
|
|
12
|
+
MessageId,
|
|
13
|
+
Options,
|
|
14
|
+
{
|
|
15
|
+
recommended?: boolean
|
|
16
|
+
},
|
|
17
|
+
import('@typescript-eslint/utils/ts-eslint').RuleListener
|
|
18
|
+
> & {
|
|
19
|
+
name: string
|
|
20
|
+
}
|
|
21
|
+
export default _default
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
2
|
+
import {
|
|
3
|
+
buildUseConfigurationIfJsonSchema,
|
|
4
|
+
matchesAstSelectorJsonSchema,
|
|
5
|
+
buildCommonJsonSchemas,
|
|
6
|
+
} from '../utils/json-schemas/common-json-schemas.js'
|
|
7
|
+
import {
|
|
8
|
+
partitionByNewLineJsonSchema,
|
|
9
|
+
partitionByCommentJsonSchema,
|
|
10
|
+
} from '../utils/json-schemas/common-partition-json-schemas.js'
|
|
11
|
+
import {
|
|
12
|
+
ORDER_ERROR,
|
|
13
|
+
GROUP_ORDER_ERROR,
|
|
14
|
+
EXTRA_SPACING_ERROR,
|
|
15
|
+
MISSED_SPACING_ERROR,
|
|
16
|
+
} from '../utils/report-errors.js'
|
|
17
|
+
import { buildCommonGroupsJsonSchemas } from '../utils/json-schemas/common-groups-json-schemas.js'
|
|
18
|
+
import { additionalCustomGroupMatchOptionsJsonSchema } from './sort-arrays/types.js'
|
|
19
|
+
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
20
|
+
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
21
|
+
import { sortArray } from './sort-arrays/sort-array.js'
|
|
22
|
+
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
23
|
+
const ORDER_ERROR_ID = 'unexpectedArraysOrder'
|
|
24
|
+
const GROUP_ORDER_ERROR_ID = 'unexpectedArraysGroupOrder'
|
|
25
|
+
const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenArraysMembers'
|
|
26
|
+
const MISSED_SPACING_ERROR_ID = 'missedSpacingBetweenArraysMembers'
|
|
27
|
+
let defaultOptions = {
|
|
28
|
+
fallbackSort: { type: 'unsorted' },
|
|
29
|
+
newlinesInside: 'newlinesBetween',
|
|
30
|
+
specialCharacters: 'keep',
|
|
31
|
+
partitionByComment: false,
|
|
32
|
+
partitionByNewLine: false,
|
|
33
|
+
newlinesBetween: 'ignore',
|
|
34
|
+
useConfigurationIf: {},
|
|
35
|
+
type: 'alphabetical',
|
|
36
|
+
groups: ['literal'],
|
|
37
|
+
ignoreCase: true,
|
|
38
|
+
locales: 'en-US',
|
|
39
|
+
customGroups: [],
|
|
40
|
+
alphabet: '',
|
|
41
|
+
order: 'asc',
|
|
42
|
+
}
|
|
43
|
+
let jsonSchema = {
|
|
44
|
+
items: {
|
|
45
|
+
properties: {
|
|
46
|
+
...buildCommonJsonSchemas(),
|
|
47
|
+
...buildCommonGroupsJsonSchemas({
|
|
48
|
+
additionalCustomGroupMatchProperties:
|
|
49
|
+
additionalCustomGroupMatchOptionsJsonSchema,
|
|
50
|
+
}),
|
|
51
|
+
useConfigurationIf: buildUseConfigurationIfJsonSchema({
|
|
52
|
+
additionalProperties: {
|
|
53
|
+
matchesAstSelector: matchesAstSelectorJsonSchema,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
partitionByComment: partitionByCommentJsonSchema,
|
|
57
|
+
partitionByNewLine: partitionByNewLineJsonSchema,
|
|
58
|
+
},
|
|
59
|
+
required: ['useConfigurationIf'],
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
type: 'object',
|
|
62
|
+
},
|
|
63
|
+
uniqueItems: true,
|
|
64
|
+
type: 'array',
|
|
65
|
+
}
|
|
66
|
+
const sortArrays = createEslintRule({
|
|
67
|
+
meta: {
|
|
68
|
+
messages: {
|
|
69
|
+
[MISSED_SPACING_ERROR_ID]: MISSED_SPACING_ERROR,
|
|
70
|
+
[EXTRA_SPACING_ERROR_ID]: EXTRA_SPACING_ERROR,
|
|
71
|
+
[GROUP_ORDER_ERROR_ID]: GROUP_ORDER_ERROR,
|
|
72
|
+
[ORDER_ERROR_ID]: ORDER_ERROR,
|
|
73
|
+
},
|
|
74
|
+
docs: {
|
|
75
|
+
url: 'https://perfectionist.dev/rules/sort-arrays',
|
|
76
|
+
description: 'Enforce sorted arrays.',
|
|
77
|
+
recommended: false,
|
|
78
|
+
},
|
|
79
|
+
schema: jsonSchema,
|
|
80
|
+
type: 'suggestion',
|
|
81
|
+
fixable: 'code',
|
|
82
|
+
},
|
|
83
|
+
create: context =>
|
|
84
|
+
buildAstListeners({
|
|
85
|
+
nodeTypes: [AST_NODE_TYPES.NewExpression, AST_NODE_TYPES.ArrayExpression],
|
|
86
|
+
context,
|
|
87
|
+
sorter,
|
|
88
|
+
}),
|
|
89
|
+
defaultOptions: [defaultOptions],
|
|
90
|
+
name: 'sort-arrays',
|
|
91
|
+
})
|
|
92
|
+
function sorter({ matchedAstSelectors, context, node }) {
|
|
93
|
+
sortArray({
|
|
94
|
+
availableMessageIds: {
|
|
95
|
+
missedSpacingBetweenMembers: MISSED_SPACING_ERROR_ID,
|
|
96
|
+
extraSpacingBetweenMembers: EXTRA_SPACING_ERROR_ID,
|
|
97
|
+
unexpectedGroupOrder: GROUP_ORDER_ERROR_ID,
|
|
98
|
+
unexpectedOrder: ORDER_ERROR_ID,
|
|
99
|
+
},
|
|
100
|
+
cachedGroupsByModifiersAndSelectors,
|
|
101
|
+
mustHaveMatchedContextOptions: true,
|
|
102
|
+
matchedAstSelectors,
|
|
103
|
+
defaultOptions,
|
|
104
|
+
context,
|
|
105
|
+
node,
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
export { sortArrays as default }
|
|
@@ -5,9 +5,6 @@ type Property =
|
|
|
5
5
|
| TSESTree.PropertyDefinition
|
|
6
6
|
type Accessor = TSESTree.TSAbstractAccessorProperty | TSESTree.AccessorProperty
|
|
7
7
|
type Method = TSESTree.TSAbstractMethodDefinition | TSESTree.MethodDefinition
|
|
8
|
-
export declare function computeAbstractModifier(
|
|
9
|
-
node: Accessor | Property | Method,
|
|
10
|
-
): Modifier[]
|
|
11
8
|
export declare function computeAccessibilityModifier({
|
|
12
9
|
hasPrivateHash,
|
|
13
10
|
node,
|
|
@@ -15,6 +12,9 @@ export declare function computeAccessibilityModifier({
|
|
|
15
12
|
node: Accessor | Property | Method
|
|
16
13
|
hasPrivateHash: boolean
|
|
17
14
|
}): Modifier[]
|
|
15
|
+
export declare function computeAbstractModifier(
|
|
16
|
+
node: Accessor | Property | Method,
|
|
17
|
+
): Modifier[]
|
|
18
18
|
export declare function computeAsyncModifier(
|
|
19
19
|
node:
|
|
20
20
|
| TSESTree.TSEmptyBodyFunctionExpression
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
|
|
2
2
|
import { UnreachableCaseError } from '../../../utils/unreachable-case-error.js'
|
|
3
|
-
|
|
4
|
-
switch (node.type) {
|
|
5
|
-
case AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
6
|
-
case AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
7
|
-
case AST_NODE_TYPES.TSAbstractAccessorProperty:
|
|
8
|
-
return ['abstract']
|
|
9
|
-
case AST_NODE_TYPES.PropertyDefinition:
|
|
10
|
-
case AST_NODE_TYPES.MethodDefinition:
|
|
11
|
-
case AST_NODE_TYPES.AccessorProperty:
|
|
12
|
-
return []
|
|
13
|
-
/* v8 ignore next 2 -- @preserve Exhaustive guard. */
|
|
14
|
-
default:
|
|
15
|
-
throw new UnreachableCaseError(node)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
3
|
+
import { assertIsNever } from '../../../utils/assert-is-never.js'
|
|
18
4
|
function computeAccessibilityModifier({ hasPrivateHash, node }) {
|
|
19
5
|
if (hasPrivateHash) {
|
|
20
6
|
return ['private']
|
|
@@ -27,9 +13,30 @@ function computeAccessibilityModifier({ hasPrivateHash, node }) {
|
|
|
27
13
|
case void 0:
|
|
28
14
|
case 'public':
|
|
29
15
|
return ['public']
|
|
16
|
+
default:
|
|
17
|
+
assertIsNever(node.accessibility)
|
|
18
|
+
return computeUnhandledAccessibilityModifier(node.accessibility)
|
|
19
|
+
}
|
|
20
|
+
function computeUnhandledAccessibilityModifier(modifier) {
|
|
21
|
+
if (modifier === null) {
|
|
22
|
+
return ['public']
|
|
23
|
+
}
|
|
24
|
+
throw new Error('Unhandled accessibility modifier')
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function computeAbstractModifier(node) {
|
|
28
|
+
switch (node.type) {
|
|
29
|
+
case AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
30
|
+
case AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
31
|
+
case AST_NODE_TYPES.TSAbstractAccessorProperty:
|
|
32
|
+
return ['abstract']
|
|
33
|
+
case AST_NODE_TYPES.PropertyDefinition:
|
|
34
|
+
case AST_NODE_TYPES.MethodDefinition:
|
|
35
|
+
case AST_NODE_TYPES.AccessorProperty:
|
|
36
|
+
return []
|
|
30
37
|
/* v8 ignore next 2 -- @preserve Exhaustive guard. */
|
|
31
38
|
default:
|
|
32
|
-
throw new UnreachableCaseError(node
|
|
39
|
+
throw new UnreachableCaseError(node)
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
42
|
function computeAsyncModifier(node) {
|
|
@@ -160,6 +160,16 @@ function analyzeModule({
|
|
|
160
160
|
let sortingNodeGroupsWithoutOverloadSignature = [[]]
|
|
161
161
|
for (let node of module.body) {
|
|
162
162
|
switch (node.type) {
|
|
163
|
+
case AST_NODE_TYPES.TSNamespaceExportDeclaration:
|
|
164
|
+
case AST_NODE_TYPES.ExportAllDeclaration:
|
|
165
|
+
case AST_NODE_TYPES.ImportDeclaration:
|
|
166
|
+
case AST_NODE_TYPES.DebuggerStatement:
|
|
167
|
+
case AST_NODE_TYPES.ContinueStatement:
|
|
168
|
+
case AST_NODE_TYPES.ReturnStatement:
|
|
169
|
+
case AST_NODE_TYPES.EmptyStatement:
|
|
170
|
+
case AST_NODE_TYPES.BreakStatement:
|
|
171
|
+
case AST_NODE_TYPES.WithStatement:
|
|
172
|
+
continue
|
|
163
173
|
case AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
164
174
|
case AST_NODE_TYPES.ExportNamedDeclaration:
|
|
165
175
|
case AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
@@ -167,14 +177,28 @@ function analyzeModule({
|
|
|
167
177
|
case AST_NODE_TYPES.FunctionDeclaration:
|
|
168
178
|
case AST_NODE_TYPES.TSModuleDeclaration:
|
|
169
179
|
break
|
|
180
|
+
case AST_NODE_TYPES.TSImportEqualsDeclaration:
|
|
170
181
|
case AST_NODE_TYPES.VariableDeclaration:
|
|
171
182
|
case AST_NODE_TYPES.ExpressionStatement:
|
|
183
|
+
case AST_NODE_TYPES.TSExportAssignment:
|
|
184
|
+
case AST_NODE_TYPES.DoWhileStatement:
|
|
185
|
+
case AST_NODE_TYPES.LabeledStatement:
|
|
186
|
+
case AST_NODE_TYPES.SwitchStatement:
|
|
187
|
+
case AST_NODE_TYPES.WhileStatement:
|
|
188
|
+
case AST_NODE_TYPES.ForInStatement:
|
|
189
|
+
case AST_NODE_TYPES.ForOfStatement:
|
|
190
|
+
case AST_NODE_TYPES.ThrowStatement:
|
|
191
|
+
case AST_NODE_TYPES.BlockStatement:
|
|
192
|
+
case AST_NODE_TYPES.ForStatement:
|
|
193
|
+
case AST_NODE_TYPES.TryStatement:
|
|
194
|
+
case AST_NODE_TYPES.IfStatement:
|
|
172
195
|
sortingNodeGroupsWithoutOverloadSignature.push([])
|
|
173
196
|
continue
|
|
174
197
|
case AST_NODE_TYPES.TSDeclareFunction:
|
|
175
198
|
case AST_NODE_TYPES.TSEnumDeclaration:
|
|
176
199
|
case AST_NODE_TYPES.ClassDeclaration:
|
|
177
200
|
break
|
|
201
|
+
/* v8 ignore next 2 -- @preserve Exhaustive guard. */
|
|
178
202
|
default:
|
|
179
203
|
continue
|
|
180
204
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options } from './sort-
|
|
1
|
+
import { Options } from './sort-arrays/types.js'
|
|
2
2
|
declare const ORDER_ERROR_ID = 'unexpectedSetsOrder'
|
|
3
3
|
declare const GROUP_ORDER_ERROR_ID = 'unexpectedSetsGroupOrder'
|
|
4
4
|
declare const EXTRA_SPACING_ERROR_ID = 'extraSpacingBetweenSetsMembers'
|
package/dist/rules/sort-sets.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { defaultOptions, jsonSchema } from './sort-array-includes.js'
|
|
9
9
|
import { buildAstListeners } from '../utils/build-ast-listeners.js'
|
|
10
10
|
import { createEslintRule } from '../utils/create-eslint-rule.js'
|
|
11
|
-
import { sortArray } from './sort-
|
|
11
|
+
import { sortArray } from './sort-arrays/sort-array.js'
|
|
12
12
|
let cachedGroupsByModifiersAndSelectors = /* @__PURE__ */ new Map()
|
|
13
13
|
const ORDER_ERROR_ID = 'unexpectedSetsOrder'
|
|
14
14
|
const GROUP_ORDER_ERROR_ID = 'unexpectedSetsGroupOrder'
|
|
@@ -51,6 +51,7 @@ function sortPotentiallyValidArray({ matchedAstSelectors, context, node }) {
|
|
|
51
51
|
unexpectedGroupOrder: GROUP_ORDER_ERROR_ID,
|
|
52
52
|
unexpectedOrder: ORDER_ERROR_ID,
|
|
53
53
|
},
|
|
54
|
+
mustHaveMatchedContextOptions: false,
|
|
54
55
|
cachedGroupsByModifiersAndSelectors,
|
|
55
56
|
matchedAstSelectors,
|
|
56
57
|
defaultOptions,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { RegexOption } from './common-options.js'
|
|
2
|
-
export type ScopedRegexOption = RegexOption<{
|
|
3
|
-
scope?: Scope
|
|
4
|
-
}>
|
|
5
2
|
export type Scope = (typeof regexScopes)[number]
|
|
3
|
+
export type ScopedRegexOption = RegexOption
|
|
6
4
|
export declare let regexScopes: readonly ['shallow', 'deep']
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert that the given member is of type `never`. This is useful for
|
|
3
|
+
* exhaustive checks in switch statements or conditional logic.
|
|
4
|
+
*
|
|
5
|
+
* @param _member - The member to check, which should be of type `never`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function assertIsNever(_member: never): void
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-perfectionist",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"./dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@typescript-eslint/utils": "^8.
|
|
32
|
+
"@typescript-eslint/utils": "^8.58.0",
|
|
33
33
|
"natural-orderby": "^5.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
package/readme.md
CHANGED
|
@@ -173,12 +173,12 @@ module.exports = {
|
|
|
173
173
|
|
|
174
174
|
### List of Configs
|
|
175
175
|
|
|
176
|
-
| Name | Description
|
|
177
|
-
| :------------------------------------------------------------------------------------- |
|
|
178
|
-
| [recommended-alphabetical](https://perfectionist.dev/configs/recommended-alphabetical) | All plugin rules with alphabetical sorting in ascending order |
|
|
179
|
-
| [recommended-natural](https://perfectionist.dev/configs/recommended-natural) | All plugin rules with natural sorting in ascending order |
|
|
180
|
-
| [recommended-line-length](https://perfectionist.dev/configs/recommended-line-length) | All plugin rules with sorting by line length in descending order |
|
|
181
|
-
| [recommended-custom](https://perfectionist.dev/configs/recommended-custom) | All plugin rules with sorting by your own custom order |
|
|
176
|
+
| Name | Description |
|
|
177
|
+
| :------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- |
|
|
178
|
+
| [recommended-alphabetical](https://perfectionist.dev/configs/recommended-alphabetical) | All recommended plugin rules with alphabetical sorting in ascending order |
|
|
179
|
+
| [recommended-natural](https://perfectionist.dev/configs/recommended-natural) | All recommended plugin rules with natural sorting in ascending order |
|
|
180
|
+
| [recommended-line-length](https://perfectionist.dev/configs/recommended-line-length) | All recommended plugin rules with sorting by line length in descending order |
|
|
181
|
+
| [recommended-custom](https://perfectionist.dev/configs/recommended-custom) | All recommended plugin rules with sorting by your own custom order |
|
|
182
182
|
|
|
183
183
|
## Rules
|
|
184
184
|
|
|
@@ -186,31 +186,33 @@ module.exports = {
|
|
|
186
186
|
|
|
187
187
|
🔧 Automatically fixable by the
|
|
188
188
|
[`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
-
| [sort-
|
|
194
|
-
| [sort-
|
|
195
|
-
| [sort-
|
|
196
|
-
| [sort-
|
|
197
|
-
| [sort-
|
|
198
|
-
| [sort-
|
|
199
|
-
| [sort-
|
|
200
|
-
| [sort-
|
|
201
|
-
| [sort-
|
|
202
|
-
| [sort-
|
|
203
|
-
| [sort-
|
|
204
|
-
| [sort-
|
|
205
|
-
| [sort-
|
|
206
|
-
| [sort-
|
|
207
|
-
| [sort-
|
|
208
|
-
| [sort-
|
|
209
|
-
| [sort-
|
|
210
|
-
| [sort-
|
|
211
|
-
| [sort-
|
|
212
|
-
| [sort-
|
|
213
|
-
| [sort-
|
|
189
|
+
✅ Included in all recommended configs.
|
|
190
|
+
|
|
191
|
+
| Name | Description | 🔧 | ✅ |
|
|
192
|
+
| :--------------------------------------------------------------------------------------- | :----------------------------------------------- | :-- | :-- |
|
|
193
|
+
| [sort-arrays](https://perfectionist.dev/rules/sort-arrays) | Enforce sorted arrays based on custom conditions | 🔧 | |
|
|
194
|
+
| [sort-array-includes](https://perfectionist.dev/rules/sort-array-includes) | Enforce sorted arrays before include method | 🔧 | ✅ |
|
|
195
|
+
| [sort-classes](https://perfectionist.dev/rules/sort-classes) | Enforce sorted classes | 🔧 | ✅ |
|
|
196
|
+
| [sort-decorators](https://perfectionist.dev/rules/sort-decorators) | Enforce sorted decorators | 🔧 | ✅ |
|
|
197
|
+
| [sort-enums](https://perfectionist.dev/rules/sort-enums) | Enforce sorted TypeScript enums | 🔧 | ✅ |
|
|
198
|
+
| [sort-export-attributes](https://perfectionist.dev/rules/sort-export-attributes) | Enforce sorted export attributes | 🔧 | ✅ |
|
|
199
|
+
| [sort-exports](https://perfectionist.dev/rules/sort-exports) | Enforce sorted exports | 🔧 | ✅ |
|
|
200
|
+
| [sort-heritage-clauses](https://perfectionist.dev/rules/sort-heritage-clauses) | Enforce sorted `implements`/`extends` clauses | 🔧 | ✅ |
|
|
201
|
+
| [sort-import-attributes](https://perfectionist.dev/rules/sort-import-attributes) | Enforce sorted import attributes | 🔧 | ✅ |
|
|
202
|
+
| [sort-imports](https://perfectionist.dev/rules/sort-imports) | Enforce sorted imports | 🔧 | ✅ |
|
|
203
|
+
| [sort-interfaces](https://perfectionist.dev/rules/sort-interfaces) | Enforce sorted interface properties | 🔧 | ✅ |
|
|
204
|
+
| [sort-intersection-types](https://perfectionist.dev/rules/sort-intersection-types) | Enforce sorted intersection types | 🔧 | ✅ |
|
|
205
|
+
| [sort-jsx-props](https://perfectionist.dev/rules/sort-jsx-props) | Enforce sorted JSX props | 🔧 | ✅ |
|
|
206
|
+
| [sort-maps](https://perfectionist.dev/rules/sort-maps) | Enforce sorted Map elements | 🔧 | ✅ |
|
|
207
|
+
| [sort-modules](https://perfectionist.dev/rules/sort-modules) | Enforce sorted modules | 🔧 | ✅ |
|
|
208
|
+
| [sort-named-exports](https://perfectionist.dev/rules/sort-named-exports) | Enforce sorted named exports | 🔧 | ✅ |
|
|
209
|
+
| [sort-named-imports](https://perfectionist.dev/rules/sort-named-imports) | Enforce sorted named imports | 🔧 | ✅ |
|
|
210
|
+
| [sort-object-types](https://perfectionist.dev/rules/sort-object-types) | Enforce sorted object types | 🔧 | ✅ |
|
|
211
|
+
| [sort-objects](https://perfectionist.dev/rules/sort-objects) | Enforce sorted objects | 🔧 | ✅ |
|
|
212
|
+
| [sort-sets](https://perfectionist.dev/rules/sort-sets) | Enforce sorted Set elements | 🔧 | ✅ |
|
|
213
|
+
| [sort-switch-case](https://perfectionist.dev/rules/sort-switch-case) | Enforce sorted switch case statements | 🔧 | ✅ |
|
|
214
|
+
| [sort-union-types](https://perfectionist.dev/rules/sort-union-types) | Enforce sorted union types | 🔧 | ✅ |
|
|
215
|
+
| [sort-variable-declarations](https://perfectionist.dev/rules/sort-variable-declarations) | Enforce sorted variable declarations | 🔧 | ✅ |
|
|
214
216
|
|
|
215
217
|
<!-- end auto-generated rules list -->
|
|
216
218
|
|
|
File without changes
|
|
File without changes
|
/package/dist/rules/{sort-array-includes → sort-arrays}/compute-matched-context-options.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|