4

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.
fernandopasik
  • 9,565
  • 7
  • 48
  • 55
Ken Palmer
  • 2,355
  • 5
  • 37
  • 57

1 Answers1

4

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.

Mike Cluck
  • 31,869
  • 13
  • 80
  • 91
  • Thanks Mike. Changing that didn't affect the build notifications for me. For instance, this line of script was flagged with a "JSCS: Illegal space before opening round brace" warning. showStatusChangeAlert = function (externalUserID, action) – Ken Palmer Apr 06 '15 at 17:18
  • Oh, I see other references to "beforeOpeningRoundBrace" in that file. I'll flag them to false and see what happens... – Ken Palmer Apr 06 '15 at 17:19
  • Thanks @RafaelXavier. Updated the link. – Mike Cluck Jul 06 '15 at 16:02