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.nodePath is not hornored when resolving configurations #1603

Closed
AkatQuas opened this issue Feb 9, 2023 · 6 comments
Closed

eslint.nodePath is not hornored when resolving configurations #1603

AkatQuas opened this issue Feb 9, 2023 · 6 comments
Labels
info-needed Issue requires more information from poster

Comments

@AkatQuas
Copy link

AkatQuas commented Feb 9, 2023

I have a small project using eslint and vscode-eslint .

In my case, the totally folder node_modules is located somewhere else.

|----ROOT
| |----infra
| | |----node_modules
| |----package.json
| |----.eslintrc.js
| |----src
| | |----index.js

In vscode terminal, eslint works well with NODE_PATH set.

NODE_PATH=infra/node_modules infra/node_modules/.bin/eslint src/index.js

However, eslint server starts correctly within the vscode-extension.

[Info  - 8:33:55 PM] ESLint library loaded from: /workspace/eslint-demo/infra/node_modules/eslint/lib/api.js

however, it couldn't resolve configuration well. Some logs are listed.

[Error - 8:33:55 PM] An unexpected error occurred:
[Error - 8:33:55 PM] Error: Failed to load config "semistandard" to extend from.
Referenced from: /workspace/eslint-demo/.eslintrc.js
    at configInvalidError (/workspace/eslint-demo/infra/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2627:9)

The eslintrc file is listed as the following:

module.exports = {
  extends: [
    'semistandard',
    'standard'
  ]
}

Here is my small project. You might need to move node_modules into infra folder manually.

Thanks for the help.

@MariaSolOs
Copy link
Contributor

You're using the new configuration file format, so you should set "eslint.experimental.useFlatConfig": true in your VS Code settings. You can refer to the flatConfig example in the playgrounds folder.

@AkatQuas
Copy link
Author

Thank you @MariaSolOs . It might be a solution, however it's not possible to extend some predefined configs with flatConfig. Much more work should be done if we turn into using flat eslint.

I'm still on my way to sort it out.

@dbaeumer
Copy link
Member

The underlying reason for this is very likely the working directory used for the ESLint server when starting it. For security reason this is NOT the workspace folder but the installation directory of VS Code. Since you have relative paths in NODE_PATH they are very likely not resolved correctly. Can you give it a try and use absolute paths and see if this would make it work.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Feb 13, 2023
@dbaeumer
Copy link
Member

See also #1602

@AkatQuas
Copy link
Author

It doesn't go well with absolute paths.

In my case, the eslint server does start correctly, but it failed to resolve the configurations.

@AkatQuas
Copy link
Author

I create a phantom node_modules folder which symlink back to infra/node_modules. And the extension works well.

Thanks for helping.

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

3 participants