Make ESLint apply rules to only certain file name patterns
Is it possible to configure ESLint in a way that it only applies rules to files that names are matching certain pattern? I know it's possible to have separate rule sheets in directories, but in case the structure is following:
app
|
|- module1
| |- module1.js
| |- module1.spec.js
|
|- module2
| |- module2.js
| |- module2.spec.js
And I want a project-wide rules that would only apply to the *.spec.js files. I'd expect to have a setting like
"include-pattern": "*.spec.js"
in the .eslintrc or any other, simlilar way to specify which filenames should be considered for specific rules.
Updated answer:
Yes, now it's possible. In your example it could look like
{
"rules": {
"quotes": [ 2, "double" ]
},
"overrides": [
{
"files": [ "app/module1/*.js" ],
"excludedFiles": "*.spec.js",
"rules": {
"quotes": [ 2, "single" ]
}
}
]
}
You can read more at eslint doc page.
Old answer:
Currently this is not supported. But for 2.0.0
version we are actively working on this feature.
To track progress: https://github.com/eslint/eslint/issues/3611
Temporary workaround is to use .eslintignore
file with something like this inside:
*.js
!*.spec.js