DEV Community

Cover image for How do I configure ESLint for a specific file or folder πŸ“‚ πŸ₯°?
Martins Gouveia
Martins Gouveia

Posted on

How do I configure ESLint for a specific file or folder πŸ“‚ πŸ₯°?

To configure ESLint for a specific file or folder, you can use the overrides field in your .eslintrc.json file. Here’s an example:

{
  "rules": {
    "quotes": [2, "double"]
  },
  "overrides": [
    {
      "files": ["src/**/*.js"],
      "rules": {
        "quotes": [2, "single"]
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

In this example, the quotes rule is set to double for all files, but it’s overridden to single for all JavaScript files in the src directory.

You can also use the .eslintignore file or the ignorePatterns option in your .eslintrc.json file to tell ESLint to ignore specific files and directories.

Here’s an example of how to use ignorePatterns:

{
  "ignorePatterns": ["gulpfile.js", "gulp/**/*", "webpack.config.js"]
}
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
artxe2 profile image
Yeom suyun

It's simple and good.

Collapse
 
martygo profile image
Martins Gouveia

Thanks!