How can I suppress the JSHint “JSCS: Illegal Space” warnings in Visual Studio 2013?

旧街凉风 提交于 2019-12-12 11:29:00

问题


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: Illegal space before opening curly brace
  • JSCS: Illegal space before opening round brace

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 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 ===

Based on the recommendation from Mike C below, the fix I applied is as follows:

  1. Select Web Essentials > Edit global JSCS Settings.
  2. Search for these strings in the .jscsrc file, and set their related properties to false: "RoundBrace", "CurlyBrace".
  3. Close and reopen Visual Studio 2013 with your solution.
  4. Rebuild and those warnings will disappear.

回答1:


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.



来源:https://stackoverflow.com/questions/29172748/how-can-i-suppress-the-jshint-jscs-illegal-space-warnings-in-visual-studio-20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!