由于我在 create-react-app 项目中重新安装了 NPM 依赖项,Atom 的 eslint 在每个文件的顶部都会出现此错误:
Error while running ESLint: Cannot find module 'eslint-config-react-app'.
虽然 react-scripts
的 eslint 不会引发任何警告或错误。顺便说一句,包 eslint-config-react-app
安装在 node_modules
中。
我尝试重新安装 linter-eslint、atom、NPM 依赖项等,但没有任何效果。
有人有想法吗?
这是我的 .eslintrc :
{
"extends": "react-app",
"rules": {
"jsx-a11y/anchor-is-valid": 0,
"react/jsx-no-comment-textnodes": 0,
"no-unused-vars": ["warn", {
args: "all",
ignoreRestSiblings: false,
argsIgnorePattern: "^_$"
}]
}
}
编辑:我不知道为什么,但突然间,错误发生了变化,现在每个 js 文件的顶部都出现了这个错误:
Error while running ESLint: Invalid regular expression flags
编辑2
给定的解决方案都不适用于我的情况。 linter-eslint
的问题没有解决。但我现在找到了一个解决方法:使用 fast-eslint
而不是 linter-eslint
。工作得很好。
最佳答案
对于尝试此操作的其他人,一种解决方案是全局安装 eslint-config-react-app 及其所有对等部门。目前,这是:
引用https://github.com/facebook/create-react-app/issues/3633#issuecomment-361485857
npm i -g babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0
关于reactjs - 原子和eslint : Cannot find module 'eslint-config-react-app' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58678375/