eslint-plugin-why
Enforces adding a comment before disabling an ESLint rule.
Trying to understand why someone ignored that lint rule? Need an explanation for what the heck is going on? Add eslint-plugin-why to your codebase and make contributors tell you why:
error Expected an eslint-why comment before eslint-disable why/tell-me-why
Installation
Install the plugin
$ npm install eslint-plugin-why --save-dev
Configuration
Add the following preset to your ESLint configuration:
"extends":
But if you find it too aggressive, there's a preset that uses warnings instead of errors:
"extends":
Or you can add the rule yourself:
"rules":
Rule: why/tell-me-why
Good Examples
// eslint-why some people just want to watch the world burn// eslint-disable-next-line semi;
/* eslint-why because I like unexpected surprises*/// eslint-disable-next-line semi;
Bad Examples
No why comment:
; // eslint-disable-next-line semi;
Why comment is too far away:
// eslint-why because testing in production is the only way we do console; // eslint-disable-next-line semi;