Objects Rules

Object property formatting, empty lines, and string property spacing

5 rules5 auto-isFixable1 isConfigurable

no-empty-lines-in-objects

auto-isFixable

No empty lines between properties or after {/before }

Why: Empty lines inside objects break visual grouping
Correct
javascript
const user = {    name: "John",    email: "john@example.com",};
Incorrect
javascript
const user = {    name: "John",     email: "john@example.com",};
eslint.config.js
javascript
"code-style/no-empty-lines-in-objects": "error"

object-property-per-line

auto-isFixableisConfigurable

Collapse objects with 1 property; expand larger objects

Why: Multiple properties need expansion for readability

Options

OptionTypeDefaultDescription
minPropertiesinteger2Minimum properties to trigger expansion
eslint.config.js
javascript
"code-style/object-property-per-line": ["error", { minProperties: 2 }]
Correct
javascript
const point = { x: 10 }; const point = {    x: 10,    y: 20,};
Incorrect
javascript
const point = { x: 10, y: 20 };
eslint.config.js
javascript
"code-style/object-property-per-line": "error"

object-property-value-brace

auto-isFixable

Opening { of object value on same line as :, not on new line

Why: Braces on new lines waste vertical space
Correct
javascript
const config = {    server: {        host: "localhost",    },};
Incorrect
javascript
const config = {    server:    {        host: "localhost",    },};
eslint.config.js
javascript
"code-style/object-property-value-brace": "error"

object-property-value-format

auto-isFixable

Simple property values on same line as :

Why: Values on new lines after : waste space
Correct
javascript
const user = {    name: "John",    age: 30,};
Incorrect
javascript
const user = {    name:        "John",    age:        30,};
eslint.config.js
javascript
"code-style/object-property-value-format": "error"

string-property-spacing

auto-isFixable

No leading/trailing whitespace inside string property keys

Why: Whitespace in property keys is usually unintentional
Correct
javascript
const styles = {    "& a": { color: "red" },};
Incorrect
javascript
const styles = {    " & a": { color: "red" },};
eslint.config.js
javascript
"code-style/string-property-spacing": "error"