ESLint 支持 Visual Studio 2017 [英] ESLint support Visual studio 2017

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

问题描述

Visual Studio 2017 似乎不支持 ESlint 静态智能感知,这使得在 .js 文件中编码非常痛苦,因为我必须运行 CMD eslint 命令来获取任何 linting 错误.在 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/打字稿 >掉毛

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

勾选启用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,但是acc.到 MS 文档,

It uses Eslint v4 but acc. to MS docs,

如果你的项目在本地安装了 ESLint,它将使用那个版本

if your project has a local installation of ESLint, it will use that version instead


2017 v.15.7

从菜单:工具 -->选项 -->文本编辑器 -->Javascript/打字稿将启用 Eslint 设置为 True(如果尚未启用)

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

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

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

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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