ESLint only target a specific directory (eslintrc, create-react-app)
Where you have written the script to run lint in package.json
, there only mention the folders you want to target
scripts:{"lint": "eslint src public"}
Then if you want to ignore some type of files in the respective folders, you can mention in ESLint config file.
You need to do something like eslint src/**/*.js[x]
. If you are running a webpack build(or precommit hook) that does linting check then add it within the scripts
object inside package.json
.
inside your .eslintrc.json
{
"rules": {
"quotes": [ 2, "double" ]
},
"overrides": [
{
"files": [ "src/**/*.js" ],
"rules": {
"quotes": [ 2, "single" ]
}
}
]
}
in .eslintignore
/someFolder
/anotherFolder
/oneMoreFolder
I used ignorePatterns
option. It'll tell ESLint to ignore specific files and directories. It's useful when your IDE (ex. VS Code) is reporting errors in unwanted files.
{
"ignorePatterns": ["gulpfile.js", "gulp/**/*", "webpack.config.js"]
}
You can Also use the .eslintignore
file.