eslint-plugin-perfectionist 3.0.0 → 3.1.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 (45) hide show
  1. package/dist/index.d.ts +20 -6
  2. package/dist/rules/sort-array-includes.js +1 -1
  3. package/dist/rules/sort-array-includes.mjs +1 -1
  4. package/dist/rules/sort-astro-attributes.js +1 -1
  5. package/dist/rules/sort-astro-attributes.mjs +1 -1
  6. package/dist/rules/sort-classes.js +21 -1
  7. package/dist/rules/sort-classes.mjs +21 -1
  8. package/dist/rules/sort-enums.js +5 -5
  9. package/dist/rules/sort-enums.mjs +5 -5
  10. package/dist/rules/sort-exports.js +1 -1
  11. package/dist/rules/sort-exports.mjs +1 -1
  12. package/dist/rules/sort-imports.js +21 -8
  13. package/dist/rules/sort-imports.mjs +19 -8
  14. package/dist/rules/sort-interfaces.js +1 -1
  15. package/dist/rules/sort-interfaces.mjs +1 -1
  16. package/dist/rules/sort-intersection-types.js +1 -1
  17. package/dist/rules/sort-intersection-types.mjs +1 -1
  18. package/dist/rules/sort-jsx-props.js +102 -117
  19. package/dist/rules/sort-jsx-props.mjs +91 -104
  20. package/dist/rules/sort-maps.js +1 -1
  21. package/dist/rules/sort-maps.mjs +1 -1
  22. package/dist/rules/sort-named-exports.js +1 -1
  23. package/dist/rules/sort-named-exports.mjs +1 -1
  24. package/dist/rules/sort-named-imports.js +1 -1
  25. package/dist/rules/sort-named-imports.mjs +1 -1
  26. package/dist/rules/sort-object-types.js +1 -1
  27. package/dist/rules/sort-object-types.mjs +1 -1
  28. package/dist/rules/sort-objects.js +9 -12
  29. package/dist/rules/sort-objects.mjs +9 -12
  30. package/dist/rules/sort-svelte-attributes.js +1 -1
  31. package/dist/rules/sort-svelte-attributes.mjs +1 -1
  32. package/dist/rules/sort-switch-case.js +68 -15
  33. package/dist/rules/sort-switch-case.mjs +63 -15
  34. package/dist/rules/sort-union-types.js +1 -1
  35. package/dist/rules/sort-union-types.mjs +1 -1
  36. package/dist/rules/sort-variable-declarations.js +1 -1
  37. package/dist/rules/sort-variable-declarations.mjs +1 -1
  38. package/dist/rules/sort-vue-attributes.js +1 -1
  39. package/dist/rules/sort-vue-attributes.mjs +1 -1
  40. package/dist/utils/get-group-number.js +1 -1
  41. package/dist/utils/get-group-number.mjs +1 -1
  42. package/dist/utils/make-fixes.js +1 -1
  43. package/dist/utils/make-fixes.mjs +1 -1
  44. package/package.json +3 -3
  45. package/readme.md +49 -24
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
  const minimatch = require('minimatch')
3
- const path = require('node:path')
4
3
  const createEslintRule = require('../utils/create-eslint-rule.js')
5
4
  const getGroupNumber = require('../utils/get-group-number.js')
6
5
  const getSourceCode = require('../utils/get-source-code.js')
@@ -101,127 +100,113 @@ const sortJsxProps = createEslintRule.createEslintRule({
101
100
  customGroups: {},
102
101
  },
103
102
  ],
104
- create: context => {
105
- if (
106
- ['.svelte', '.astro', '.vue'].includes(path.extname(context.filename))
107
- ) {
108
- return {}
109
- }
110
- return {
111
- JSXElement: node => {
112
- if (node.openingElement.attributes.length > 1) {
113
- let options = complete.complete(context.options.at(0), {
114
- type: 'alphabetical',
115
- ignorePattern: [],
116
- ignoreCase: true,
117
- customGroups: {},
118
- order: 'asc',
119
- groups: [],
120
- })
121
- let sourceCode = getSourceCode.getSourceCode(context)
122
- let shouldIgnore = false
123
- if (options.ignorePattern.length) {
124
- let tagName = sourceCode.text.slice(
125
- ...node.openingElement.name.range,
126
- )
127
- shouldIgnore = options.ignorePattern.some(pattern =>
128
- minimatch.minimatch(tagName, pattern),
129
- )
130
- }
131
- if (!shouldIgnore && node.openingElement.attributes.length > 1) {
132
- let parts = node.openingElement.attributes.reduce(
133
- (accumulator, attribute) => {
134
- if (attribute.type === 'JSXSpreadAttribute') {
135
- accumulator.push([])
136
- return accumulator
137
- }
138
- let name =
139
- attribute.name.type === 'JSXNamespacedName'
140
- ? `${attribute.name.namespace.name}:${attribute.name.name.name}`
141
- : attribute.name.name
142
- let { getGroup, defineGroup, setCustomGroups } =
143
- useGroups.useGroups(options.groups)
144
- setCustomGroups(options.customGroups, name)
145
- if (attribute.value === null) {
146
- defineGroup('shorthand')
147
- }
148
- if (attribute.loc.start.line !== attribute.loc.end.line) {
149
- defineGroup('multiline')
150
- }
151
- let jsxNode = {
152
- size: rangeToDiff.rangeToDiff(attribute.range),
153
- group: getGroup(),
154
- node: attribute,
155
- name,
156
- }
157
- accumulator.at(-1).push(jsxNode)
103
+ create: context => ({
104
+ JSXElement: node => {
105
+ if (node.openingElement.attributes.length > 1) {
106
+ let options = complete.complete(context.options.at(0), {
107
+ type: 'alphabetical',
108
+ ignorePattern: [],
109
+ ignoreCase: true,
110
+ customGroups: {},
111
+ order: 'asc',
112
+ groups: [],
113
+ })
114
+ let sourceCode = getSourceCode.getSourceCode(context)
115
+ let shouldIgnore = false
116
+ if (options.ignorePattern.length) {
117
+ let tagName = sourceCode.text.slice(...node.openingElement.name.range)
118
+ shouldIgnore = options.ignorePattern.some(pattern =>
119
+ minimatch.minimatch(tagName, pattern),
120
+ )
121
+ }
122
+ if (!shouldIgnore && node.openingElement.attributes.length > 1) {
123
+ let parts = node.openingElement.attributes.reduce(
124
+ (accumulator, attribute) => {
125
+ if (attribute.type === 'JSXSpreadAttribute') {
126
+ accumulator.push([])
158
127
  return accumulator
159
- },
160
- [[]],
161
- )
162
- for (let nodes of parts) {
163
- pairwise.pairwise(nodes, (left, right) => {
164
- let leftNum = getGroupNumber.getGroupNumber(
165
- options.groups,
166
- left,
167
- )
168
- let rightNum = getGroupNumber.getGroupNumber(
169
- options.groups,
170
- right,
171
- )
172
- if (
173
- leftNum > rightNum ||
174
- (leftNum === rightNum &&
175
- isPositive.isPositive(
176
- compare.compare(left, right, options),
177
- ))
178
- ) {
179
- context.report({
180
- messageId: 'unexpectedJSXPropsOrder',
181
- data: {
182
- left: left.name,
183
- right: right.name,
184
- },
185
- node: right.node,
186
- fix: fixer => {
187
- let grouped = {}
188
- for (let currentNode of nodes) {
189
- let groupNum = getGroupNumber.getGroupNumber(
190
- options.groups,
191
- currentNode,
192
- )
193
- if (!(groupNum in grouped)) {
194
- grouped[groupNum] = [currentNode]
195
- } else {
196
- grouped[groupNum] = sortNodes.sortNodes(
197
- [...grouped[groupNum], currentNode],
198
- options,
199
- )
200
- }
201
- }
202
- let sortedNodes = []
203
- for (let group of Object.keys(grouped).sort(
204
- (a, b) => Number(a) - Number(b),
205
- )) {
206
- sortedNodes.push(
207
- ...sortNodes.sortNodes(grouped[group], options),
128
+ }
129
+ let name =
130
+ attribute.name.type === 'JSXNamespacedName'
131
+ ? `${attribute.name.namespace.name}:${attribute.name.name.name}`
132
+ : attribute.name.name
133
+ let { getGroup, defineGroup, setCustomGroups } =
134
+ useGroups.useGroups(options.groups)
135
+ setCustomGroups(options.customGroups, name)
136
+ if (attribute.value === null) {
137
+ defineGroup('shorthand')
138
+ }
139
+ if (attribute.loc.start.line !== attribute.loc.end.line) {
140
+ defineGroup('multiline')
141
+ }
142
+ let jsxNode = {
143
+ size: rangeToDiff.rangeToDiff(attribute.range),
144
+ node: structuredClone(attribute),
145
+ group: getGroup(),
146
+ name,
147
+ }
148
+ accumulator.at(-1).push(jsxNode)
149
+ return accumulator
150
+ },
151
+ [[]],
152
+ )
153
+ for (let nodes of parts) {
154
+ pairwise.pairwise(nodes, (left, right) => {
155
+ let leftNum = getGroupNumber.getGroupNumber(options.groups, left)
156
+ let rightNum = getGroupNumber.getGroupNumber(
157
+ options.groups,
158
+ right,
159
+ )
160
+ if (
161
+ leftNum > rightNum ||
162
+ (leftNum === rightNum &&
163
+ isPositive.isPositive(compare.compare(left, right, options)))
164
+ ) {
165
+ context.report({
166
+ messageId: 'unexpectedJSXPropsOrder',
167
+ data: {
168
+ left: left.name,
169
+ right: right.name,
170
+ },
171
+ node: right.node,
172
+ fix: fixer => {
173
+ let grouped = {}
174
+ for (let currentNode of nodes) {
175
+ let groupNum = getGroupNumber.getGroupNumber(
176
+ options.groups,
177
+ currentNode,
178
+ )
179
+ if (!(groupNum in grouped)) {
180
+ grouped[groupNum] = [currentNode]
181
+ } else {
182
+ grouped[groupNum] = sortNodes.sortNodes(
183
+ [...grouped[groupNum], currentNode],
184
+ options,
208
185
  )
209
186
  }
210
- return makeFixes.makeFixes(
211
- fixer,
212
- nodes,
213
- sortedNodes,
214
- sourceCode,
187
+ }
188
+ let sortedNodes = []
189
+ for (let group of Object.keys(grouped).sort(
190
+ (a, b) => Number(a) - Number(b),
191
+ )) {
192
+ sortedNodes.push(
193
+ ...sortNodes.sortNodes(grouped[group], options),
215
194
  )
216
- },
217
- })
218
- }
219
- })
220
- }
195
+ }
196
+ return makeFixes.makeFixes(
197
+ fixer,
198
+ nodes,
199
+ sortedNodes,
200
+ sourceCode,
201
+ )
202
+ },
203
+ })
204
+ }
205
+ })
221
206
  }
222
207
  }
223
- },
224
- }
225
- },
208
+ }
209
+ },
210
+ }),
226
211
  })
227
212
  module.exports = sortJsxProps
@@ -1,5 +1,4 @@
1
1
  import { minimatch } from 'minimatch'
2
- import path from 'node:path'
3
2
  import { createEslintRule } from '../utils/create-eslint-rule.mjs'
4
3
  import { getGroupNumber } from '../utils/get-group-number.mjs'
5
4
  import { getSourceCode } from '../utils/get-source-code.mjs'
@@ -100,113 +99,101 @@ const sortJsxProps = createEslintRule({
100
99
  customGroups: {},
101
100
  },
102
101
  ],
103
- create: context => {
104
- if (
105
- ['.svelte', '.astro', '.vue'].includes(path.extname(context.filename))
106
- ) {
107
- return {}
108
- }
109
- return {
110
- JSXElement: node => {
111
- if (node.openingElement.attributes.length > 1) {
112
- let options = complete(context.options.at(0), {
113
- type: 'alphabetical',
114
- ignorePattern: [],
115
- ignoreCase: true,
116
- customGroups: {},
117
- order: 'asc',
118
- groups: [],
119
- })
120
- let sourceCode = getSourceCode(context)
121
- let shouldIgnore = false
122
- if (options.ignorePattern.length) {
123
- let tagName = sourceCode.text.slice(
124
- ...node.openingElement.name.range,
125
- )
126
- shouldIgnore = options.ignorePattern.some(pattern =>
127
- minimatch(tagName, pattern),
128
- )
129
- }
130
- if (!shouldIgnore && node.openingElement.attributes.length > 1) {
131
- let parts = node.openingElement.attributes.reduce(
132
- (accumulator, attribute) => {
133
- if (attribute.type === 'JSXSpreadAttribute') {
134
- accumulator.push([])
135
- return accumulator
136
- }
137
- let name =
138
- attribute.name.type === 'JSXNamespacedName'
139
- ? `${attribute.name.namespace.name}:${attribute.name.name.name}`
140
- : attribute.name.name
141
- let { getGroup, defineGroup, setCustomGroups } = useGroups(
142
- options.groups,
143
- )
144
- setCustomGroups(options.customGroups, name)
145
- if (attribute.value === null) {
146
- defineGroup('shorthand')
147
- }
148
- if (attribute.loc.start.line !== attribute.loc.end.line) {
149
- defineGroup('multiline')
150
- }
151
- let jsxNode = {
152
- size: rangeToDiff(attribute.range),
153
- group: getGroup(),
154
- node: attribute,
155
- name,
156
- }
157
- accumulator.at(-1).push(jsxNode)
102
+ create: context => ({
103
+ JSXElement: node => {
104
+ if (node.openingElement.attributes.length > 1) {
105
+ let options = complete(context.options.at(0), {
106
+ type: 'alphabetical',
107
+ ignorePattern: [],
108
+ ignoreCase: true,
109
+ customGroups: {},
110
+ order: 'asc',
111
+ groups: [],
112
+ })
113
+ let sourceCode = getSourceCode(context)
114
+ let shouldIgnore = false
115
+ if (options.ignorePattern.length) {
116
+ let tagName = sourceCode.text.slice(...node.openingElement.name.range)
117
+ shouldIgnore = options.ignorePattern.some(pattern =>
118
+ minimatch(tagName, pattern),
119
+ )
120
+ }
121
+ if (!shouldIgnore && node.openingElement.attributes.length > 1) {
122
+ let parts = node.openingElement.attributes.reduce(
123
+ (accumulator, attribute) => {
124
+ if (attribute.type === 'JSXSpreadAttribute') {
125
+ accumulator.push([])
158
126
  return accumulator
159
- },
160
- [[]],
161
- )
162
- for (let nodes of parts) {
163
- pairwise(nodes, (left, right) => {
164
- let leftNum = getGroupNumber(options.groups, left)
165
- let rightNum = getGroupNumber(options.groups, right)
166
- if (
167
- leftNum > rightNum ||
168
- (leftNum === rightNum &&
169
- isPositive(compare(left, right, options)))
170
- ) {
171
- context.report({
172
- messageId: 'unexpectedJSXPropsOrder',
173
- data: {
174
- left: left.name,
175
- right: right.name,
176
- },
177
- node: right.node,
178
- fix: fixer => {
179
- let grouped = {}
180
- for (let currentNode of nodes) {
181
- let groupNum = getGroupNumber(
182
- options.groups,
183
- currentNode,
127
+ }
128
+ let name =
129
+ attribute.name.type === 'JSXNamespacedName'
130
+ ? `${attribute.name.namespace.name}:${attribute.name.name.name}`
131
+ : attribute.name.name
132
+ let { getGroup, defineGroup, setCustomGroups } = useGroups(
133
+ options.groups,
134
+ )
135
+ setCustomGroups(options.customGroups, name)
136
+ if (attribute.value === null) {
137
+ defineGroup('shorthand')
138
+ }
139
+ if (attribute.loc.start.line !== attribute.loc.end.line) {
140
+ defineGroup('multiline')
141
+ }
142
+ let jsxNode = {
143
+ size: rangeToDiff(attribute.range),
144
+ node: structuredClone(attribute),
145
+ group: getGroup(),
146
+ name,
147
+ }
148
+ accumulator.at(-1).push(jsxNode)
149
+ return accumulator
150
+ },
151
+ [[]],
152
+ )
153
+ for (let nodes of parts) {
154
+ pairwise(nodes, (left, right) => {
155
+ let leftNum = getGroupNumber(options.groups, left)
156
+ let rightNum = getGroupNumber(options.groups, right)
157
+ if (
158
+ leftNum > rightNum ||
159
+ (leftNum === rightNum &&
160
+ isPositive(compare(left, right, options)))
161
+ ) {
162
+ context.report({
163
+ messageId: 'unexpectedJSXPropsOrder',
164
+ data: {
165
+ left: left.name,
166
+ right: right.name,
167
+ },
168
+ node: right.node,
169
+ fix: fixer => {
170
+ let grouped = {}
171
+ for (let currentNode of nodes) {
172
+ let groupNum = getGroupNumber(options.groups, currentNode)
173
+ if (!(groupNum in grouped)) {
174
+ grouped[groupNum] = [currentNode]
175
+ } else {
176
+ grouped[groupNum] = sortNodes(
177
+ [...grouped[groupNum], currentNode],
178
+ options,
184
179
  )
185
- if (!(groupNum in grouped)) {
186
- grouped[groupNum] = [currentNode]
187
- } else {
188
- grouped[groupNum] = sortNodes(
189
- [...grouped[groupNum], currentNode],
190
- options,
191
- )
192
- }
193
- }
194
- let sortedNodes = []
195
- for (let group of Object.keys(grouped).sort(
196
- (a, b) => Number(a) - Number(b),
197
- )) {
198
- sortedNodes.push(...sortNodes(grouped[group], options))
199
180
  }
200
- return makeFixes(fixer, nodes, sortedNodes, sourceCode)
201
- },
202
- })
203
- }
204
- })
205
- }
181
+ }
182
+ let sortedNodes = []
183
+ for (let group of Object.keys(grouped).sort(
184
+ (a, b) => Number(a) - Number(b),
185
+ )) {
186
+ sortedNodes.push(...sortNodes(grouped[group], options))
187
+ }
188
+ return makeFixes(fixer, nodes, sortedNodes, sourceCode)
189
+ },
190
+ })
191
+ }
192
+ })
206
193
  }
207
194
  }
208
- },
209
- }
210
- },
195
+ }
196
+ },
197
+ }),
211
198
  })
212
199
  export { sortJsxProps as default }
@@ -99,7 +99,7 @@ const sortMaps = createEslintRule.createEslintRule({
99
99
  }
100
100
  return {
101
101
  size: rangeToDiff.rangeToDiff(element.range),
102
- node: element,
102
+ node: structuredClone(element),
103
103
  name,
104
104
  }
105
105
  })
@@ -98,7 +98,7 @@ const sortMaps = createEslintRule({
98
98
  }
99
99
  return {
100
100
  size: rangeToDiff(element.range),
101
- node: element,
101
+ node: structuredClone(element),
102
102
  name,
103
103
  }
104
104
  })
@@ -78,8 +78,8 @@ const sortNamedExports = createEslintRule.createEslintRule({
78
78
  }
79
79
  return {
80
80
  size: rangeToDiff.rangeToDiff(specifier.range),
81
+ node: structuredClone(specifier),
81
82
  name: specifier.local.name,
82
- node: specifier,
83
83
  group,
84
84
  }
85
85
  })
@@ -77,8 +77,8 @@ const sortNamedExports = createEslintRule({
77
77
  }
78
78
  return {
79
79
  size: rangeToDiff(specifier.range),
80
+ node: structuredClone(specifier),
80
81
  name: specifier.local.name,
81
- node: specifier,
82
82
  group,
83
83
  }
84
84
  })
@@ -94,7 +94,7 @@ const sortNamedImports = createEslintRule.createEslintRule({
94
94
  }
95
95
  return {
96
96
  size: rangeToDiff.rangeToDiff(specifier.range),
97
- node: specifier,
97
+ node: structuredClone(specifier),
98
98
  group,
99
99
  name,
100
100
  }
@@ -93,7 +93,7 @@ const sortNamedImports = createEslintRule({
93
93
  }
94
94
  return {
95
95
  size: rangeToDiff(specifier.range),
96
- node: specifier,
96
+ node: structuredClone(specifier),
97
97
  group,
98
98
  name,
99
99
  }
@@ -164,7 +164,7 @@ const sortObjectTypes = createEslintRule.createEslintRule({
164
164
  let endSize = endsWithComma ? 1 : 0
165
165
  let memberSortingNode = {
166
166
  size: rangeToDiff.rangeToDiff(member.range) - endSize,
167
- node: member,
167
+ node: structuredClone(member),
168
168
  name,
169
169
  }
170
170
  if (
@@ -164,7 +164,7 @@ const sortObjectTypes = createEslintRule({
164
164
  let endSize = endsWithComma ? 1 : 0
165
165
  let memberSortingNode = {
166
166
  size: rangeToDiff(member.range) - endSize,
167
- node: member,
167
+ node: structuredClone(member),
168
168
  name,
169
169
  }
170
170
  if (
@@ -71,6 +71,10 @@ const sortObjects = createEslintRule.createEslintRule({
71
71
  description: 'Controls whether to sort styled components.',
72
72
  type: 'boolean',
73
73
  },
74
+ destructureOnly: {
75
+ description: 'Controls whether to sort only destructured objects.',
76
+ type: 'boolean',
77
+ },
74
78
  ignorePattern: {
75
79
  description:
76
80
  'Specifies names or patterns for nodes that should be ignored by rule.',
@@ -79,10 +83,6 @@ const sortObjects = createEslintRule.createEslintRule({
79
83
  },
80
84
  type: 'array',
81
85
  },
82
- customIgnore: {
83
- description: 'Specifies custom ignore functions.',
84
- type: 'array',
85
- },
86
86
  groups: {
87
87
  description: 'Specifies the order of the groups.',
88
88
  type: 'array',
@@ -133,8 +133,8 @@ const sortObjects = createEslintRule.createEslintRule({
133
133
  partitionByComment: false,
134
134
  partitionByNewLine: false,
135
135
  styledComponents: true,
136
+ destructureOnly: false,
136
137
  ignorePattern: [],
137
- customIgnore: [],
138
138
  groups: [],
139
139
  customGroups: {},
140
140
  },
@@ -145,20 +145,17 @@ const sortObjects = createEslintRule.createEslintRule({
145
145
  partitionByNewLine: false,
146
146
  partitionByComment: false,
147
147
  styledComponents: true,
148
+ destructureOnly: false,
148
149
  type: 'alphabetical',
149
150
  ignorePattern: [],
150
151
  ignoreCase: true,
151
152
  customGroups: {},
152
- customIgnore: [],
153
153
  order: 'asc',
154
154
  groups: [],
155
155
  })
156
156
  let shouldIgnore = false
157
- if (
158
- options.customIgnore.length &&
159
- options.customIgnore.some(fn => fn(node, context.filename))
160
- ) {
161
- shouldIgnore = true
157
+ if (options.destructureOnly) {
158
+ shouldIgnore = node.type !== 'ObjectPattern'
162
159
  }
163
160
  if (!shouldIgnore && options.ignorePattern.length) {
164
161
  let varParent = getNodeParent.getNodeParent(node, [
@@ -255,7 +252,7 @@ const sortObjects = createEslintRule.createEslintRule({
255
252
  }
256
253
  let propSortingNode = {
257
254
  size: rangeToDiff.rangeToDiff(prop.range),
258
- node: prop,
255
+ node: structuredClone(prop),
259
256
  name,
260
257
  }
261
258
  if (
@@ -70,6 +70,10 @@ const sortObjects = createEslintRule({
70
70
  description: 'Controls whether to sort styled components.',
71
71
  type: 'boolean',
72
72
  },
73
+ destructureOnly: {
74
+ description: 'Controls whether to sort only destructured objects.',
75
+ type: 'boolean',
76
+ },
73
77
  ignorePattern: {
74
78
  description:
75
79
  'Specifies names or patterns for nodes that should be ignored by rule.',
@@ -78,10 +82,6 @@ const sortObjects = createEslintRule({
78
82
  },
79
83
  type: 'array',
80
84
  },
81
- customIgnore: {
82
- description: 'Specifies custom ignore functions.',
83
- type: 'array',
84
- },
85
85
  groups: {
86
86
  description: 'Specifies the order of the groups.',
87
87
  type: 'array',
@@ -132,8 +132,8 @@ const sortObjects = createEslintRule({
132
132
  partitionByComment: false,
133
133
  partitionByNewLine: false,
134
134
  styledComponents: true,
135
+ destructureOnly: false,
135
136
  ignorePattern: [],
136
- customIgnore: [],
137
137
  groups: [],
138
138
  customGroups: {},
139
139
  },
@@ -144,20 +144,17 @@ const sortObjects = createEslintRule({
144
144
  partitionByNewLine: false,
145
145
  partitionByComment: false,
146
146
  styledComponents: true,
147
+ destructureOnly: false,
147
148
  type: 'alphabetical',
148
149
  ignorePattern: [],
149
150
  ignoreCase: true,
150
151
  customGroups: {},
151
- customIgnore: [],
152
152
  order: 'asc',
153
153
  groups: [],
154
154
  })
155
155
  let shouldIgnore = false
156
- if (
157
- options.customIgnore.length &&
158
- options.customIgnore.some(fn => fn(node, context.filename))
159
- ) {
160
- shouldIgnore = true
156
+ if (options.destructureOnly) {
157
+ shouldIgnore = node.type !== 'ObjectPattern'
161
158
  }
162
159
  if (!shouldIgnore && options.ignorePattern.length) {
163
160
  let varParent = getNodeParent(node, ['VariableDeclarator', 'Property'])
@@ -246,7 +243,7 @@ const sortObjects = createEslintRule({
246
243
  }
247
244
  let propSortingNode = {
248
245
  size: rangeToDiff(prop.range),
249
- node: prop,
246
+ node: structuredClone(prop),
250
247
  name,
251
248
  }
252
249
  if (