Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable eslint for all files but js files?

Right now it's giving error that .png and .less files aren't valid, everything is invalid.

I want eslint to only look at .js and .jsx files.

I don't see any way to do that.

I did find eslintignore which is not the best way to do things.

I don't want to maintain a list of files to ignore.

Whitelist approach please.

like image 542
Muhammad Umer Avatar asked Oct 24 '25 12:10

Muhammad Umer


2 Answers

You could make use of the property "overrides" on your .eslintrc file to include only the files/file types you want:

{
    "overrides": [
        {
            "files": [ "src/**/*.js", "src/**/*.jsx" ]
        }
    ]
}

Docs: https://eslint.org/docs/user-guide/configuring#example-configuration

like image 100
Wayrex Avatar answered Oct 27 '25 01:10

Wayrex


I believe there is no way to configure it other than the arguments for the CLI

If you are running it through gulp, first pipe the src like

src(['**/*.js', '**/*.jsx'])
        .pipe(eslint())
...

If you would rather do it via npm command, you can create a script in your package.json like so:

"scripts": {
  ...
  "eslint": "eslint **/*.js **/*.jsx",

Then invoke it with npm run eslint

like image 21
Thiago Camargo Avatar answered Oct 27 '25 00:10

Thiago Camargo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!