microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.73k stars 335 forks source link

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

Closed nbaleli-w closed 3 years ago

nbaleli-w commented 3 years ago

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

dbaeumer commented 3 years ago

@nbaleli-w does the validation happen correctly when you use eslint in the terminal. If this is the case can you please provide me with a GitHub repository I can clone that demos what you are experiencing.

nbaleli-w commented 3 years ago

@dbaeumer thanks for your help. this issue is actually exactly the same as this one: https://github.com/microsoft/vscode-eslint/issues/974

dbaeumer commented 3 years ago

@nbaleli-w thanks. Can you provide me with a GitHub repository I can clone that demos what you are experiencing.

nbaleli-w commented 3 years ago

@dbaeumer unfortunately for me I was unable to reproduce this in a fresh repo. If I ever succeed Ill repoen this, thank you.

nbaleli-w commented 3 years ago

Ive managed to create a repo for reproduction https://github.com/NitsanBaleli/eslint-vscode-repro-test

thus Im reopening this sue, thank you

dbaeumer commented 3 years ago

@nbaleli-w thanks for the repository. I am not able to reproduce this. Can you provide me with concrete steps

capture
nbaleli-w commented 3 years ago

@dbaeumer really no special steps, as soon as I open the VScode window of that workspace, this is what I see when I open the ESLint panel:

image

dbaeumer commented 3 years ago

Here is what I see:

capture
dbaeumer commented 3 years ago

Do you open a folder or the workspace file?

nbaleli-w commented 3 years ago

@dbaeumer no special workspace settings (empty workspace settings file)

it is opened as a directory, not a workspace.

any additional info I can add here ?

Version: 1.54.0-insider
Commit: e590188f17162393f50feec19263398e6fe02d13
Date: 2021-02-26T20:32:11.854Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 4.15.0-135-generic
dbaeumer commented 3 years ago

Can't reproduce even if I open the folder (e.g. the repository root I cloned),

capture
nbaleli-w commented 3 years ago

I guess this is a local issue? Ill close it for now, maybe some one else will come up with the same issue and we will be able to find the cause

thanks for you time, @dbaeumer!

alesmenzel commented 3 years ago

Hi @nbaleli-w , did you manage to somehow fix the issue? I have started seeing the exact same issue and according to searching through issues here on GitHub I am not the only one. The issue is kind of annoying one, because vscode keeps showing notifications about this every few minutes.

Here is the output I see in vscode for eslint (The project was shortend to <project> for readability)

[Error - 3:57:47 PM] Error: Failed to load config "./.config/eslint.config" to extend from.
Referenced from: <project>/node_modules/@popperjs/core/package.json
    at configInvalidError (<project>/node_modules/@eslint/eslintrc/lib/config-array-factory.js:290:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (<project>/node_modules/@eslint/eslintrc/lib/config-array-factory.js:883:23)
    at ConfigArrayFactory._loadExtends (<project>/node_modules/@eslint/eslintrc/lib/config-array-factory.js:781:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (<project>/node_modules/@eslint/eslintrc/lib/config-array-factory.js:720:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (<project>/node_modules/@eslint/eslintrc/lib/config-array-factory.js:665:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at ConfigArrayFactory.loadInDirectory (<project>/node_modules/@eslint/eslintrc/lib/config-array-factory.js:511:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (<project>/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:379:46)
    at CascadingConfigArrayFactory._loadConfigInAncestors (<project>/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:398:20)

I am running on latest vscode, latest eslint + ts.

nbaleli-w commented 3 years ago

I ended up doing a full wipe of vscode, and slowly putting my settings back. I didnt have an issue since

On Sun, Jul 18, 2021, 17:03 Aleš Menzel @.***> wrote:

Hi @nbaleli-w https://github.com/nbaleli-w , did you manage to somehow fix the issue? I have started seeing the exact same issue and according to searching through issues here on GitHub I am not the only one. The issue is kind of annoying one, because vscode keeps showing notifications about this every few minutes.

Here is the output I see in vscode for eslint (The project was shortend to

for readability) [Error - 3:57:47 PM] Error: Failed to load config "./.config/eslint.config" to extend from. Referenced from: ***@***.***/core/package.json at configInvalidError ***@***.***/eslintrc/lib/config-array-factory.js:290:9) at ConfigArrayFactory._loadExtendedShareableConfig ***@***.***/eslintrc/lib/config-array-factory.js:883:23) at ConfigArrayFactory._loadExtends ***@***.***/eslintrc/lib/config-array-factory.js:781:25) at ConfigArrayFactory._normalizeObjectConfigDataBody ***@***.***/eslintrc/lib/config-array-factory.js:720:25) at _normalizeObjectConfigDataBody.next () at ConfigArrayFactory._normalizeObjectConfigData ***@***.***/eslintrc/lib/config-array-factory.js:665:20) at _normalizeObjectConfigData.next () at ConfigArrayFactory.loadInDirectory ***@***.***/eslintrc/lib/config-array-factory.js:511:28) at CascadingConfigArrayFactory._loadConfigInAncestors ***@***.***/eslintrc/lib/cascading-config-array-factory.js:379:46) at CascadingConfigArrayFactory._loadConfigInAncestors ***@***.***/eslintrc/lib/cascading-config-array-factory.js:398:20) I am running on latest vscode, latest eslint + ts. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or unsubscribe .
justingrant commented 3 years ago

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:

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!

dbaeumer commented 3 years ago

It is hard for the extension to decide which files to ignore and I stayed away from hardcoding any paths. If you run ESLint in the terminal you get the same:

./node_modules/.bin/eslint ./node_modules/serverless/lib/serverless-error.js

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find the config "@serverless/eslint-config/node" to extend from. Please check that the name of the config is correct.

The config "@serverless/eslint-config/node" was referenced from the config file in "/home/dirkb/Projects/playgrounds/1182/node_modules/serverless/package.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

The extension does respect .eslintignore files on all levels. So adding one to the root and add node_modules make the error go away.

justingrant commented 3 years ago

The extension does respect .eslintignore files on all levels. So adding one to the root and add node_modules make the error go away.

I just added a one-line .eslintignore file to root of the folder created in the repro above, but I still see the error dialog. Here's the contents.

node_modules

Is this correct? If so, can you repro the dialog on your end too?

dbaeumer commented 3 years ago

You can test the .eslintignore file using ESLint on the command line. Does it work there?

justingrant commented 3 years ago

If I run only eslint --ext .js "./**/*" from the command line, no errors are reported. (I had to add an index.js in my root directory to avoid the no-files-linted warning.) However, if I run eslint node_modules/serverless/lib/Serverless.js (which is what I assume that VSCode is doing) then I get the same warning as I see in the UI.

The problem seems to be that .eslintignore is itself ignored when you provide a specific filename (not a glob pattern) to ESLint. When you're running ESLint from the command line, this seems like appropriate behavior. But when the IDE is running ESLint on my behalf, it's frustrating to see a modal error dialog over code that's not mine and that I can't fix.

I just published a repo that shows the two cases:

Instead of the current IDE behavior, I'd expect to see:

If the user wants to see details behind problems, they can click the status bar to get taken to the output pane to see details.

justingrant commented 3 years ago

I realized that my last point above wasn't specific to this problem but was a more general complaint about how errors are reported by the extension, so I moved it to a new issue #1322.

dbaeumer commented 3 years ago

@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