【问题标题】:Coming from JSCS to ESLint: missing rules从 JSCS 到 ESLint:缺少规则
【发布时间】:2015-09-21 08:08:43
【问题描述】:

我们决定从 JSCS 切换到 ESLint,因为它允许对其他内容进行更多检查。我已经设法转换了大部分规则,但其中两个我无法与 ESLint 规则集匹配。因此,在我深入研究 AST 并尝试自己编写它之前,我想问一下这些是否已经存在。

{
    // nothing similar to this seems available
    "requireBlocksOnNewline": 2,
    // there is only rule for after spaces - space-after-keywords
    "requireSpaceBeforeKeywords": ["else", "while", "catch"]
}

http://jscs.info/rule/requireBlocksOnNewline.html http://jscs.info/rule/requireSpaceBeforeKeywords.html

【问题讨论】:

    标签: javascript eslint


    【解决方案1】:

    requireBlockOnNewline 可以用brace-style: [2, "1tbs"] 模拟 requireSpaceBeforeKeywords 不存在,但创建起来不会太难。

    【讨论】:

    • 是的,我很害怕。第一条规则也不同,因为我们只在有超过 2 个语句时才关心换行符。 brace-style 为一个声明而尖叫。
    • brace-style 有一个选项 allowSingleLine 可能对此有所帮助,但主要是关于在单行块周围不需要大括号,而不是换行符
    猜你喜欢
    • 1970-01-01
    • 2017-10-11
    • 2021-04-14
    • 2020-08-04
    • 2016-04-14
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 2023-03-27
    相关资源
    最近更新 更多