Disable eslint rules for folder

227

Is there a way to disable specific rules for a folder? For example, I don't want to have required JSDoc comments for all my test files in the test folder. Is there a way to do this?

This question is tagged with eslint

~ Asked on 2017-02-15 13:06:04

The Best Answer is


371

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

~ Answered on 2017-10-26 06:29:07


77

The previous answers were in the right track, but the complete answer for this is going to 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": {}
}

~ Answered on 2019-04-23 09:50:27


Most Viewed Questions: