Skip to content

complete/sort-objects

💼 This rule is enabled in the ✅ recommended config.

📝 Requires object properties to match the declared type order or alphabetical order.

🔧 This rule is automatically fixable by the --fix CLI option.

💭 This rule requires type information.

Requires object literal properties to match the declared type order. If there is no declared property order, object literal properties must be in alphabetical order.

For single interface inheritance chains, derived properties come first, followed by inherited properties, with source order preserved within each declaration. Overrides keep their derived position. Mapped types such as Partial and Omit preserve this order when their properties retain the original declarations. Properties from unrelated bases, intersections, or merged declarations still fall back to alphabetical order when they span multiple declaration containers.

This rule has an auto-fixer, but it will refuse to auto-fix if there are attached block comments, as those usually semantic meaning relating to the line and the auto-fixer is not smart enough to move them.

interface Foo {
name: string;
description: string;
}
// Bad
const foo: Foo = {
description: "A foo.",
name: "foo",
};
// Good
const foo: Foo = {
name: "foo",
description: "A foo.",
};

This rule is not configurable.