简体   繁体   English

jshint-创建自定义警告/规则

[英]jshint - Create custom warnings/rules

Is it possible to create a custom jshint rule, add it to existing inbuilt rules, configure it (on or off) in our projects? 是否可以创建自定义jshint规则,将其添加到现有内置规则中,在我们的项目中对其进行配置(打开或关闭)?

Is jshint extendable, like how we create our own custom tasks in Grunt? jshint是否可扩展,就像我们在Grunt中创建自己的自定义任务一样?

Sometimes we need to enforce a javascript coding practice just in our environment. 有时我们仅在我们的环境中需要执行javascript编码实践。 For example, we want to enforce our developers to use Date.now() instead of Date.getTime(). 例如,我们要强制我们的开发人员使用Date.now()而不是Date.getTime()。

There's some vague reference to how to do this in the jshint-next project on GitHub, which was apparently merged back into jshint proper at some point. 在GitHub上的jshint-next项目中对如何执行此操作存在一些模糊的参考,该项目显然在某些时候已合并回jshint。

https://github.com/jshint/jshint-next/wiki/Design https://github.com/jshint/jshint-next/wiki/Design

You should consider using ESLint in that case. 在这种情况下,您应该考虑使用ESLint

Every rule is standalone. 每个规则都是独立的。 Even the default rules . 甚至是默认规则 So you could take one of the default rules as a blueprint, and write your own. 因此,您可以将默认规则之一作为蓝图,然后编写自己的规则。

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

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