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

options.overrideConfigFile looks in subfolder if eslint.config.mjs and linted file are in the same directory #1966

Open
SedrickHeiniger opened this issue Jan 7, 2025 · 4 comments
Labels
info-needed Issue requires more information from poster

Comments

@SedrickHeiniger
Copy link

SedrickHeiniger commented Jan 7, 2025

Summary

The issue in a short sentence:

If "options.overrideConfigFile": "./config/eslint.config.mjs" a linted file at ${workspaceFolder}/config/someFile.mjs looks in ${workspaceFolder}/config/config/eslint.config.mjs for a config file.

Some Points to Mention

  • This happens if the eslint.config.mjs and someFile.mjs are in the same directory.
  • It also happens if eslint.config.mjs has nothing except export default {} in it (tested).
  • It doesn't happen if you put the absolute path to the eslint.config.mjs into options.overrideConfigFile (in settings.json) (tested).

Currently I've just moved my eslint.config.mjs to my root because of this.

Thank you so much for fixing this! (If I'm not the one doing something wrong 🙂).

Reproducing this Bug

Setup:

eslint.config.mjs:

export default {};

settings.json (Snippet)

"eslint.options": {
    "overrideConfigFile": "config/eslint.config.mjs",
  },

File System: (eslint.config.mjs and dev-server.mjs are both in ${workspaceFolder}/config/)

Output:

When updating settings.json ESLint will start linting and you'll get the following error in the ESLint console in the VS Code "output" panel.

[Error - 3:47:18 PM] Calculating config file for file:///c%3A/Users/sedri/OneDrive/Desktop/Projects/WebAppDevelopment/HelloWorld/config/dev-server.mjs) failed.
Error: ENOENT: no such file or directory, stat 'C:\Users\sedri\OneDrive\Desktop\Projects\WebAppDevelopment\HelloWorld\config\config\eslint.config.mjs'
@SedrickHeiniger SedrickHeiniger changed the title If path in options.overrideConfigFile a linted file at cwd/config/a.txt looks for cwd/config/conig/a.txt for a file. options.overrideConfigFile in settings.json looks for subfolder if config file and linted file are in the same directory Jan 7, 2025
@SedrickHeiniger SedrickHeiniger changed the title options.overrideConfigFile in settings.json looks for subfolder if config file and linted file are in the same directory options.overrideConfigFile looks in subfolder if config file and linted file are in the same directory Jan 7, 2025
@SedrickHeiniger SedrickHeiniger changed the title options.overrideConfigFile looks in subfolder if config file and linted file are in the same directory options.overrideConfigFile looks in subfolder if eslint.config.mjs and linted file are in the same directory Jan 7, 2025
@dbaeumer
Copy link
Member

dbaeumer commented Jan 9, 2025

@SedrickHeiniger does the same happen when you lint the file in the terminal specify the config file as a command line option. If so, can you please provide me with a GitHub repository I can clone with a minimal setup that demos what you are seeing. Thanks!

@dbaeumer dbaeumer closed this as completed Jan 9, 2025
@dbaeumer dbaeumer reopened this Jan 9, 2025
@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jan 9, 2025
@SedrickHeiniger
Copy link
Author

@dbaeumer When moving eslint.config.mjs back to the config directory and then running npx eslint -c config/eslint.config.mjs . everything works fine.

@dbaeumer
Copy link
Member

So., can you please provide me with a GitHub repository I can clone with a minimal setup that demos what you are seeing. Thanks

@SedrickHeiniger
Copy link
Author

@dbaeumer Well, I've just made a new minimal project and there everything worked as it should. Then I've uncommented my old ESLint extensions settings in my actual project for reproducing the bug and now this also works fine! 🙂

I'm new in software development and not very experienced. Maybe (hopefully) I've just made a stupid mistake. I'm not able to reproduce it anymore so I think you can close this issue. I'll make a new issue if it should happen again.

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

2 participants