complete/consistent-object-braces
💼 This rule is enabled in the ✅ recommended config.
📝 Requires object brace spacing to match the property count.
🔧 This rule is automatically fixable by the
--fix CLI option.
Object literals with one property must be on one line unless that property value is another object literal. Object literals with two or more properties, object literals used as object property values, and object literals with object-valued properties must put each property on its own line. When automatically fixing an object literal to use multiple lines, the rule adds a trailing comma after every property.
This rule applies to object expressions, such as object literals assigned to variables, nested inside other objects, or passed as function arguments. It does not apply to object patterns, such as destructuring assignments or function parameters.
Rule Details
Section titled “Rule Details”// Badconst foo = { bar,};
// Goodconst foo = { bar };
// Badconst baz = { one, two };
// Goodconst baz = { one, two,};
// Badconst qux = { nested: { value } };
// Goodconst qux = { nested: { value, },};This rule does not report destructuring patterns:
const { foo } = bar;function foo({ bar }: Baz) {}Options
Section titled “Options”This rule is not configurable.
