本文介绍了ESLint支持Visual Studio 2017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ESlint静态intellisense似乎在Visual Studio 2017中不受支持,这使.js文件中的编码变得很痛苦,因为我必须运行CMD eslint命令来获取任何掉毛错误.在VSCode中,我可以只使用ESLint扩展.那么Visual Studio 2017呢?

ESlint static intellisense doesn't seem to be supported in Visual Studio 2017 which makes coding in .js files a complete pain as I have to run the CMD eslint command to get any linting errors. In VSCode I can just use the ESLint extension. What about Visual studio 2017?

他们有什么办法可以启用它吗?

Is their any way I can enable it?

推荐答案

如何使ESLint在Visual Studio 2019和2017中工作:

2019 v16& 2017> = v15.8

最后我已经包含了先前的版本说明,但是如果您想使用此功能,请帮个忙并进行升级.

How to Get ESLint Working in Visual Studio 2019 and 2017:

2019 v16 & 2017 >= v15.8

I've included the previous version instructions at the end, but do yourself a favor and upgrade if you want this feature.

从菜单中:工具>选项>文字编辑器> Javascript/Typescript>棉绒

From the menu: Tools > Options > Text Editor > Javascript/Typescript > Linting

检查Enable Eslint

global-in-visual-studio .eslintrc文件以及其他Visual Studio配置位于您的根用户目录(Windows 10)中.您仍然可以通过npm install eslint -g在计算机上安装eslint. VS不会使用它.它带有react插件,但是您可以安装其他插件,它们将起作用.您可以在项目中正常扩展配置( eslint ref )

The global-in-visual-studio .eslintrc file is at your root user directory (Windows 10) along with other visual studio configs. You could still have eslint installed via npm install eslint -g on your machine. VS won't use it. It comes with the react plugin, but you can install other plugins and they'll will work. You can extend configs normally in your project (eslint ref)

它使用Eslint v4,但符合.到MS文档,

It uses Eslint v4 but acc. to MS docs,


2017 v.15.7

从菜单中:工具->选项->文字编辑器-> Javascript/Typescript将Enable Eslint设置为 True (如果尚未安装)


2017 v.15.7

From the menu: Tools --> Options --> Text Editor --> Javascript/TypescriptSet Enable Eslint to True (if it's not already)

然后从主菜单中:工具->网络代码分析->编辑ESLint设置

Then from the main menu: Tools --> Web Code Analysis --> Edit ESLint Settings

您必须保存.eslintrcyour.js文件,规则才能生效.键入时可能有一种启用智能感知的方法,但我还没有找到.我发现如果在Visual Studio已经开始整理后更新规则,则必须重新启动项目以使新规则生效.仍然很笨拙,但是这是快速实现编码标准的好方法,特别是当您将其与文本编辑器格式匹配并在保存插件上使用自动格式时,例如这一个

You will have to save the .eslintrc and your.js file for the rules to take effect. There might be a way to enable the intellisense as you type, but I haven't found it. I found that if I update the rules after visual studio has already begin linting, I have to restart the project for the new rule to take effect. Still clunky but this is a great way to quickly implement a coding standard especially when you match it with your text editor format and use an auto-format on save plugin like this one

只要记住以找到的ESLint 2.0.0格式编辑.eslintrc文件,此处

Just remember to edit the .eslintrc file in the ESLint 2.0.0 format found here

这篇关于ESLint支持Visual Studio 2017的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 17:12