JavaScript275 Documents

Property Formatting

Keep one object property on one line, keep a destructured parameter brace beside its opening parenthesis, require multiline formatting for two or more properties, sort multiline properties alphabetically, and keep the rest pattern last in JavaScript and JSX.

Correct

const item = { title }
const item = {
    description,
    title,
}
const {
    title,
    ...rest
} = item
export default ({ date }) => {}

Incorrect

const item = { title, description }
const item = {
    title,
    description,
}
export default (
    { date }) => {}

Fix

Keep one property on one line, keep a destructured parameter brace beside its opening parenthesis, move multiple properties to separate lines, sort them alphabetically, and keep the rest pattern last.