【问题标题】:ESlint: validate files by glob patternESlint:通过 glob 模式验证文件
【发布时间】:2015-09-21 13:22:07
【问题描述】:

我可以按 glob 模式拆分 ESLint 规则吗?

我的意思是这样的情况:

{ 
  "*.server.js": { /* rules set for the server JS */ },
  "*.client.js": { /* rules set for the client JS */ },
  "*.special.js": { /* some very special JS */ },
  "*.js": { /* all other JS with its own rules not intersecting with others */ }
}

有 JSHint 的 jshint-groups 包装器。 ESLint 有这样的东西吗?

【问题讨论】:

    标签: javascript eslint


    【解决方案1】:

    还没有。这是 2.0.0 版路线图上的项目之一。目前,如果您使用 grunt/gulp,您可以使用多个 .eslintrc 文件创建多个任务。

    【讨论】:

      【解决方案2】:

      现在可以使用覆盖部分:

      {
        "rules": {...},
        "overrides": [
          {
            "files": ["*-test.js","*.spec.js"],
            "rules": {
              "no-unused-expressions": "off"
            }
          }
        ]
      }
      

      https://eslint.org/docs/user-guide/configuring/rules#using-configuration-files-1

      【讨论】:

        猜你喜欢
        • 2017-12-24
        • 1970-01-01
        • 2014-08-20
        • 2012-04-15
        • 2016-08-27
        • 2013-03-09
        • 1970-01-01
        • 2020-03-02
        • 2019-10-17
        相关资源
        最近更新 更多