简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM