javascript – ESLint not working in VS Code?

javascript – ESLint not working in VS Code?

If ESLint is running in the terminal but not inside VSCode, it is probably
because the extension is unable to detect both the local and the global
node_modules folders.

To verify, press Ctrl+Shift+U in VSCode to open
the Output panel after opening a JavaScript file with a known eslint issue.
If it shows Failed to load the ESLint library for the document {documentName}.js -or- if the Problems tab shows an error or a warning that
refers to eslint, then VSCode is having a problem trying to detect the path.

If yes, then set it manually by configuring the eslint.nodePath in the VSCode
settings (settings.json). Give it the full path (for example, like
eslint.nodePath: C:\Program Files\nodejs,) — using environment variables
is currently not supported.
This option has been documented at the ESLint extension page.

In my case, since I was using TypeScript with React, the fix was simply to tell ESLint to also validate these files. This needs to go in your user settings:

eslint.validate: [ javascript, javascriptreact, html, typescriptreact ],

javascript – ESLint not working in VS Code?

configuring working directories solved it for me, since I had multiple projects with own .eslintrc files openend in the same window.

Put this in your .vscode/settings.json

eslint.workingDirectories: [

thanks to this guy on github:

PS: useful command to list all subdirectories containing an .eslintrc except /node_modules:

find . .eslintrc | grep .eslintrc | grep -v node_modules

Leave a Reply

Your email address will not be published.