简体   繁体   English

JSHint和JSCS内联忽略了相同的下一行

[英]JSHint and JSCS inline ignore for the same next line

Is it possible to somehow make JSHint and JSCS play along nicely on inline ignore for the same next line? 是否有可能以某种方式使JSHint和JSCS在同一下一行的内联忽略上很好地发挥作用?

I would like to do something like: 我想做的事情如下:

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

I tried a couple of different variations of that (separate "comment blocks", semi-colon in between, different lines for ignore), but couldn't make it work. 我尝试了几种不同的变体(单独的“注释块”,中间用分号,忽略不同的行),但无法使其工作。 Perhaps I'm missing something obvious? 也许我错过了一些明显的东西? Or is it simply not possible? 或者它根本不可能? Thnx. 日Thnx。

JSHint doesn't allow disabling a specific rule for a single line, but it is possible to disable all validations for a line: JSHint不允许为单行禁用特定规则,但可以禁用行的所有验证:

var do_something; /* jshint ignore:line */

For JSCS, the syntax to enable/disable a single rule is like this: 对于JSCS,启用/禁用单个规则的语法如下:

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

Put together, to disable both JSHint and JSCS validation for a particular line, one would use a combination of the comments above: 综合起来,要禁用特定行的JSHint和JSCS验证,可以使用上述注释的组合:

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

If the non-camelcase identifier is used in multiple lines inside a block (as is normally the rule), it may be necessary to enclose the whole function in comments. 如果在块内的多行中使用非camelcase标识符(通常是规则),则可能需要将整个函数括在注释中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM