andre487
andre487

Reputation: 1397

ESlint: validate files by glob pattern

Can I split the ESLint rules by glob pattern?

I mean case like this:

{ 
  "*.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 */ }
}

There is the jshint-groups wrapper for JSHint. Is there something like this for ESLint?

Upvotes: 1

Views: 929

Answers (2)

caveman_dick
caveman_dick

Reputation: 6647

This is now possible using an overrides section:

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

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

Upvotes: 1

Ilya Volodin
Ilya Volodin

Reputation: 11266

Not yet. It's one of the items on the road map for version 2.0.0. For now if you are using grunt/gulp, you can just create multiple tasks with multiple .eslintrc files.

Upvotes: 2

Related Questions