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.
Here’s what I did to customize the check report via extensions: Duplicate the Cheque_US SSRS report to a model that extends the Application Suite model. I called my new report MyCheque_US and added some text to indicate that it was the custom report—that way I could tell at a glance if I was looking at the stock report or my custom report.
In case of .jshintrc, JSHint will start looking for this file in the same directory as the file that's being linted. If not found, it will move one level up the directory tree all the way up to the filesystem root.
Trying to figure out how JSHint options work can be confusing and frustrating (and we're working on fixing that!) so please read the following couple of paragraphs carefully. JSHint has two types of options: enforcing and relaxing. The former are used to make JSHint more strict while the latter are used to suppress some warnings.
JSHint comes with a default set of warnings but it was designed to be very configurable. There are three main ways to configure your copy of JSHint: you can either specify the configuration file manually via the --config flag, use a special file.jshintrc or put your config into your projects package.json file under the jshintConfig property.
If 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 come 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With