繁体   English   中英

eslint / eslint-plugin-react:找不到.jsx文件

[英]eslint/eslint-plugin-react:not finding .jsx files

我第一次在react应用程序上使用eslint ,虽然它可以很好地检查.js文件,但找不到任何.jsx文件。 诚然,我的理解很模糊,但是我认为eslint-plugin-react自动将.jsx文件扫描并将parserOptions.ecmaFeatures.jsx设置为true?

如果我运行npm run:lint -- --ext .jsx则将正确扫描jsx文件,但不会使用默认的npm run:lint命令

我的.eslintrc在这里:

{
  "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": {
  }
}

看起来使用--ext CLI标志是指定文件扩展名的唯一方法。 请参阅下面的文档。

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

您可以做的一件事是将标志包含在npm命令中。 例如, npm run lint可以运行eslint --ext .jsx因此您不必手动键入它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM