1.2.0 • Published 6 years ago

eslint-plugin-why v1.2.0

Weekly downloads
376
License
MIT
Repository
github
Last release
6 years ago

eslint-plugin-why

Enforces adding a comment before disabling an ESLint rule.

fun gif

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": [
    "plugin:why/error"
  ]

But if you find it too aggressive, there's a preset that uses warnings instead of errors:

  "extends": [
    "plugin:why/warning"
  ]

Or you can add the rule yourself:

  "rules": {
    "why/tell-me-why": "error"
  }

Rule: why/tell-me-why

Good Examples

// eslint-why some people just want to watch the world burn
// eslint-disable-next-line semi
someCodeHere();
/*
    eslint-why
    because I like unexpected surprises
*/
// eslint-disable-next-line semi
someCodeHere();

Bad Examples

No why comment:

someCodeHere();

// eslint-disable-next-line semi
someCodeThere();

Why comment is too far away:

// eslint-why because testing in production is the only way we do

console.log("I like turtles");

// eslint-disable-next-line semi
someCodeHere();

Contributors

1.2.0

6 years ago

1.1.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.0

6 years ago