Tikkes
Tikkes

Reputation: 4689

ESLint object destructuring new line formats function

I want to be able to format my code something like this:

const {
    header, 
    note, 
    otherStuff
} = labels;

const { thisDestructuredObject } = _.get(labels,`some.thing.here`,`some.default.value`);

Eslint formats it like this:

const {
    header, note, otherStuff
} = labels;

const { thisDestructuredObject } = _.get(labels,
    `some.thing.here`,
    `some.default.value`);

Yet, I have both rules set:

"function-paren-newline": ["error", { "minItems": 4 }],
"object-curly-newline": [
    "error",
    {
        "ObjectExpression": { "multiline": true, "minProperties": 2 },
        "ObjectPattern": { "multiline": true, "minProperties": 2 },
        "ImportDeclaration": "never",
        "ExportDeclaration": { "multiline": true, "minProperties": 3 }
    }
]

I have presets enabled for React and the recommended settings for ESLint. Also, plugins for React and React-hooks are set.

Anyone ever tried to do something like this?

Upvotes: 2

Views: 3233

Answers (1)

Brian Surowiec
Brian Surowiec

Reputation: 17291

There isn't a built-in rule for this currently, but there is an open proposal for it. The eslint-plugin-putout package has a couple rules for doing this until it's baked it.

Upvotes: 1

Related Questions