vscode-eslint: eslint extension keeps giving errors for a node_modules package - Failed to load config "./.config/eslint.config" to extend from

the error Error: Failed to load config "./.config/eslint.config" to extend from. is flooding the output channel, showing popups none-stop

Ive tried looking everywhere for a solution, no luck yet -/ these are my configs:

//this is a multiroot workspace
"eslint.workingDirectories": [
      {
        "directory": "client",
        "changeProcessCWD": true
      }
    ],

error output: eslinterror.txt

config file: eslintrc.txt

verbose output: verbose.txt

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

I can repro this problem at will. I removed my globally-installed ESLint and removed all ESLint settings from my user settings file, and the problem still reproes. The problem happens for me when I open a JS file in any node_modules package (let’s call it “A”) that extends from another package “B” where the “B” dependency is in devDependencies of “A”, which means that it’s not installed on my machine when I npm install A.

Even if eslint isn’t working in code in node_modules, honestly I don’t care-- because it’s not my code so I can’t fix it! Ideally, the extension would:

  • Recognize node_modules and ignore ESLint errors (both errors in the code and ESLint’s own internal failures). If that’s not possible, it’d be great to have an easy way to exclude node_modules folders from ESLint. (I’ve tried .eslintignore and haven’t found the magic content to get it to ignore node_modules)
  • Another possibility would be, instead of a modal error dialog, to have a more subtle UI to let me know that something is amiss with a particular file. The (prettier-vscode extension)[https://github.com/prettier/prettier-vscode} does this really well; when prettier is broken, its icon in the status bar changes from a checkmark to an X. Ideally, ESLint could do something similar.

Here’s repro steps:

  1. Open a new VS Code window
  2. Create a new folder
  3. Open that folder as a workspace in VS Code
  4. npm init the folder. Accept all the defaults.
  5. npm i serverless eslint
  6. In the files/folders left pane, navigate to and open this file: ./node_modules/severless/lib/Serverless.js

Expected: No modal error dialog box. Actual: ESLint: Failed to load config “@serverless/eslint-config/node” to extend from. Referenced from: /Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/serverless/package.json. Please see the ‘ESLint’ output channel for details.

Here’s the content of the output channel:

[Info  - 9:15:04 PM] ESLint server is starting
[Info  - 9:15:04 PM] ESLint server running in node v14.16.0
[Info  - 9:15:04 PM] ESLint server is running.
[Info  - 9:15:05 PM] ESLint library loaded from: /Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/eslint/lib/api.js
[Error - 9:15:05 PM] ESLint stack trace:
[Error - 9:15:05 PM] Error: Failed to load config "@serverless/eslint-config/node" to extend from.
Referenced from: /Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/serverless/package.json
    at configInvalidError (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/config-array-factory.js:290:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/config-array-factory.js:883:23)
    at ConfigArrayFactory._loadExtends (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/config-array-factory.js:781:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/config-array-factory.js:720:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/config-array-factory.js:665:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at ConfigArrayFactory.loadInDirectory (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/config-array-factory.js:511:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:379:46)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/Users/justingrant/Documents/hdev/repro/eslint-warning/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:398:20)

I’m happy to help you diagnose further-- let me know how I can help. Thanks!

@justingrant the reason why the .eslintignore file doesn’t work in this case is that the ESLint npm module reads the config before inspecting the ignore file. This is document capture in https://github.com/microsoft/vscode-eslint/issues/1238