DEV Community

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

Posted on

17 1 1 1 1

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!

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay