简体   繁体   English

如何用JSCS规则替换已弃用的JSHint选项?

[英]How to replace deprecated JSHint options with JSCS rules?

The JSHint option reference lists some options as deprecated with the following notice. JSHint选项引用列出了一些不推荐使用的选项,并附有以下通知。

Warning This option has been deprecated and will be removed in the next major release of JSHint. 警告此选项已被弃用,将在JSHint的下一个主要版本中删除。 JSHint is limiting its scope to issues of code correctness. JSHint将其范围限制为代码正确性问题。 If you would like to enforce rules relating to code style, check out the JSCS project . 如果要强制执行与代码样式相关的规则,请查看JSCS项目

Specifically, the deprecated options are: 具体而言,不推荐使用的选项是:

  • camelcase 骆驼香烟盒
  • immed IMMED
  • indent 缩进
  • maxlen MAXLEN
  • newcap newcap
  • noempty noempty
  • quotmark quotmark
  • laxbreak laxbreak
  • laxcomma laxcomma
  • multistr multistr
  • sub

Unfortunately, the reference does not indicate how to replace these deprecated options, and merely points to the JSCS GitHub repo. 遗憾的是,该引用并未指出如何替换这些已弃用的选项,而只是指向JSCS GitHub存储库。

What JSCS rules correspond to the deprecated JSHint options? JSCS规则对应于不推荐使用的JSHint选项? Are there any configuration differences to be considered when switching to JSCS? 切换到JSCS时是否有任何配置差异?

One way to determine this is to search the JSCS Github Repo for "JSHint" or the specific rule ( example search ), as the relevant rules in the JSCS docs all have links to their JSHint equivalents. 确定这一点的一种方法是在JSCS Github Repo中搜索“JSHint”或特定规则( 示例搜索 ),因为JSCS文档中的相关规则都具有指向其JSHint等效项的链接。

These are the equivalents for your short list at time of writing: 在撰写本文时,这些是您的短名单的等价物:

Though many of these rules are very similar and require little work to switch, some have slightly different options, requirements, or meaning and thus require some configuration differences, and in some cases you may need to choose between two rules ( require vs. disallow ). 虽然其中许多规则非常相似,只需要很少的工作来切换,但有些规则的选项,要求或含义略有不同,因此需要一些配置差异,在某些情况下,您可能需要在两个规则之间进行选择( requiredisallow ) 。

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

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