ESLint无法在VS Code中工作吗? [英] ESLint not working in VS Code?

查看:84
本文介绍了ESLint无法在VS Code中工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ESLint在VS Code中不适用于我.我已经在VS Code中安装了插件,并且在我也已安装的package.json中将ESLint本身作为开发人员依赖项.

ESLint is not working for me in VS Code. I have the plugin installed in VS Code, and ESLint itself as a developer dependency in my package.json, which I have installed as well.

我在VS Code用户设置中修改了以下选项:

I modified the following option in the VS Code User Settings:

{
  "eslint.options": { "configFile": "C:/mypath" }
}

我已经使用命令 eslint --init 将基本的 .eslintrc.json 添加到程序包的主目录中.

I have use the command eslint --init to add the basic .eslintrc.json to the main directory of my package.

其他人能够使用具有完全相同的ESLint配置文件的完全相同的软件包从VS Code获得ESLint反馈.

Other people were able to get ESLint feedback from VS Code using the exact same package with the exact same ESLint config file.

当直接破坏推荐规则集中包含的多个规则时,我没有收到任何反馈.默认情况下,推荐规则集中在 .eslintrc.json 文件中.

I have received no feedback of any kind when directly breaking multiple rules that were all included in the recommended rule set that is by default inside of the .eslintrc.json file.

我想念什么?

我已经通过命令行使用ESLint进行了测试,并且一切都按预期工作,并且在应有的位置发现了错误,但是,这些相同的错误从未在VS Code中显示.问题似乎在VS Code一方,而不是ESLint.

I have tested using ESLint via command line, and everything worked as expected, with the errors found where they should have, however, these same errors never showed up in VS Code. The issue seems to be on VS Code's side and not ESLint.

推荐答案

出于某些原因,ESLint可能无法为您提供反馈.ESLint将首先在您的项目中寻找您的配置文件,如果找不到.eslintrc.json,它将在其中寻找全局配置.就个人而言,我仅在每个项目中安装ESLint并根据每个项目创建配置.

There are a few reasons that ESLint may not be giving you feedback. ESLint is going to look for your configuration file first in your project and if it can't find a .eslintrc.json there it will look for a global configuration. Personally, I only install ESLint in each project and create a configuration based off of each project.

没有得到反馈的第二个原因是,要获得反馈,您必须在.eslintrc.json中定义起毛规则.如果那里没有规则,或者您没有安装插件,则必须定义它们.

The second reason why you aren't getting feedback is that to get the feedback you have to define your linting rules in the .eslintrc.json. If there are no rules there, or you have no plugins installed then you have to define them.

这篇关于ESLint无法在VS Code中工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆