繁体   English   中英

ESLint 对象解构新行格式函数

[英]ESLint object destructuring new line formats function

我希望能够像这样格式化我的代码:

const {
    header, 
    note, 
    otherStuff
} = labels;

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

Eslint 格式如下:

const {
    header, note, otherStuff
} = labels;

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

然而,我设定了两个规则:

"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 }
    }
]

我为React启用了预设,并为 ESLint 推荐了设置。 此外,还设置了ReactReact-hooks插件。

有没有人试过做这样的事情?

目前没有针对此的内置规则,但有一个公开的提案 eslint-plugin-putout包有几个规则来执行此操作,直到它被烘烤。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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