8

I have been searching Github and Stack Overflow for the past hour with no answer on how to fix this problem with ES-Lint.

enter image description here

.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.

Does anyone have any idea what could be going on?

6
  • Seeing same. Started happening after some updates today. It was either the update to Node 11 or just the general dependency updates. It isn't all of my imports, only the ones where I am importing a default export. Commented Oct 31, 2018 at 1:02
  • Are you using vs code? Commented Oct 31, 2018 at 1:05
  • No, IntelliJ. It might be Node. I'm not getting the error on TravisCI, which is still using Node 10. Commented Oct 31, 2018 at 19:07
  • I eliminated the Node version as the culprit. It looks like there might be some incompatibility with Babel 7.1. I had various other (serious) problems until I reverted my dependencies and got back to Babel 7.0. This ESLint issue also seems to be fixed now. Commented Oct 31, 2018 at 22:18
  • I fixed mine but I honestly dont remember what I did. Did you check to see if you had eslint installed in your global npm dependencies? It might be trying to use that version. I honestly don't remember what fixed my problem. Commented Oct 31, 2018 at 22:21

6 Answers 6

7

These steps might work:

  1. Change path to path.ts
  2. Save
  3. Again, change it to path
  4. Save
Sign up to request clarification or add additional context in comments.

1 Comment

This actually worked for me with error: Parse errors in imported module 'filename.ts': ',' expected. import/namespace Wish i knew why... but now i'm just glad it's gone.
3

Just disable that rule to rrsolve this issue insted of uninstalling 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."

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
}

Comments

1

Deleting node_modules and reinstalling everything worked for me :-(

Comments

1

just add in your eslint rules. Works fine for me

"parser": "off",

Comments

0

babel-eslint has been deprecated. Update to @babel/eslint-parser.

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

1 Comment

Please add explanation with/or screen-capture or code. Sharing link over question may invalid after period of time, which tends to invalid answer.
-7

Uninstalling EsLint globally fixed my problem: npm uninstall -g eslint

3 Comments

Yeah, I think that should solve the problem for most people. Also, a really annoying gotcha is that I had to close and reopen VSCode before the settings took effect. Might be worthwhile for people to remove es lint globally then close and reopen their editor just in case.
Uninstalling EsLint is not a good practice. ESLint is used for ensuring code quality in the application. Uninstalling that not making any sense
Think people misunderstood this. I believe Alex meant uninstall the global version of eslint, and use the local version declared in the package.json.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.