簡體   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