简体   繁体   English

Babel ES-Lint 解析导入模块中的错误。 找不到模块'./parse-with-patch'

[英]Babel ES-Lint parse errors in imported module. Cannot find module './parse-with-patch'

I have been searching Github and Stack Overflow for the past hour with no answer on how to fix this problem with ES-Lint.在过去的一个小时里,我一直在搜索 Github 和 Stack Overflow,但没有关于如何使用 ES-Lint 解决此问题的答案。

在此处输入图像描述

.eslintrc.json .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开发依赖

"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"
  },

All of the linter options are working which is great, but there is no way I can let other people use this config if I am getting errors for every single import statement throughout the entire app.所有的 linter 选项都很好,但是如果我在整个应用程序中的每个导入语句都出现错误,我无法让其他人使用这个配置。

Does anyone have any idea what could be going on?有谁知道会发生什么?

Just disable that rule to rrsolve this issue insted of uninstalling ESLint只需禁用该规则即可解决此问题,即卸载 ESLint

"Unfortunately, React + Redux is the most common scenario. However, there are lots of other cases where HOCs will force developers to shut down this rule." “不幸的是,React + Redux 是最常见的场景。但是,还有很多其他情况 HOC 会迫使开发人员关闭此规则。”

https://github.com/benmosher/eslint-plugin-import/issues/544https://github.com/benmosher/eslint-plugin-import/issues/544

https://github.com/reactjs/react-redux/issues/119 https://github.com/reactjs/react-redux/issues/119

https://github.com/18F/calc/pull/1235 https://github.com/18F/calc/pull/1235

.eslintrc .eslintrc

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

These steps might work:这些步骤可能有效:

  1. Change path to path.tspath更改为path.ts
  2. Save节省
  3. Again, change it to path再次,将其更改为path
  4. Save节省

删除node_modules并重新安装一切对我node_modules :-(

babel-eslint has been deprecated. babel-eslint已被弃用。 Update to @babel/eslint-parser .更新到@babel/eslint-parser

https://tjaddison.com/blog/2021/03/updating-babel-eslint-to-babeleslint-parser-for-react-apps/ https://tjaddison.com/blog/2021/03/updating-babel-eslint-to-babeleslint-parser-for-react-apps/

just add in your eslint rules.只需添加您的 eslint 规则。 Works fine for me对我来说很好

"parser": "off", “解析器”:“关闭”,

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

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

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