admin管理员组文章数量:1319471
In the Python world there are multiple static code analysis tools that can be easily extended with custom checks via writing plugins or extensions, for example:
pylint
flake8
In the JavaScript world, as far as I understand, jshint
is the number one tool for static code analysis. I've been using it for a while and it definitely helps to find lots of code style violations, but, recently, I've encountered the need to extend jshint
with a custom check. How can I do that? Is it extendable?
I've looked through the documentation and the only thing I've found is how to write a custom reporter which is not what I'm looking for.
As a workaround, I guess I can fork the jshint
repo, implement the check, and use the fork in the project maintaining updates from the upstream.
In the Python world there are multiple static code analysis tools that can be easily extended with custom checks via writing plugins or extensions, for example:
pylint
flake8
In the JavaScript world, as far as I understand, jshint
is the number one tool for static code analysis. I've been using it for a while and it definitely helps to find lots of code style violations, but, recently, I've encountered the need to extend jshint
with a custom check. How can I do that? Is it extendable?
I've looked through the documentation and the only thing I've found is how to write a custom reporter which is not what I'm looking for.
As a workaround, I guess I can fork the jshint
repo, implement the check, and use the fork in the project maintaining updates from the upstream.
- Of course, you can also fork it, add your check and create a pull request if you think it's a generally worthy check. :) – Ingo Bürk Commented Dec 7, 2014 at 10:36
2 Answers
Reset to default 7 +100If I were you I would try to use something like ESLint. The ES stands for ECMAScript, which is where the rules for the JS language e from. Every single rule in ESLint is standalone (so you can use what you like), and you can use the default rules as a guideline or skeleton to create your own rule and plug it in.
Try ESLint.
The ability to create custom JSHint rules has been discussed on the JSHint Google group, but that thread has had no activity in 17 months. Your only at this time is to use ESLint. ESLint was created with the explicit purpose of making each of the JSHint rules pluggable, and I think at this time, every JSHint rules is available in ESLint.
本文标签: javascriptExtending jshint with custom checksStack Overflow
版权声明:本文标题:javascript - Extending jshint with custom checks - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742060321a2418544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论