ESLint ignore specific rule for a specific directory

Kevin Amiranoff picture Kevin Amiranoff · Dec 24, 2016 · Viewed 36.3k times · Source

Is it possible with ESLint to ignore one specific rule for an entire directory?

In my case, I would like to ignore import/prefer-default-export for a directory named commonComponents

Answer

cartant picture cartant · Dec 24, 2016

ESLint configuration (.eslintrc) files are hierarchical:

ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem. This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file.

You can disable the import/prefer-default-export rule for the commonComponents directory by creating a .eslintrc file with the following content in that directory:

{
    "rules": {
        "import/prefer-default-export": "off"
    }
}