简体   繁体   English

如何从自定义报告程序获取JsHint版本

[英]How to get JsHint version from a custom reporter

Each custom reporter in JsHint receives 3 arguments : results, data, and options . JsHint中的每个自定义报告程序都接收3个参数: results, data, and options

I'd like to be able to display the current JsHint version in the output generated by the reporter but it doesn't seem to be provided by any of the variables described above. 我希望能够在报告程序生成的输出中显示当前的JsHint版本,但上述任何变量似乎都无法提供该版本。

Am I missing something obvious, or is there another way to grab it? 我是否缺少明显的东西,或者还有另一种方法来抓住它?

Use a function property to store the version: 使用函数属性存储版本:

reporter.version = "1.2.3";

then add a reference to it in the reporter source: 然后在报告源中添加对它的引用:

console.log(reporter.version ? "JSHint version: " + reporter.version + "\n" : "" + str + "\n" + len + ' error' + ((len === 1) ? '' : 's'));

References 参考文献

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

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