Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nbaleli-w opened this issue Feb 15, 2021 · 21 comments
Labels
info-needed Issue requires more information from poster

Comments

@nbaleli-w
Copy link

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
Copy link
Member

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

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Feb 15, 2021
@nbaleli-w
Copy link
Author

@dbaeumer
thanks for your help.
this issue is actually exactly the same as this one: #974

@dbaeumer
Copy link
Member

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

@nbaleli-w
Copy link
Author

@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
Copy link
Author

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

thus Im reopening this sue, thank you

@nbaleli-w nbaleli-w reopened this Feb 22, 2021
@dbaeumer
Copy link
Member

dbaeumer commented Mar 1, 2021

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

capture

@nbaleli-w
Copy link
Author

@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
Copy link
Member

dbaeumer commented Mar 1, 2021

Here is what I see:

capture

@dbaeumer
Copy link
Member

dbaeumer commented Mar 1, 2021

Do you open a folder or the workspace file?

@nbaleli-w
Copy link
Author

@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
Copy link
Member

dbaeumer commented Mar 1, 2021

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

capture

@nbaleli-w
Copy link
Author

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
Copy link

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
Copy link
Author

nbaleli-w commented Jul 18, 2021 via email

@justingrant
Copy link

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!

@dbaeumer
Copy link
Member

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
Copy link

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
Copy link
Member

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

@justingrant
Copy link

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:

  • npm lint - Lints one file and shows the warning (after running npm install, of course!)
  • npm lint all - Lints a glob pattern. No warning shown.

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

  • The IDE should respect my .eslintignore and not bother linting those files when I open them in the IDE and/or there should be some VS setting I could use to exclude node_modules and other not-my-code folders from IDE linting.
  • However excluding folders works, the default should exclude node_modules because (with rare exceptions that can be worked around by customizing the ignore list) code in node_modules is someone else's code that can't be changed by the user, so notifying about problems there isn't helpful.
  • Ideally, ESLint configuration/parsing errors (anywhere, not only in ignored files) should not be reported using a modal dialog which must be manually dismissed by the user. IMHO a better UX is what the Prettier extension does which is to show status using an icon in the status bar, e.g.
    image - ignored file
    image - OK
    image - file can't be parsed

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
Copy link

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
Copy link
Member

@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 #1238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants