Babel ES-Lint在导入模块中分析错误无法找到模块'./parse-with-patch'

bqucvtff  于 2022-12-08  发布在  Babel
关注(0)|答案(6)|浏览(265)

在过去的一个小时里,我一直在搜索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选项都在工作,这很好,但是如果我在整个应用程序中的每一个导入语句都出现错误,我就没有办法让其他人使用这个配置。
有人知道发生了什么吗?

57hvy0tb

57hvy0tb1#

以下步骤可能有效:
1.将path更改为path.ts
1.保存
1.再次将其更改为path
1.保存

mqkwyuun

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

"rules": {
    "import/no-named-as-default": 0
}
njthzxwz

njthzxwz3#

删除node_modules和重新安装一切为我工作:-(

0g0grzrc

0g0grzrc5#

只要加上你的eslint规则。对我来说很好

“解析器”:“关闭,”

gpfsuwkq

gpfsuwkq6#

全局卸载EsLint解决了我的问题:npm uninstall -g eslint

相关问题