简体   繁体   English

ESLint CLI 没有发现 VSCode 插件突出显示的所有错误

[英]ESLint CLI not picking up all errors that VSCode plugin is highlighting

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.我一直在 VSCode 中使用 eslint 并且还安装了插件,但是我希望能够在将整个项目添加到编码中的一部分时对整个项目进行 lint,并且希望在不打开每个文件的情况下检查错误。

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.我现在只想在其中一个项目上运行 linter,而该项目是唯一一个带有.eslintrc.json文件的项目。

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.打开单个文件,插件会在问题面板中标记错误 - 我正在处理的一个文件单独有 9 个错误,但是当使用eslint. in the project directory, or ./node_modules/eslint/bin/eslint.js.在项目目录中,./node_modules/eslint/bin/eslint.js. brings up a total of 6 problems across the whole project.在整个项目中总共提出了 6 个问题。 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.我在本地全局都安装了 eslint,我尝试卸载全局版本以查看是否存在冲突,但我再次得到相同的 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).我尝试使用 -c 参数来确保它获取.eslintrc.json文件,并强制本地版本运行(这对输出没有影响)。 Each time the output is the same ( 6 Problems (4 errors, 2 warnings) ) but I know from opening single files that there are more.每次 output 都是相同的( 6 Problems (4 errors, 2 warnings) ),但我从打开单个文件中知道还有更多。

Is there something obvious I'm missing to ensure that the CLI and the Plugin display the same errors when running in this configuration?在此配置中运行时,我是否缺少一些明显的东西来确保 CLI 和插件显示相同的错误?

Managed to solve this myself.设法自己解决了这个问题。 When running the plugin, it lints all files that you open, however eslint by default only lints *.js files.运行插件时,它会检查您打开的所有文件,但默认情况下eslint仅检查*.js文件。 I noticed that it seemed to be missing .jsx files from the report, and, as this was is a React project I added:我注意到报告中似乎缺少.jsx文件,因为这是我添加的一个 React 项目:

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

to my .eslintrc.json file and all of the errors showed up when running eslint.到我的.eslintrc.json文件,运行eslint.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM