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

Dan*_*ich 6 javascript reactjs eslint babeljs

过去一个小时我一直在 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
  }
}
Run Code Online (Sandbox Code Playgroud)

开发依赖

"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"
  },
Run Code Online (Sandbox Code Playgroud)

所有 linter 选项都在工作,这很棒,但是如果我在整个应用程序中的每个导入语句都出错,我无法让其他人使用此配置。

有谁知道会发生什么?

小智 7

这些步骤可能有效:

  1. 改成path​path.ts
  2. 节省
  3. 再次将其更改为path
  4. 节省


小智 -7

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

  • 认为人们误解了这一点。我相信 Alex 的意思是卸载 eslint 的全局版本,并使用 package.json 中声明的本地版本。 (3认同)