问题
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:
- 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.
回答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