I'm having trouble getting ESLint to lint my JavaScript files in my IDE. The setup I have done is to install eslint locally via npm and create an eslint config file that is then stored in a config directory. Running eslint from the mand line works fine, but when I create an error in a JavaScript file no red squiggly is showing up.
Here are the versions I am running:
- VSCode 1.86.2
- Node V20.12.2
- NPM 10.5.0
- eslint 9.3.0
- eslint VSCode Extension 2.4.4
Here is my file structure:
/backend
/config
eslint.config.mjs
package.json
/frontend
/config
eslint.config.mjs
package.json
Furthermore, I've located the eslint error in the output console within VSCode. It appears that the function locateConfigFileToUse
within eslint.js tries to find my config file and does not succeed. I've not had luck finding any answers online and have tried moving the eslint config file to the root, but still was same error. Any help is much appreciated. Thank you.
Here is the error I receive in my VSCode "Output":
[Error - 9:25:13 AM] Error: Could not find config file.
at locateConfigFileToUse (C:\Users\user\Desktop\project\backend\node_modules\eslint\lib\eslint\eslint.js:349:21)
at async calculateConfigArray (C:\Users\user\Desktop\project\backend\node_modules\eslint\lib\eslint\eslint.js:385:49)
at async ESLint.lintText (C:\Users\user\Desktop\project\backend\node_modules\eslint\lib\eslint\eslint.js:1023:25)
at async c:\Users\user\.vscode\extensions\dbaeumer.vscode-eslint-2.4.4\server\out\eslintServer.js:1:24954
at async E (c:\Users\user\.vscode\extensions\dbaeumer.vscode-eslint-2.4.4\server\out\eslintServer.js:1:19114)
at async c:\Users\user\.vscode\extensions\dbaeumer.vscode-eslint-2.4.4\server\out\eslintServer.js:1:220290
I'm having trouble getting ESLint to lint my JavaScript files in my IDE. The setup I have done is to install eslint locally via npm and create an eslint config file that is then stored in a config directory. Running eslint from the mand line works fine, but when I create an error in a JavaScript file no red squiggly is showing up.
Here are the versions I am running:
- VSCode 1.86.2
- Node V20.12.2
- NPM 10.5.0
- eslint 9.3.0
- eslint VSCode Extension 2.4.4
Here is my file structure:
/backend
/config
eslint.config.mjs
package.json
/frontend
/config
eslint.config.mjs
package.json
Furthermore, I've located the eslint error in the output console within VSCode. It appears that the function locateConfigFileToUse
within eslint.js tries to find my config file and does not succeed. I've not had luck finding any answers online and have tried moving the eslint config file to the root, but still was same error. Any help is much appreciated. Thank you.
Here is the error I receive in my VSCode "Output":
[Error - 9:25:13 AM] Error: Could not find config file.
at locateConfigFileToUse (C:\Users\user\Desktop\project\backend\node_modules\eslint\lib\eslint\eslint.js:349:21)
at async calculateConfigArray (C:\Users\user\Desktop\project\backend\node_modules\eslint\lib\eslint\eslint.js:385:49)
at async ESLint.lintText (C:\Users\user\Desktop\project\backend\node_modules\eslint\lib\eslint\eslint.js:1023:25)
at async c:\Users\user\.vscode\extensions\dbaeumer.vscode-eslint-2.4.4\server\out\eslintServer.js:1:24954
at async E (c:\Users\user\.vscode\extensions\dbaeumer.vscode-eslint-2.4.4\server\out\eslintServer.js:1:19114)
at async c:\Users\user\.vscode\extensions\dbaeumer.vscode-eslint-2.4.4\server\out\eslintServer.js:1:220290
Share
Improve this question
asked May 29, 2024 at 15:56
Code-Cody-418Code-Cody-418
1211 gold badge1 silver badge7 bronze badges
3
-
1
Your ESLint config file should be in the root of your project, keeping it in a subfolder will not work. Once you move it, try restarting your VSCode window, if you're getting the same exact error it must be because the extension is not trying to reload the config. If that doesn't work, try updating your extension to
3.0.5
since it seems to be working better with eslint 9. – moonstar-x Commented May 29, 2024 at 16:52 - Perfect worked like a charm. I did have to do both the Extension upgrade and moving the config to the same directory of the package.json. Version 2.4.4 of the extension was not working. Much appreciation for the help. – Code-Cody-418 Commented May 29, 2024 at 17:20
- 13 this error appeared out of blue in a long-time existing project after the latest eslint extension update – sKopheK Commented Jun 17, 2024 at 16:00
2 Answers
Reset to default 12I ran into this error when upgrading from eslint 8 to 9. I was able to resolve this error by migrating from the deprecated flat file config to the new format.
There's an automated tool for migrating configuration that worked perfectly for me.
If you've recently upgraded from eslint 8.x to 9.x and you haven't changed your config file structure, then you will need to
Instruct each project to use the old config file structure by specifying
ESLINT_USE_FLAT_CONFIG=false
when you run lint. When you make your mand in your package.json file, say something like"lint": "ESLINT_USE_FLAT_CONFIG=false TIMING=1 eslint ."
.Additionally, you will also need to tell the VSCode plugin to use the old structure! You can do this in the VSCode settings.json file by adding
"eslint.useFlatConfig": false
Check here for which esLint versions default to which settings, but basically anything in version 9.x will default to useFlatConfig:true, and if you haven't changed all those files, you will need to run in useFlatConfig:false until you do.