Vue-cli: Error when using ESLint Airbnb config

Created on 13 Apr 2019  ·  9Comments  ·  Source: vuejs/vue-cli

Version

3.5.5

Environment info

Environment Info:

  System:
    OS: Windows 7
    CPU: (4) x64 Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
  Binaries:
    Node: 11.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

  1. Run in command line: vue create vue-test
  2. Manually select features
  3. Make sure "Linter / Formatter" is selected
  4. Pick "ESLint Airbnb config"
  5. "Lint on save"
  6. Select to place config "In dedicated config files"
  7. Do not save preset for future use

What is expected?

Project will be created without errors.

What is actually happening?

 ERROR  TypeError: (0 , _ignore.getFileExtensions) is not a function
Occurred while linting d:\temp\vue-test\src\App.vue:9
TypeError: (0 , _ignore.getFileExtensions) is not a function
Occurred while linting d:\temp\vue-test\src\App.vue:9
    at checkSourceValue (d:\temp\vue-test\node_modules\eslint-plugin-import\lib\
rules\no-useless-path-segments.js:103:60)
    at checkSourceValue (d:\temp\vue-test\node_modules\eslint-module-utils\modul
eVisitor.js:29:5)
    at checkSource (d:\temp\vue-test\node_modules\eslint-module-utils\moduleVisi
tor.js:34:5)
    at listeners.(anonymous function).forEach.listener (d:\temp\vue-test\node_mo
dules\eslint\lib\util\safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (d:\temp\vue-test\node_modules\eslint\lib\util\safe-emitter.j
s:45:38)
    at NodeEventGenerator.applySelector (d:\temp\vue-test\node_modules\eslint\li
b\util\node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (d:\temp\vue-test\node_modules\eslint\l
ib\util\node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (d:\temp\vue-test\node_modules\eslint\lib\ut
il\node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (d:\temp\vue-test\node_modules\eslint\lib\code
-path-analysis\code-path-analyzer.js:632:23)

Using "ESLint with error prevention only" or "ESLint Standard config" works correctly without errors. Earlier vue-cli versions did not have this problem, but I didn't have time to find exact version where this issue started.

bug eslint upstream

Most helpful comment

Seems to be an upstream issue in eslint-plugin-import, see https://github.com/benmosher/eslint-plugin-import/issues/1322

I assume a viable workaround would be to disable this plugin's rule that throws this error for the time being, until the bug has been fixed upstream:

// .eslintrc.js
module.exports = {
  // ...stuff...
  rules: {
+    "import/no-useless-path-segments": "off",
    "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
  },
  // ..stuff....
};

Maybe the bug affects other rules as well - disable them accordingly.

All 9 comments

Same on version 3.4.1

same with macos, setup eslint for the react-project with ./node_modules/.bin/eslint --init
TypeError: (0 , _ignore.getFileExtensions) is not a function Occurred while linting /Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/src/app.js:3 at checkSourceValue (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint-plugin-import/lib/rules/no-useless-path-segments.js:103:60) at checkSourceValue (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint-module-utils/moduleVisitor.js:29:5) at checkSource (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint-module-utils/moduleVisitor.js:34:5) at listeners.(anonymous function).forEach.listener (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint/lib/util/safe-emitter.js:45:58) at Array.forEach (<anonymous>) at Object.emit (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint/lib/util/safe-emitter.js:45:38) at NodeEventGenerator.applySelector (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint/lib/util/node-event-generator.js:251:26) at NodeEventGenerator.applySelectors (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint/lib/util/node-event-generator.js:280:22) at NodeEventGenerator.enterNode (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint/lib/util/node-event-generator.js:294:14) at CodePathAnalyzer.enterNode (/Users/user/Dev/FrontEnd-Dev-projects_fcc/Advanced_Front-End/react-toe/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)

Seems to be an upstream issue in eslint-plugin-import, see https://github.com/benmosher/eslint-plugin-import/issues/1322

I assume a viable workaround would be to disable this plugin's rule that throws this error for the time being, until the bug has been fixed upstream:

// .eslintrc.js
module.exports = {
  // ...stuff...
  rules: {
+    "import/no-useless-path-segments": "off",
    "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
  },
  // ..stuff....
};

Maybe the bug affects other rules as well - disable them accordingly.

I have the same bug, but I'm using React rather than Vue.

I'm going to assume you're using [email protected]? This appears to be solely related to eslint-plugin-import rather than the Airbnb config, which is what I'm using. I did the following to fix the issue;

npm install [email protected]

EDIT1: I use the Airbnb config too, and downgrading fixed the problem for me.

if anyone still curios, this helps me to get rid of this error, thanks @LinusBorg

 .eslintrc.js
module.exports = {
  rules: {
   "import/no-useless-path-segments": "off", 

This should be fixed in v2.17.1 according to
https://github.com/benmosher/eslint-plugin-import/issues/1322#issuecomment-482814429

If someone affected can confirm that reinstalling dependencies (remove lock file!) solves the issue I can close this.

Updated to vue-cli 3.6.0 . Creating new project with ESLint Airbnb config completes without errors.

Seems to be an upstream issue in eslint-plugin-import, see benmosher/eslint-plugin-import#1322

I _assume_ a viable workaround would be to disable this plugin's rule that throws this error for the time being, until the bug has been fixed upstream:

// .eslintrc.js
module.exports = {
  // ...stuff...
  rules: {
+    "import/no-useless-path-segments": "off",
    "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
  },
  // ..stuff....
};

Maybe the bug affects other rules as well - disable them accordingly.

This solution worked for me! Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings