diff --git a/packages/eslint-plugin-query/src/rules/infinite-query-property-order/infinite-query-property-order.rule.ts b/packages/eslint-plugin-query/src/rules/infinite-query-property-order/infinite-query-property-order.rule.ts index d478bd1ec6..b55cef5828 100644 --- a/packages/eslint-plugin-query/src/rules/infinite-query-property-order/infinite-query-property-order.rule.ts +++ b/packages/eslint-plugin-query/src/rules/infinite-query-property-order/infinite-query-property-order.rule.ts @@ -86,11 +86,11 @@ 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], @@ -98,14 +98,16 @@ export const rule = createRule({ ) } 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, ) }, })