eslint-plugin-perfectionist 3.1.3 → 3.3.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.d.ts +13 -9
- package/dist/rules/sort-array-includes.js +3 -1
- package/dist/rules/sort-array-includes.mjs +3 -1
- package/dist/rules/sort-astro-attributes.js +3 -1
- package/dist/rules/sort-astro-attributes.mjs +3 -1
- package/dist/rules/sort-classes-utils.js +99 -0
- package/dist/rules/sort-classes-utils.mjs +96 -0
- package/dist/rules/sort-classes.js +154 -77
- package/dist/rules/sort-classes.mjs +158 -77
- package/dist/rules/sort-enums.js +93 -6
- package/dist/rules/sort-enums.mjs +89 -6
- package/dist/rules/sort-exports.js +3 -1
- package/dist/rules/sort-exports.mjs +3 -1
- package/dist/rules/sort-imports.js +3 -1
- package/dist/rules/sort-imports.mjs +3 -1
- package/dist/rules/sort-interfaces.js +3 -1
- package/dist/rules/sort-interfaces.mjs +3 -1
- package/dist/rules/sort-intersection-types.js +3 -1
- package/dist/rules/sort-intersection-types.mjs +3 -1
- package/dist/rules/sort-jsx-props.js +3 -1
- package/dist/rules/sort-jsx-props.mjs +3 -1
- package/dist/rules/sort-maps.js +3 -1
- package/dist/rules/sort-maps.mjs +3 -1
- package/dist/rules/sort-named-exports.js +3 -1
- package/dist/rules/sort-named-exports.mjs +3 -1
- package/dist/rules/sort-named-imports.js +3 -1
- package/dist/rules/sort-named-imports.mjs +3 -1
- package/dist/rules/sort-object-types.js +3 -1
- package/dist/rules/sort-object-types.mjs +3 -1
- package/dist/rules/sort-objects.js +3 -1
- package/dist/rules/sort-objects.mjs +3 -1
- package/dist/rules/sort-svelte-attributes.js +3 -1
- package/dist/rules/sort-svelte-attributes.mjs +3 -1
- package/dist/rules/sort-switch-case.js +9 -4
- package/dist/rules/sort-switch-case.mjs +9 -4
- package/dist/rules/sort-union-types.js +3 -1
- package/dist/rules/sort-union-types.mjs +3 -1
- package/dist/rules/sort-variable-declarations.js +3 -1
- package/dist/rules/sort-variable-declarations.mjs +3 -1
- package/dist/rules/sort-vue-attributes.js +2 -1
- package/dist/rules/sort-vue-attributes.mjs +2 -1
- package/dist/utils/compare.js +12 -7
- package/dist/utils/compare.mjs +12 -7
- package/dist/utils/complete.js +2 -1
- package/dist/utils/complete.mjs +2 -1
- package/dist/utils/get-settings.js +30 -0
- package/dist/utils/get-settings.mjs +28 -0
- package/dist/utils/use-groups.js +2 -1
- package/dist/utils/use-groups.mjs +2 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
2
2
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
3
3
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
4
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
4
5
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
5
6
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
6
7
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -51,7 +52,8 @@ const sortExports = createEslintRule({
|
|
|
51
52
|
},
|
|
52
53
|
],
|
|
53
54
|
create: context => {
|
|
54
|
-
let
|
|
55
|
+
let settings = getSettings(context.settings)
|
|
56
|
+
let options = complete(context.options.at(0), settings, {
|
|
55
57
|
type: 'alphabetical',
|
|
56
58
|
ignoreCase: true,
|
|
57
59
|
order: 'asc',
|
|
@@ -8,6 +8,7 @@ const getGroupNumber = require('../utils/get-group-number.js')
|
|
|
8
8
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
9
9
|
const getNodeRange = require('../utils/get-node-range.js')
|
|
10
10
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
11
|
+
const getSettings = require('../utils/get-settings.js')
|
|
11
12
|
const isPositive = require('../utils/is-positive.js')
|
|
12
13
|
const useGroups = require('../utils/use-groups.js')
|
|
13
14
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
@@ -163,7 +164,8 @@ const sortImports = createEslintRule.createEslintRule({
|
|
|
163
164
|
},
|
|
164
165
|
],
|
|
165
166
|
create: context => {
|
|
166
|
-
let
|
|
167
|
+
let settings = getSettings.getSettings(context.settings)
|
|
168
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
167
169
|
groups: [
|
|
168
170
|
'type',
|
|
169
171
|
['builtin', 'external'],
|
|
@@ -7,6 +7,7 @@ import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
|
7
7
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
8
8
|
import { getNodeRange } from '../utils/get-node-range.mjs'
|
|
9
9
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
10
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
10
11
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
11
12
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
12
13
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
@@ -162,7 +163,8 @@ const sortImports = createEslintRule({
|
|
|
162
163
|
},
|
|
163
164
|
],
|
|
164
165
|
create: context => {
|
|
165
|
-
let
|
|
166
|
+
let settings = getSettings(context.settings)
|
|
167
|
+
let options = complete(context.options.at(0), settings, {
|
|
166
168
|
groups: [
|
|
167
169
|
'type',
|
|
168
170
|
['builtin', 'external'],
|
|
@@ -7,6 +7,7 @@ const getGroupNumber = require('../utils/get-group-number.js')
|
|
|
7
7
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
8
8
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
9
9
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
10
|
+
const getSettings = require('../utils/get-settings.js')
|
|
10
11
|
const isPositive = require('../utils/is-positive.js')
|
|
11
12
|
const useGroups = require('../utils/use-groups.js')
|
|
12
13
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
@@ -118,7 +119,8 @@ const sortInterfaces = createEslintRule.createEslintRule({
|
|
|
118
119
|
create: context => ({
|
|
119
120
|
TSInterfaceDeclaration: node => {
|
|
120
121
|
if (node.body.body.length > 1) {
|
|
121
|
-
let
|
|
122
|
+
let settings = getSettings.getSettings(context.settings)
|
|
123
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
122
124
|
partitionByNewLine: false,
|
|
123
125
|
type: 'alphabetical',
|
|
124
126
|
groupKind: 'mixed',
|
|
@@ -6,6 +6,7 @@ import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
|
6
6
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
7
7
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
8
8
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
9
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
9
10
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
10
11
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
11
12
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
@@ -117,7 +118,8 @@ const sortInterfaces = createEslintRule({
|
|
|
117
118
|
create: context => ({
|
|
118
119
|
TSInterfaceDeclaration: node => {
|
|
119
120
|
if (node.body.body.length > 1) {
|
|
120
|
-
let
|
|
121
|
+
let settings = getSettings(context.settings)
|
|
122
|
+
let options = complete(context.options.at(0), settings, {
|
|
121
123
|
partitionByNewLine: false,
|
|
122
124
|
type: 'alphabetical',
|
|
123
125
|
groupKind: 'mixed',
|
|
@@ -4,6 +4,7 @@ const getGroupNumber = require('../utils/get-group-number.js')
|
|
|
4
4
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
5
5
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
6
6
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
7
|
+
const getSettings = require('../utils/get-settings.js')
|
|
7
8
|
const isPositive = require('../utils/is-positive.js')
|
|
8
9
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
9
10
|
const useGroups = require('../utils/use-groups.js')
|
|
@@ -75,7 +76,8 @@ const sortIntersectionTypes = createEslintRule.createEslintRule({
|
|
|
75
76
|
],
|
|
76
77
|
create: context => ({
|
|
77
78
|
TSIntersectionType: node => {
|
|
78
|
-
let
|
|
79
|
+
let settings = getSettings.getSettings(context.settings)
|
|
80
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
79
81
|
type: 'alphabetical',
|
|
80
82
|
ignoreCase: true,
|
|
81
83
|
order: 'asc',
|
|
@@ -3,6 +3,7 @@ import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
|
3
3
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
4
4
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
5
5
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
6
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
6
7
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
7
8
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
8
9
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
@@ -74,7 +75,8 @@ const sortIntersectionTypes = createEslintRule({
|
|
|
74
75
|
],
|
|
75
76
|
create: context => ({
|
|
76
77
|
TSIntersectionType: node => {
|
|
77
|
-
let
|
|
78
|
+
let settings = getSettings(context.settings)
|
|
79
|
+
let options = complete(context.options.at(0), settings, {
|
|
78
80
|
type: 'alphabetical',
|
|
79
81
|
ignoreCase: true,
|
|
80
82
|
order: 'asc',
|
|
@@ -4,6 +4,7 @@ const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
|
4
4
|
const getGroupNumber = require('../utils/get-group-number.js')
|
|
5
5
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
6
6
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
7
|
+
const getSettings = require('../utils/get-settings.js')
|
|
7
8
|
const isPositive = require('../utils/is-positive.js')
|
|
8
9
|
const useGroups = require('../utils/use-groups.js')
|
|
9
10
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -103,7 +104,8 @@ const sortJsxProps = createEslintRule.createEslintRule({
|
|
|
103
104
|
create: context => ({
|
|
104
105
|
JSXElement: node => {
|
|
105
106
|
if (node.openingElement.attributes.length > 1) {
|
|
106
|
-
let
|
|
107
|
+
let settings = getSettings.getSettings(context.settings)
|
|
108
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
107
109
|
type: 'alphabetical',
|
|
108
110
|
ignorePattern: [],
|
|
109
111
|
ignoreCase: true,
|
|
@@ -3,6 +3,7 @@ import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
|
3
3
|
import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
4
4
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
5
5
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
6
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
6
7
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
7
8
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
8
9
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -102,7 +103,8 @@ const sortJsxProps = createEslintRule({
|
|
|
102
103
|
create: context => ({
|
|
103
104
|
JSXElement: node => {
|
|
104
105
|
if (node.openingElement.attributes.length > 1) {
|
|
105
|
-
let
|
|
106
|
+
let settings = getSettings(context.settings)
|
|
107
|
+
let options = complete(context.options.at(0), settings, {
|
|
106
108
|
type: 'alphabetical',
|
|
107
109
|
ignorePattern: [],
|
|
108
110
|
ignoreCase: true,
|
package/dist/rules/sort-maps.js
CHANGED
|
@@ -3,6 +3,7 @@ const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
|
3
3
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
4
4
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
5
5
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
6
|
+
const getSettings = require('../utils/get-settings.js')
|
|
6
7
|
const isPositive = require('../utils/is-positive.js')
|
|
7
8
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
8
9
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -65,7 +66,8 @@ const sortMaps = createEslintRule.createEslintRule({
|
|
|
65
66
|
) {
|
|
66
67
|
let [{ elements }] = node.arguments
|
|
67
68
|
if (elements.length > 1) {
|
|
68
|
-
let
|
|
69
|
+
let settings = getSettings.getSettings(context.settings)
|
|
70
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
69
71
|
type: 'alphabetical',
|
|
70
72
|
ignoreCase: true,
|
|
71
73
|
order: 'asc',
|
package/dist/rules/sort-maps.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
|
2
2
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
3
3
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
4
4
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
5
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
5
6
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
6
7
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
7
8
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -64,7 +65,8 @@ const sortMaps = createEslintRule({
|
|
|
64
65
|
) {
|
|
65
66
|
let [{ elements }] = node.arguments
|
|
66
67
|
if (elements.length > 1) {
|
|
67
|
-
let
|
|
68
|
+
let settings = getSettings(context.settings)
|
|
69
|
+
let options = complete(context.options.at(0), settings, {
|
|
68
70
|
type: 'alphabetical',
|
|
69
71
|
ignoreCase: true,
|
|
70
72
|
order: 'asc',
|
|
@@ -3,6 +3,7 @@ const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
|
3
3
|
const getGroupNumber = require('../utils/get-group-number.js')
|
|
4
4
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
5
5
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
6
|
+
const getSettings = require('../utils/get-settings.js')
|
|
6
7
|
const isPositive = require('../utils/is-positive.js')
|
|
7
8
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
8
9
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -62,7 +63,8 @@ const sortNamedExports = createEslintRule.createEslintRule({
|
|
|
62
63
|
create: context => ({
|
|
63
64
|
ExportNamedDeclaration: node => {
|
|
64
65
|
if (node.specifiers.length > 1) {
|
|
65
|
-
let
|
|
66
|
+
let settings = getSettings.getSettings(context.settings)
|
|
67
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
66
68
|
type: 'alphabetical',
|
|
67
69
|
groupKind: 'mixed',
|
|
68
70
|
ignoreCase: true,
|
|
@@ -2,6 +2,7 @@ import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
|
2
2
|
import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
3
3
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
4
4
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
5
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
5
6
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
6
7
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
7
8
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -61,7 +62,8 @@ const sortNamedExports = createEslintRule({
|
|
|
61
62
|
create: context => ({
|
|
62
63
|
ExportNamedDeclaration: node => {
|
|
63
64
|
if (node.specifiers.length > 1) {
|
|
64
|
-
let
|
|
65
|
+
let settings = getSettings(context.settings)
|
|
66
|
+
let options = complete(context.options.at(0), settings, {
|
|
65
67
|
type: 'alphabetical',
|
|
66
68
|
groupKind: 'mixed',
|
|
67
69
|
ignoreCase: true,
|
|
@@ -3,6 +3,7 @@ const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
|
3
3
|
const getGroupNumber = require('../utils/get-group-number.js')
|
|
4
4
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
5
5
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
6
|
+
const getSettings = require('../utils/get-settings.js')
|
|
6
7
|
const isPositive = require('../utils/is-positive.js')
|
|
7
8
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
8
9
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -70,7 +71,8 @@ const sortNamedImports = createEslintRule.createEslintRule({
|
|
|
70
71
|
({ type }) => type === 'ImportSpecifier',
|
|
71
72
|
)
|
|
72
73
|
if (specifiers.length > 1) {
|
|
73
|
-
let
|
|
74
|
+
let settings = getSettings.getSettings(context.settings)
|
|
75
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
74
76
|
type: 'alphabetical',
|
|
75
77
|
ignoreAlias: false,
|
|
76
78
|
groupKind: 'mixed',
|
|
@@ -2,6 +2,7 @@ import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
|
2
2
|
import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
3
3
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
4
4
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
5
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
5
6
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
6
7
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
7
8
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -69,7 +70,8 @@ const sortNamedImports = createEslintRule({
|
|
|
69
70
|
({ type }) => type === 'ImportSpecifier',
|
|
70
71
|
)
|
|
71
72
|
if (specifiers.length > 1) {
|
|
72
|
-
let
|
|
73
|
+
let settings = getSettings(context.settings)
|
|
74
|
+
let options = complete(context.options.at(0), settings, {
|
|
73
75
|
type: 'alphabetical',
|
|
74
76
|
ignoreAlias: false,
|
|
75
77
|
groupKind: 'mixed',
|
|
@@ -5,6 +5,7 @@ const getGroupNumber = require('../utils/get-group-number.js')
|
|
|
5
5
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
6
6
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
7
7
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
8
|
+
const getSettings = require('../utils/get-settings.js')
|
|
8
9
|
const isPositive = require('../utils/is-positive.js')
|
|
9
10
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
10
11
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -107,7 +108,8 @@ const sortObjectTypes = createEslintRule.createEslintRule({
|
|
|
107
108
|
create: context => ({
|
|
108
109
|
TSTypeLiteral: node => {
|
|
109
110
|
if (node.members.length > 1) {
|
|
110
|
-
let
|
|
111
|
+
let settings = getSettings.getSettings(context.settings)
|
|
112
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
111
113
|
partitionByNewLine: false,
|
|
112
114
|
type: 'alphabetical',
|
|
113
115
|
groupKind: 'mixed',
|
|
@@ -4,6 +4,7 @@ import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
|
4
4
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
5
5
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
6
6
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
7
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
7
8
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
8
9
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
9
10
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -106,7 +107,8 @@ const sortObjectTypes = createEslintRule({
|
|
|
106
107
|
create: context => ({
|
|
107
108
|
TSTypeLiteral: node => {
|
|
108
109
|
if (node.members.length > 1) {
|
|
109
|
-
let
|
|
110
|
+
let settings = getSettings(context.settings)
|
|
111
|
+
let options = complete(context.options.at(0), settings, {
|
|
110
112
|
partitionByNewLine: false,
|
|
111
113
|
type: 'alphabetical',
|
|
112
114
|
groupKind: 'mixed',
|
|
@@ -9,6 +9,7 @@ const getSourceCode = require('../utils/get-source-code.js')
|
|
|
9
9
|
const getNodeParent = require('../utils/get-node-parent.js')
|
|
10
10
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
11
11
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
12
|
+
const getSettings = require('../utils/get-settings.js')
|
|
12
13
|
const isPositive = require('../utils/is-positive.js')
|
|
13
14
|
const useGroups = require('../utils/use-groups.js')
|
|
14
15
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -141,7 +142,8 @@ const sortObjects = createEslintRule.createEslintRule({
|
|
|
141
142
|
],
|
|
142
143
|
create: context => {
|
|
143
144
|
let sortObject = node => {
|
|
144
|
-
let
|
|
145
|
+
let settings = getSettings.getSettings(context.settings)
|
|
146
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
145
147
|
partitionByNewLine: false,
|
|
146
148
|
partitionByComment: false,
|
|
147
149
|
styledComponents: true,
|
|
@@ -8,6 +8,7 @@ import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
|
8
8
|
import { getNodeParent } from '../utils/get-node-parent.mjs'
|
|
9
9
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
10
10
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
11
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
11
12
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
12
13
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
13
14
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -140,7 +141,8 @@ const sortObjects = createEslintRule({
|
|
|
140
141
|
],
|
|
141
142
|
create: context => {
|
|
142
143
|
let sortObject = node => {
|
|
143
|
-
let
|
|
144
|
+
let settings = getSettings(context.settings)
|
|
145
|
+
let options = complete(context.options.at(0), settings, {
|
|
144
146
|
partitionByNewLine: false,
|
|
145
147
|
partitionByComment: false,
|
|
146
148
|
styledComponents: true,
|
|
@@ -4,6 +4,7 @@ const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
|
4
4
|
const getGroupNumber = require('../utils/get-group-number.js')
|
|
5
5
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
6
6
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
7
|
+
const getSettings = require('../utils/get-settings.js')
|
|
7
8
|
const isPositive = require('../utils/is-positive.js')
|
|
8
9
|
const useGroups = require('../utils/use-groups.js')
|
|
9
10
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
@@ -98,7 +99,8 @@ const sortSvelteAttributes = createEslintRule.createEslintRule({
|
|
|
98
99
|
return {
|
|
99
100
|
SvelteStartTag: node => {
|
|
100
101
|
if (node.attributes.length > 1) {
|
|
101
|
-
let
|
|
102
|
+
let settings = getSettings.getSettings(context.settings)
|
|
103
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
102
104
|
type: 'alphabetical',
|
|
103
105
|
ignoreCase: true,
|
|
104
106
|
customGroups: {},
|
|
@@ -3,6 +3,7 @@ import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
|
3
3
|
import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
4
4
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
5
5
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
6
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
6
7
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
7
8
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
8
9
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
@@ -97,7 +98,8 @@ const sortSvelteAttributes = createEslintRule({
|
|
|
97
98
|
return {
|
|
98
99
|
SvelteStartTag: node => {
|
|
99
100
|
if (node.attributes.length > 1) {
|
|
100
|
-
let
|
|
101
|
+
let settings = getSettings(context.settings)
|
|
102
|
+
let options = complete(context.options.at(0), settings, {
|
|
101
103
|
type: 'alphabetical',
|
|
102
104
|
ignoreCase: true,
|
|
103
105
|
customGroups: {},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
3
3
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
4
4
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
5
|
+
const getSettings = require('../utils/get-settings.js')
|
|
5
6
|
const isPositive = require('../utils/is-positive.js')
|
|
6
7
|
const makeFixes = require('../utils/make-fixes.js')
|
|
7
8
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
@@ -54,7 +55,8 @@ const sortSwitchCase = createEslintRule.createEslintRule({
|
|
|
54
55
|
],
|
|
55
56
|
create: context => ({
|
|
56
57
|
SwitchStatement: node => {
|
|
57
|
-
let
|
|
58
|
+
let settings = getSettings.getSettings(context.settings)
|
|
59
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
58
60
|
type: 'alphabetical',
|
|
59
61
|
ignoreCase: true,
|
|
60
62
|
order: 'asc',
|
|
@@ -76,10 +78,12 @@ const sortSwitchCase = createEslintRule.createEslintRule({
|
|
|
76
78
|
let nodes = node.cases.map(caseNode => {
|
|
77
79
|
var _a, _b
|
|
78
80
|
let name
|
|
81
|
+
let isDefaultClause = false
|
|
79
82
|
if (((_a = caseNode.test) == null ? void 0 : _a.type) === 'Literal') {
|
|
80
83
|
name = `${caseNode.test.value}`
|
|
81
84
|
} else if (caseNode.test === null) {
|
|
82
85
|
name = 'default'
|
|
86
|
+
isDefaultClause = true
|
|
83
87
|
} else {
|
|
84
88
|
name = sourceCode.text.slice(...caseNode.test.range)
|
|
85
89
|
}
|
|
@@ -89,6 +93,7 @@ const sortSwitchCase = createEslintRule.createEslintRule({
|
|
|
89
93
|
caseNode.range,
|
|
90
94
|
),
|
|
91
95
|
node: caseNode,
|
|
96
|
+
isDefaultClause,
|
|
92
97
|
name,
|
|
93
98
|
}
|
|
94
99
|
})
|
|
@@ -99,7 +104,7 @@ const sortSwitchCase = createEslintRule.createEslintRule({
|
|
|
99
104
|
(lefter == null ? void 0 : lefter.node.consequent.length) === 0 &&
|
|
100
105
|
left.node.consequent.length !== 0
|
|
101
106
|
let isGroupContainsDefault = group =>
|
|
102
|
-
group.some(currentNode => currentNode.
|
|
107
|
+
group.some(currentNode => currentNode.isDefaultClause)
|
|
103
108
|
let leftCaseGroup = [left]
|
|
104
109
|
let rightCaseGroup = [right]
|
|
105
110
|
for (let i = iteration - 1; i >= 0; i--) {
|
|
@@ -166,7 +171,7 @@ const sortSwitchCase = createEslintRule.createEslintRule({
|
|
|
166
171
|
let sortedGroup = sortNodes
|
|
167
172
|
.sortNodes(group, options)
|
|
168
173
|
.sort((a, b) => {
|
|
169
|
-
if (b.
|
|
174
|
+
if (b.isDefaultClause) {
|
|
170
175
|
return -1
|
|
171
176
|
}
|
|
172
177
|
return 1
|
|
@@ -224,7 +229,7 @@ const sortSwitchCase = createEslintRule.createEslintRule({
|
|
|
224
229
|
})
|
|
225
230
|
let sortedNodes = sortedNodeGroups.flat()
|
|
226
231
|
for (let max = sortedNodes.length, i = 0; i < max; i++) {
|
|
227
|
-
if (sortedNodes.at(i).
|
|
232
|
+
if (sortedNodes.at(i).isDefaultClause) {
|
|
228
233
|
sortedNodes.push(sortedNodes.splice(i, 1).at(0))
|
|
229
234
|
}
|
|
230
235
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
2
2
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
3
3
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
4
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
4
5
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
5
6
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
6
7
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
@@ -53,7 +54,8 @@ const sortSwitchCase = createEslintRule({
|
|
|
53
54
|
],
|
|
54
55
|
create: context => ({
|
|
55
56
|
SwitchStatement: node => {
|
|
56
|
-
let
|
|
57
|
+
let settings = getSettings(context.settings)
|
|
58
|
+
let options = complete(context.options.at(0), settings, {
|
|
57
59
|
type: 'alphabetical',
|
|
58
60
|
ignoreCase: true,
|
|
59
61
|
order: 'asc',
|
|
@@ -75,10 +77,12 @@ const sortSwitchCase = createEslintRule({
|
|
|
75
77
|
let nodes = node.cases.map(caseNode => {
|
|
76
78
|
var _a, _b
|
|
77
79
|
let name
|
|
80
|
+
let isDefaultClause = false
|
|
78
81
|
if (((_a = caseNode.test) == null ? void 0 : _a.type) === 'Literal') {
|
|
79
82
|
name = `${caseNode.test.value}`
|
|
80
83
|
} else if (caseNode.test === null) {
|
|
81
84
|
name = 'default'
|
|
85
|
+
isDefaultClause = true
|
|
82
86
|
} else {
|
|
83
87
|
name = sourceCode.text.slice(...caseNode.test.range)
|
|
84
88
|
}
|
|
@@ -88,6 +92,7 @@ const sortSwitchCase = createEslintRule({
|
|
|
88
92
|
caseNode.range,
|
|
89
93
|
),
|
|
90
94
|
node: caseNode,
|
|
95
|
+
isDefaultClause,
|
|
91
96
|
name,
|
|
92
97
|
}
|
|
93
98
|
})
|
|
@@ -98,7 +103,7 @@ const sortSwitchCase = createEslintRule({
|
|
|
98
103
|
(lefter == null ? void 0 : lefter.node.consequent.length) === 0 &&
|
|
99
104
|
left.node.consequent.length !== 0
|
|
100
105
|
let isGroupContainsDefault = group =>
|
|
101
|
-
group.some(currentNode => currentNode.
|
|
106
|
+
group.some(currentNode => currentNode.isDefaultClause)
|
|
102
107
|
let leftCaseGroup = [left]
|
|
103
108
|
let rightCaseGroup = [right]
|
|
104
109
|
for (let i = iteration - 1; i >= 0; i--) {
|
|
@@ -159,7 +164,7 @@ const sortSwitchCase = createEslintRule({
|
|
|
159
164
|
.map(group => {
|
|
160
165
|
var _a, _b
|
|
161
166
|
let sortedGroup = sortNodes(group, options).sort((a, b) => {
|
|
162
|
-
if (b.
|
|
167
|
+
if (b.isDefaultClause) {
|
|
163
168
|
return -1
|
|
164
169
|
}
|
|
165
170
|
return 1
|
|
@@ -212,7 +217,7 @@ const sortSwitchCase = createEslintRule({
|
|
|
212
217
|
})
|
|
213
218
|
let sortedNodes = sortedNodeGroups.flat()
|
|
214
219
|
for (let max = sortedNodes.length, i = 0; i < max; i++) {
|
|
215
|
-
if (sortedNodes.at(i).
|
|
220
|
+
if (sortedNodes.at(i).isDefaultClause) {
|
|
216
221
|
sortedNodes.push(sortedNodes.splice(i, 1).at(0))
|
|
217
222
|
}
|
|
218
223
|
}
|
|
@@ -4,6 +4,7 @@ const getGroupNumber = require('../utils/get-group-number.js')
|
|
|
4
4
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
5
5
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
6
6
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
7
|
+
const getSettings = require('../utils/get-settings.js')
|
|
7
8
|
const isPositive = require('../utils/is-positive.js')
|
|
8
9
|
const useGroups = require('../utils/use-groups.js')
|
|
9
10
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
@@ -75,7 +76,8 @@ const sortUnionTypes = createEslintRule.createEslintRule({
|
|
|
75
76
|
],
|
|
76
77
|
create: context => ({
|
|
77
78
|
TSUnionType: node => {
|
|
78
|
-
let
|
|
79
|
+
let settings = getSettings.getSettings(context.settings)
|
|
80
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
79
81
|
type: 'alphabetical',
|
|
80
82
|
ignoreCase: true,
|
|
81
83
|
order: 'asc',
|
|
@@ -3,6 +3,7 @@ import { getGroupNumber } from '../utils/get-group-number.mjs'
|
|
|
3
3
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
4
4
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
5
5
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
6
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
6
7
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
7
8
|
import { useGroups } from '../utils/use-groups.mjs'
|
|
8
9
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
@@ -74,7 +75,8 @@ const sortUnionTypes = createEslintRule({
|
|
|
74
75
|
],
|
|
75
76
|
create: context => ({
|
|
76
77
|
TSUnionType: node => {
|
|
77
|
-
let
|
|
78
|
+
let settings = getSettings(context.settings)
|
|
79
|
+
let options = complete(context.options.at(0), settings, {
|
|
78
80
|
type: 'alphabetical',
|
|
79
81
|
ignoreCase: true,
|
|
80
82
|
order: 'asc',
|
|
@@ -3,6 +3,7 @@ const createEslintRule = require('../utils/create-eslint-rule.js')
|
|
|
3
3
|
const getSourceCode = require('../utils/get-source-code.js')
|
|
4
4
|
const toSingleLine = require('../utils/to-single-line.js')
|
|
5
5
|
const rangeToDiff = require('../utils/range-to-diff.js')
|
|
6
|
+
const getSettings = require('../utils/get-settings.js')
|
|
6
7
|
const isPositive = require('../utils/is-positive.js')
|
|
7
8
|
const sortNodes = require('../utils/sort-nodes.js')
|
|
8
9
|
const makeFixes = require('../utils/make-fixes.js')
|
|
@@ -56,7 +57,8 @@ const sortVariableDeclarations = createEslintRule.createEslintRule({
|
|
|
56
57
|
create: context => ({
|
|
57
58
|
VariableDeclaration: node => {
|
|
58
59
|
if (node.declarations.length > 1) {
|
|
59
|
-
let
|
|
60
|
+
let settings = getSettings.getSettings(context.settings)
|
|
61
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
60
62
|
type: 'alphabetical',
|
|
61
63
|
ignoreCase: true,
|
|
62
64
|
order: 'asc',
|
|
@@ -2,6 +2,7 @@ import { createEslintRule } from '../utils/create-eslint-rule.mjs'
|
|
|
2
2
|
import { getSourceCode } from '../utils/get-source-code.mjs'
|
|
3
3
|
import { toSingleLine } from '../utils/to-single-line.mjs'
|
|
4
4
|
import { rangeToDiff } from '../utils/range-to-diff.mjs'
|
|
5
|
+
import { getSettings } from '../utils/get-settings.mjs'
|
|
5
6
|
import { isPositive } from '../utils/is-positive.mjs'
|
|
6
7
|
import { sortNodes } from '../utils/sort-nodes.mjs'
|
|
7
8
|
import { makeFixes } from '../utils/make-fixes.mjs'
|
|
@@ -55,7 +56,8 @@ const sortVariableDeclarations = createEslintRule({
|
|
|
55
56
|
create: context => ({
|
|
56
57
|
VariableDeclaration: node => {
|
|
57
58
|
if (node.declarations.length > 1) {
|
|
58
|
-
let
|
|
59
|
+
let settings = getSettings(context.settings)
|
|
60
|
+
let options = complete(context.options.at(0), settings, {
|
|
59
61
|
type: 'alphabetical',
|
|
60
62
|
ignoreCase: true,
|
|
61
63
|
order: 'asc',
|
|
@@ -103,7 +103,8 @@ const sortVueAttributes = createEslintRule.createEslintRule({
|
|
|
103
103
|
return defineTemplateBodyVisitor({
|
|
104
104
|
VStartTag: node => {
|
|
105
105
|
if (node.attributes.length > 1) {
|
|
106
|
-
let
|
|
106
|
+
let settings = context.settings.perfectionist
|
|
107
|
+
let options = complete.complete(context.options.at(0), settings, {
|
|
107
108
|
type: 'alphabetical',
|
|
108
109
|
ignoreCase: true,
|
|
109
110
|
customGroups: {},
|
|
@@ -102,7 +102,8 @@ const sortVueAttributes = createEslintRule({
|
|
|
102
102
|
return defineTemplateBodyVisitor({
|
|
103
103
|
VStartTag: node => {
|
|
104
104
|
if (node.attributes.length > 1) {
|
|
105
|
-
let
|
|
105
|
+
let settings = context.settings.perfectionist
|
|
106
|
+
let options = complete(context.options.at(0), settings, {
|
|
106
107
|
type: 'alphabetical',
|
|
107
108
|
ignoreCase: true,
|
|
108
109
|
customGroups: {},
|