如何在 Visual Studio 2017 中禁用 JavaScript 构建错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42724820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable JavaScript build error in Visual Studio 2017?
提问by Mohammad Dayyan
I just updated Visual Studio 2017 from RC to final. I didn't get the following error but recently I get this error. In building the project, I get the following error and it prevents the web project to start:
我刚刚将 Visual Studio 2017 从 RC 更新为最终版本。我没有收到以下错误,但最近我收到了这个错误。在构建项目时,我收到以下错误并阻止 Web 项目启动:
Severity Code Description Project File Line Suppression State
Error eqeqeq (ESLint) Expected '===' and instead saw '=='. VistaBest.Shop.Web C:\***\Request.js 21
How can I disable JavaScript building error in Visual Studio 2017?
如何在 Visual Studio 2017 中禁用 JavaScript 构建错误?
回答by Mohammad Dayyan
I think, find the solution:
我想,找到解决办法:
- Open
Tools > Options - Navigate to
Text Editor > JavaScript/TypeScript > EsLint(in VS2017 15.8 it isLintingnotEsLint) - Set
Enable ESLinttoFalse
- 打开
Tools > Options - 导航到
Text Editor > JavaScript/TypeScript > EsLint(在 VS2017 15.8 中Linting不是EsLint) - 设置
Enable ESLint为False
回答by Brad
In Visual Studio 2017 (v 15.8.0):
在 Visual Studio 2017 (v 15.8.0) 中:
Option 1: Options > JS Errors
选项 1:选项 > JS 错误
- Open
Tools > Options - Navigate to
Text Editor > JavaScript/TypeScript > Code Validation - Set
Enable JavaScript errorstofalse - or, set
Enable JavaScript errorstotrueandShow errors as warningstotrue
- 打开
Tools > Options - 导航
Text Editor > JavaScript/TypeScript > Code Validation - 设置
Enable JavaScript errors为false - 或者,设置
Enable JavaScript errors要true和Show errors as warnings到true
I needed to restart Visual Studio for this to take effect.
我需要重新启动 Visual Studio 才能生效。
Option 2: Options > Linting
选项 2:选项 > Linting
There is another option below which will let you edit your global linting settings:
下面还有另一个选项可让您编辑全局 linting 设置:
Option 3: .eslint file
选项 3:.eslint 文件
You can also create a file named .eslintrcin the root of your project.
您还可以创建一个.eslintrc在项目根目录中命名的文件。
Option 4: ESLint commands in-file
选项 4:文件中的 ESLint 命令
Resources
资源
回答by Rafael dos Santos
I tried Mohammad`s solution but it didn't work. I managed to work doing the following:
我尝试了穆罕默德的解决方案,但没有奏效。我设法完成了以下工作:
- Righ click on your web .csproj file
- On the first
<PropertyGroup>add the following entry:<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
- 右键单击您的 Web .csproj 文件
- 在第一个
<PropertyGroup>添加以下条目:<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
回答by user9153924
Add /*eslint eqeqeq: ["error", "smart"]*/to the first line of your Javascript code to remove the errors.
https://eslint.org/docs/rules/eqeqeq
添加/*eslint eqeqeq: ["error", "smart"]*/到您的 Javascript 代码的第一行以删除错误。
https://eslint.org/docs/rules/eqeqeq
Following Mohammad's solution will turn off ESLint for syntax checking. This works in VS2015 and should work in later versions.
遵循 Mohammad 的解决方案将关闭 ESLint 进行语法检查。这适用于 VS2015,应该适用于更高版本。
回答by Nilachal Sethi
回答by cjl
I've just had to change the "eqeqeq"rule behaviour to include "smart":
我只需要更改“eqeqeq”规则行为以包含“smart”:
Edit the .eslintrc file found in your user root folder mentioned in other answers already.
编辑在其他答案中提到的用户根文件夹中找到的 .eslintrc 文件。
The change is made to the rulessection by adding the smart rule
通过添加智能规则对规则部分进行了更改
"rules": {
"eqeqeq": [2, "smart"],
Copied from the web article:This option enforces the use of === and !== except for these cases:
复制自网络文章:此选项强制使用 === 和 !== 除了这些情况:
- Comparing two literal values
- Evaluating the value of typeof
- Comparing against null
- 比较两个文字值
- 评估 typeof 的值
- 与 null 比较
I found the specifics at: https://eslint.org/docs/2.0.0/rules/eqeqeq
我在以下位置找到了详细信息:https: //eslint.org/docs/2.0.0/rules/eqeqeq
回答by SilentCoder
I tried Mohammad's solution but with no luck, I followed Rafeel answer and instead of adding his suggested code sample I removed below code from web .csprojand finally I was able to build and run my project. There were two places where you should remove that in the same file. Still, I don't have any clue how the removed code will affect my solution.
我尝试了 Mohammad 的解决方案,但没有运气,我遵循了 Rafeel 的回答,而不是添加他建议的代码示例,而是从中删除了以下代码web .csproj,最后我能够构建和运行我的项目。有两个地方你应该在同一个文件中删除它。不过,我不知道删除的代码将如何影响我的解决方案。
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
Hope this will also help someone to save the day..!!!
希望这也能帮助某人挽救这一天..!!!


