diff --git a/packages/eslint-plugin/src/rules/consistent-device-config-property-order.ts b/packages/eslint-plugin/src/rules/consistent-device-config-property-order.ts index c99e3fe7d154..1ace0f740e95 100644 --- a/packages/eslint-plugin/src/rules/consistent-device-config-property-order.ts +++ b/packages/eslint-plugin/src/rules/consistent-device-config-property-order.ts @@ -48,7 +48,7 @@ export const consistentDeviceConfigPropertyOrder: JSONCRule.RuleModule = { .filter( (c) => c.loc?.start.line - === prev.property.loc.end.line, + === prev.property.loc.end.line, ); prev.comments.trailing.push( ...wronglyAttributedComments, @@ -80,8 +80,8 @@ export const consistentDeviceConfigPropertyOrder: JSONCRule.RuleModule = { 0, withRanges[0].property.loc.start.column, ); - // TODO: Change to .toSorted() once on node 20. - const desiredOrder = [...propsWithComments].sort((a, b) => + // TODO: Change to .toSorted() once on node 20. + const desiredOrder = [...propsWithComments].sort((a, b) => a.index - b.index ).map((prop) => { const start = Math.min( @@ -161,7 +161,8 @@ export const consistentDeviceConfigPropertyOrder: JSONCRule.RuleModule = { schema: [], messages: { "parameter-ordering": - `For consistency, config param properties should follow the order ${paramInfoPropertyOrder.map((p) => `"${p}"`).join(", ") + `For consistency, config param properties should follow the order ${ + paramInfoPropertyOrder.map((p) => `"${p}"`).join(", ") }.`, }, type: "problem",