问题描述
我们在Visual Studio 2013解决方案中使用JSHint。在构建时,我们看到一些格式警告,用于破坏样式警告但在功能上有效的项目。具体来说,我想压制非法空间的警告。我在构建错误列表中考虑这样的警告视觉瑕疵:
We're using JSHint in a Visual Studio 2013 solution. When building, we are seeing some formatting warnings for items that break style warnings, but are functionally valid. Specifically, I would like to suppress the "Illegal Space" warnings. I consider warnings like this in the build error list visual chaff:
- JSCS:打开大括号之前的非法空间
- JSCS:非常空格
开盘前支撑
这就是原因。我喜欢使用Visual Studio自动格式化功能(Ctrl + K + D)。在函数定义如下的场景中......
Here's why. I'm a fan of using the Visual Studio auto-formatting feature (Ctrl+K+D). In a scenario where a function is defined as follows...
$select.find('option').each(function(){
...自动格式化功能会将其更改为:
... the auto formatting feature will change it to this:
$select.find('option').each(function () {
JSHint对于发现其他问题很有价值,比如丢失分号,所以我更喜欢在这个项目中继续使用它。通过Web Essentials> Edit Global有一个设置文件JSHint设置。但我不清楚我需要调整该文件中的哪个设置来抑制那些非法空间警告。
JSHint is valuable for finding other problems, like missing semicolons, so I'd prefer to continue using it in this project. There is a settings file via Web Essentials > Edit Global JSHint Settings. But it's unclear to me what setting in that file I need to adjust to suppress those Illegal Space warnings.
=== Update 4/6/2015 == =
=== Update 4/6/2015 ===
根据以下Mike C的建议,我申请的修复方法如下:
Based on the recommendation from Mike C below, the fix I applied is as follows:
- 选择Web Essentials>编辑全局JSCS设置。
- 在.jscsrc文件中搜索这些字符串,并将其相关属性设置为false:RoundBrace,CurlyBrace 。
- 关闭并使用您的解决方案重新打开Visual Studio 2013.
- 重建并且这些警告将消失。
- Select Web Essentials > Edit global JSCS Settings.
- Search for these strings in the .jscsrc file, and set their related properties to false: "RoundBrace", "CurlyBrace".
- Close and reopen Visual Studio 2013 with your solution.
- Rebuild and those warnings will disappear.
推荐答案
这不是JSHint错误,而是JSCS错误。在Web Essentials菜单下,单击编辑全局JSCS设置(.jscsrc)...
。查找 requireSpacesInAnonymousFunctionExpression
并将 beforeOpeningRoundBrace
更改为 false
。
That isn't a JSHint error, it's a JSCS error. Under the Web Essentials menu click Edit global JSCS settings (.jscsrc)...
. Look for requireSpacesInAnonymousFunctionExpression
and change beforeOpeningRoundBrace
to false
.
有关列表,请参阅此所有规则及其价值。
See this JSCS reference for a list of all of the rules and their values.
这篇关于我怎样才能压制JSHint“JSCS:Illegal Space” Visual Studio 2013中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!