【问题标题】:Eslint rule for linebreaks in function bodies函数体中换行的 Eslint 规则
【发布时间】:2020-02-17 16:53:34
【问题描述】:

我正在寻找将以下标记为错误的规则:

const setStuff = () => { setThing(2); setOtherThing(3); };

我想在正文中有多个语句时进行换行,所以这应该是正确的:

const setStuff = () => {
    setThing(2);
    setOtherThing(3);
};

哪些规则适用于此?我似乎找不到一个。我确实想继续允许一个班轮退货(例如const get = () => 3

【问题讨论】:

    标签: eslint eslintrc


    【解决方案1】:

    文档:brace-style

    您可以像这样在.eslintrc 中使用它:

    'rules': {
        'brace-style': [
            'error',
            '1tbs'
        ]
    }
    

    【讨论】:

    • 这是关于输入参数的规则,与函数体无关。
    • 是的,就是这样!谢谢!
    猜你喜欢
    • 2016-08-02
    • 2021-11-21
    • 2020-04-17
    • 2021-08-20
    • 1970-01-01
    • 2015-02-28
    • 1970-01-01
    • 2020-08-04
    相关资源
    最近更新 更多