使用自定义检查扩展jshint

使用自定义检查扩展jshint

本文介绍了使用自定义检查扩展jshint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python世界中,有多个静态代码分析工具可以通过编写插件或扩展轻松扩展自定义检查,例如:

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

在JavaScript世界中,据我所知, jshint 是静态代码分析的头号工具。我已经使用了一段时间,它肯定有助于找到许多代码风格违规,但是,最近,我遇到了需要使用自定义扩展 jshint 校验。我怎样才能做到这一点?它是可扩展的吗?

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.

作为解决方法,我想我可以分析,执行检查,并使用项目中的fork保持上游的更新。

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.

推荐答案

JSHint Google小组讨论了创建自定义JSHint规则的能力,但在17个月内没有活动。您此时唯一使用的是ESLint。 ESLint是使用创建的,其中每个都是JSHint规则可插拔,我认为目前每个JSHint规则都可以在中找到。

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.

这篇关于使用自定义检查扩展jshint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 17:38