ESLint ignore specific rule for a specific directory

前端 未结 5 2187
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 02:35

Is it possible with ESLint to ignore one specific rule for an entire directory?

In my case, I would like to ignore import/prefer-default-export for a di

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 02:55

    You can also use the "overrides" key to declare rules for different glob patterns.

    Have a read of Configuration Based on Glob Patterns

    Sometimes a more fine-controlled configuration is necessary, for example if the configuration for files within the same directory has to be different. Therefore you can provide configurations under the overrides key that will only apply to files that match specific glob patterns, using the same format you would pass on the command line (e.g., app/**/*.test.js).

    I use this to remove the no-unused-expressions rule from my test files like so;

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

提交回复
热议问题