简体   繁体   English

同时使用JSLint和JSHint

[英]Using both JSLint and JSHint

The project I joined is using JSLint and JSHint at the same time. 我加入的项目是同时使用JSLint和JSHint。 They're launched for the same files, with a unique grunt task. 它们针对相同的文件启动,并且具有独特的grunt任务。 My understanding is that one could use one of them, but when using both of them there's an overlap on the analysis and the checks made. 我的理解是,一个人可以使用其中之一,但是当同时使用它们时,在分析和检查方面存在重叠。

Is it reasonable to use both of them in the same project ? 在同一项目中使用它们是否合理?

JSHint started life as a fork of JSLint. JSHint最初是JSLint的分支。 It retains much of the same functionality, to the point you can configure it to behave almost exactly as JSLint does. 它保留了许多相同的功能,以至于您可以将其配置为几乎与JSLint一样。

A few warnings from JSLint have been removed from JSHint, but these tend to be ones that give little benefit to you. JSLint的一些警告已从JSHint中删除,但是这些警告对您几乎没有好处。 Off the top of my head, one of these warnings is " Unexpected 'else' after disruption ", which warns you that you have a redundant else block following a return or throw statement: 在我脑海中,这些警告之一是“ 中断后出现意外的'else' ”,它警告您在returnthrow语句之后存在多余的else块:

if (x) {
    return y;
} else { // This `else` block is unnecessary
    return z;
}

It is reasonable to use both JSLint and JSHint if you need to cover situations like this. 如果您需要涵盖此类情况,则可以同时使用JSLint和JSHint。 But on the whole, it is usually possible to configure JSHint to cover all situations you are concerned about. 但是总的来说,通常可以将JSHint配置为涵盖您所关注的所有情况。

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

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