Home > Enterprise >  ESLint CLI not picking up all errors that VSCode plugin is highlighting
ESLint CLI not picking up all errors that VSCode plugin is highlighting

Time:11-20

I've been using eslint in VSCode and have the plugin installed also, but want to be able to lint a whole project as I added it part way into coding and want to check for errors without opening up every single file.

It's a single-root Workspace to keep the projects I'm currently working on together, but the root has folders for each project (Projects > [Project Name] > [Sub Project]). I'm only wanting to run the linter on one of the Projects at the moment, and that project is the only one with an .eslintrc.json file.

Opening individual files, the plugins flags the errors in the problem panel - one file I'm working on has 9 errors alone, however when running the CLI with either eslint . in the project directory, or ./node_modules/eslint/bin/eslint.js . brings up a total of 6 problems across the whole project. I have eslint installed both locally and globally, and I've tried uninstalling the global version to see if there was a conflict, but again I get the same output.

I've tried using the -c argument to ensure it's picking up the .eslintrc.json file, as well as forcing the local version to run (which doesn't make a difference to the output). Each time the output is the same (6 Problems (4 errors, 2 warnings)) but I know from opening single files that there are more.

Is there something obvious I'm missing to ensure that the CLI and the Plugin display the same errors when running in this configuration?

CodePudding user response:

Managed to solve this myself. When running the plugin, it lints all files that you open, however eslint by default only lints *.js files. I noticed that it seemed to be missing .jsx files from the report, and, as this was is a React project I added:

"overrides": [
    {
        "files": ["*.jsx"]
    }
]

to my .eslintrc.json file and all of the errors showed up when running eslint .

  • Related