Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,28 @@ export const rule = createRule({
fix(fixer) {
const sourceCode = context.sourceCode

const text = sortedProperties.reduce(
const reorderedText = sortedProperties.reduce(
(sourceText, specifier, index) => {
let text = ''
let textBetweenProperties = ''
if (index < allProperties.length - 1) {
text = sourceCode
textBetweenProperties = sourceCode
.getText()
.slice(
allProperties[index]!.range[1],
allProperties[index + 1]!.range[0],
)
}
return (
sourceText + sourceCode.getText(specifier.property) + text
sourceText +
sourceCode.getText(specifier.property) +
textBetweenProperties
)
},
'',
)
return fixer.replaceTextRange(
[allProperties[0]!.range[0], allProperties.at(-1)!.range[1]],
text,
reorderedText,
)
},
})
Expand Down