Disable eslint rules for folder
In ESLint 6.7.0+ use "ignorePatterns": [].
You can tell ESLint to ignore specific files and directories using ignorePatterns in your config files.
example of .eslintrc.js
module.exports = {
env: {
...
},
extends: [
...
],
parserOptions: {
...
},
plugins: [
...
],
rules: {
...
},
ignorePatterns: ['src/test/*'], // <<< ignore all files in test folder
};
Or you can ignore files with some extension:
ignorePatterns: ['**/*.js']
You can read the user-guide doc here.
https://eslint.org/docs/user-guide/configuring/ignoring-code
The previous answers were in the right track, but the complete answer for this is going to be about disabling rules only for a group of files, there you'll find the documentation needed to disable/enable rules for certain folders (Because in some cases you don't want to ignore the whole thing, only disable certain rules). Example:
{
"env": {},
"extends": [],
"parser": "",
"plugins": [],
"rules": {},
"overrides": [
{
"files": ["test/*.spec.js"], // Or *.test.js
"rules": {
"require-jsdoc": "off"
}
}
],
"settings": {}
}
YAML version :
overrides:
- files: *-tests.js
rules:
no-param-reassign: 0
Example of specific rules for mocha tests :
You can also set a specific env for a folder, like this :
overrides:
- files: test/*-tests.js
env:
mocha: true
This configuration will fix error message about describe
and it
not defined, only for your test folder:
/myproject/test/init-tests.js
6:1 error 'describe' is not defined no-undef
9:3 error 'it' is not defined no-undef
To ignore some folder from eslint rules we could create the file .eslintignore
in root directory and add there the path to the folder we want omit (the same way as for .gitignore
).
Here is the example from the ESLint docs on Ignoring Files and Directories:
# path/to/project/root/.eslintignore
# /node_modules/* and /bower_components/* in the project root are ignored by default
# Ignore built files except build/index.js
build/*
!build/index.js