object-properties-newline
Enforce multiline objects when they have two or more properties.
- Rule ID:
tai-kun/object-properties-newline - Auto-fix: Yes
Inserts a line break after { when an object literal or JSON object has two or more properties and the first property starts on the same line as the brace.
Configuration
Add the rule to lint.rules in vite.config.ts to enable it.
"tai-kun/object-properties-newline": "error",
Examples
Invalid
const value = { a: 1, b: 2 };
Valid
const value = {
a: 1,
b: 2,
};
Notes
- Sortable objects are skipped because
sort-object-propertiesalso makes them multiline. - Use it together with Oxfmt’s
objectWrap: "preserve". JSON is formatted with the same setting. - Objects with one property are ignored.
- JSON (
JSONObjectExpression) is also covered. Each nested object is checked.