Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint/eslint-plugin-react:not finding .jsx files

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": {
  }
}
like image 902
PlankTon Avatar asked Oct 11 '25 09:10

PlankTon


1 Answers

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.

like image 195
Anthony N Avatar answered Oct 16 '25 11:10

Anthony N



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!