在过去的一个小时里,我一直在搜索Github和Stack Overflow,但没有找到关于如何用ES-Lint解决这个问题的答案。
.eslintrc.json
{
"parser": "babel-eslint",
"extends": ["airbnb", "prettier"],
"plugins": ["prettier", "flowtype"],
"rules": {
"prettier/prettier": ["error"],
"no-unused-expressions": 0,
"react/jsx-filename-extension": 0,
"class-methods-use-this": 0,
"default-case": 0,
"import/no-unresolved": 0,
"react/prefer-stateless-function": 0,
"import/no-named-as-default": 0
},
"parserOptions": {
"sourceType": "module",
"import/extensions": [".jsx", ".js"],
"allowImportExportEverywhere": true
}
}
设备依赖项
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.1.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.7.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.11.1",
"flow-bin": "0.78.0",
"jest": "23.5.0",
"jest-react-native": "18.0.0",
"metro-react-native-babel-preset": "^0.45.0",
"prettier": "1.14.1",
"react-native-debugger-open": "0.3.17",
"react-test-renderer": "16.0.0-alpha.12",
"schedule": "0.4.0",
"semver": "5.5.0"
},
所有的linter选项都在工作,这很好,但是如果我在整个应用程序中的每一个导入语句都出现错误,我就没有办法让其他人使用这个配置。
有人知道发生了什么吗?
6条答案
按热度按时间57hvy0tb1#
以下步骤可能有效:
1.将
path
更改为path.ts
1.保存
1.再次将其更改为
path
1.保存
mqkwyuun2#
只需禁用该规则即可解决此问题,而无需卸载ESLint
“不幸的是,React + Redux是最常见的场景。然而,还有很多其他情况下,HOC会迫使开发人员关闭这一规则。”
https://github.com/benmosher/eslint-plugin-import/issues/544
https://github.com/reactjs/react-redux/issues/119
https://github.com/18F/calc/pull/1235
.eslintrc
njthzxwz3#
删除
node_modules
和重新安装一切为我工作:-(6ss1mwsb4#
babel-eslint
已被取代。请更新至@babel/eslint-parser
。https://tjaddison.com/blog/2021/03/updating-babel-eslint-to-babeleslint-parser-for-react-apps/
0g0grzrc5#
只要加上你的eslint规则。对我来说很好
“解析器”:“关闭,”
gpfsuwkq6#
全局卸载EsLint解决了我的问题:
npm uninstall -g eslint