Javascript 抑制 JSHint / JSLint 或替代服务中的“混合空格和制表符”警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10286178/
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
Suppress "mixed spaces and tabs" warning in JSHint / JSLint or alternative service?
提问by Crashalot
JSHint and JSLint are awesome tools.
JSHint 和 JSLint 是很棒的工具。
However, the "mixed spaces and tabs" warning dominates the report. Is there a way to suppress these warnings, or is there a similar service that allows white space warnings to get suppressed?
但是,“混合空格和制表符”警告在报告中占主导地位。有没有办法抑制这些警告,或者是否有类似的服务可以抑制空白警告?
回答by Wilfred Hughes
It's not possible to switch off this warning with a flag, and the JSHint maintainer doesn't want to add a flag for this.
无法使用标志关闭此警告,并且JSHint 维护者不想为此添加标志。
However, it is possible to turn off warnings according to their number. In this case, you'd write:
但是,可以根据警告的数量关闭警告。在这种情况下,你会写:
/* jshint -W099 */
If you're using a JSHint configuration file, you can specify this there too:
如果您使用的是 JSHint 配置文件,您也可以在那里指定:
{
"-W099": true, // allowed mixed tabs and spaces
}
Alternatively, there's a custom reporter availableto switch off this warning.
或者,有一个自定义报告器可用于关闭此警告。
回答by Matt Ball
/*jshint smarttabs:true */
See smarttabs
, under "Relaxing Options." http://www.jshint.com/docs/options/
请参阅smarttabs
“放松选项”下的 。http://www.jshint.com/docs/options/
This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only. The technique is called SmartTabs.
当混合制表符和空格仅用于对齐时,此选项会抑制有关混合制表符和空格的警告。该技术称为SmartTabs。
回答by mikemaccana
Answer for 2014: upgrade jshintAs @RobW mentioned earlier, jshint no longer complains about mixed spaces and tabs. I have tested this by upgrading to [email protected] and re-linting my document, which no longer complains (I consistently indent using tabs, but commenting out lines in SublimeText triggered this warning).
2014 年的答案:升级 jshint正如@RobW 前面提到的,jshint不再抱怨混合空格和制表符。我已经通过升级到 [email protected] 并重新整理我的文档来测试这个,它不再抱怨(我一直使用制表符缩进,但在 SublimeText 中注释掉行触发了这个警告)。
sudo npm update -g jshint