[英]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: Eslint 格式如下:
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.我为
React
启用了预设,并为 ESLint 推荐了设置。 Also, plugins for React
and React-hooks
are set.此外,还设置了
React
和React-hooks
插件。
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.
eslint-plugin-putout包有几个规则来执行此操作,直到它被烘烤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.