Skip to main content

complete/sort-objects

💼 This rule is enabled in the ✅ recommended config.

📝 Requires object properties to match the declared type 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.

Note that 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.

Rule Details

interface Foo {
name: string;
description: string;
}

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

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

Options

This rule is not configurable.

Resources