4

I'm using eslint on a react app for the first time, and while it's checking .js files perfectly well, it's not finding any .jsx files. Admittedly my understanding is hazy, but I thought eslint-plugin-react automatically scanned .jsx files as well with parserOptions.ecmaFeatures.jsx set to true?

If I run npm run:lint -- --ext .jsx then jsx files are scanned correctly, but not with a default npm run:lint command

My .eslintrc here:

{
  "plugins": [
    "react"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6":     true,
    "browser": true,
    "node":    true,
    "mocha":   true,
    "jest": true
  },
  "extends": [
    "eslint:recommended",
  "plugin:react/recommended"
  ],
  "rules": {
  }
}

1 Answer 1

3

It looks like using the --ext CLI flag is the only way to specify file extensions. See the documentation below.

https://eslint.org/docs/2.0.0/user-guide/configuring#specifying-file-extensions-to-lint

One thing you could do is to include the flag as part of your npm command. For example, npm run lint could run eslint --ext .jsx so that you don't have to type it manually.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.