4

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.

3
  • How are you running eslint? Commented Mar 22, 2018 at 4:12
  • in vscode and gulp Commented Mar 22, 2018 at 4:14
  • i was hoping there would be something i could put in .eslintrc Commented Mar 22, 2018 at 4:14

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

did that and it still tries to lint .png etc. WHen I add pngs to the .eslintignore, it stops but there should be a better way
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.