2015-09-06 33 views
3

是否有可能以某種方式使JSHint和JSCS很好地在同一下一行的內聯忽略上播放?JSHint和JSCS內聯忽略相同的下一行

我想這樣做:

/* jshint camelcase: false, jscs requireCamelCaseOrUpperCaseIdentifiers: false */ 

我試過一對夫婦的不同變化(單獨的「註釋塊」,分號中,不同的線無視之間),但couldn」讓它工作。也許我錯過了一些明顯的東西?或者它根本不可能?日Thnx。

回答

6

JSHint不允許禁止用於單線一個特定的規則,但它可以禁用所有驗證了行:

var do_something; /* jshint ignore:line */ 

對於JSCS,語法啓用/禁用單個規則像這樣:

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers 
... 
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers 

放在一起,以禁用JSHint和JSCS驗證對於特定線中,應當使用上述評論的組合:

// jscs:disable requireCamelCaseOrUpperCaseIdentifiers 
var var_name_with_underscores; /* jshint ignore:line */ 
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers 

如果塊中的多行使用非駝峯標識符(通常是規則),可能需要將整個函數包含在註釋中。

// jscs: disable requireCamelCaseOrUpperCaseIdentifiers 
/* jshint ignore:start */ 
function foo() 
{ 
    var var_name_with_underscores; 
    ... 
    var_name_with_underscores = 123; 
    ... 
} 
/* jshint ignore:end */ 
// jscs: enable requireCamelCaseOrUpperCaseIdentifiers