The solution is to define an overrideConfigFile option to point to the location of the ESLint configuration file in the workspace in the settings.json like so:
{
"eslint.options": { "overrideConfigFile": "./path/to/eslint.config.js" }
}
Since ESLint v8.x, the ESLint extension in VSCode uses the ESLint Class API to "[...] configure how ESLint is started". The extension documents that "[...] to point to a custom .eslintrc.json file using the new ESLint API" is as shown above.
For good measure, since the configuration file used is the new flat config file, the eslint.useFlatConfig setting can also be explicitly set to true. In the settings.json:
{
"eslint.useFlatConfig": true
}
Since version 3.0.5 of the extension, the activation of this setting works like this:
- 8.57.0 <= ESLint version < 9.x: setting is honored and defaults to false.
- 9.0.0 <= ESLint version < 10.x: settings is honored and defaults to true.
Videos
It was a node version issue. My distro only distributes the latest version of node. I've done the following for the errors to correct themselves.
- Installed NVM
Set the version of node to
10.10.0$ nvm install 10.10.0 $ nvm use 10.10.0Inside the
home/user/'Code - OSS'/User/settings.jsonfile, added the following field to theJSONsettings:{ ... "eslint.runtime": "/home/user/.nvm/versions/node/v10.10.0/bin/node" // This should be the path to the node runtime set by nvm }After saving and restarting VSCode the errors were gone and ESLint is working correctly now.
NOTE: Check which version your system is using with nvm ls command. The output should look something like this
$ nvm ls
v6.14.4
-> v10.10.0
v10.20.0
v12.16.2
default -> 10.10.0 (-> v10.10.0)
node -> stable (-> v12.16.2) (default)
stable -> 12.16 (-> v12.16.2) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.16.2)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.20.0
lts/erbium -> v12.16.2
Thank you for the help everyone. Sorry if the question did not give more relevant details as I did not have any clue on where the problem may lay, so I asked for assistance from a good friend who's experienced.
I used this video while installing ESlint on my VS Code a while back.
Maybe it can be an issue with version, and you can check the best version that worked from here.