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": {
}
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.