Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coleturner/eslint-plugin-why
Enforces adding a comment before disabling an ESLint rule
https://github.com/coleturner/eslint-plugin-why
Last synced: about 2 months ago
JSON representation
Enforces adding a comment before disabling an ESLint rule
- Host: GitHub
- URL: https://github.com/coleturner/eslint-plugin-why
- Owner: coleturner
- License: mit
- Created: 2019-03-05T01:12:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T17:16:54.000Z (over 1 year ago)
- Last Synced: 2024-07-10T18:50:57.793Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.19 MB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.**
![demo](./demo.png)
**So you don't have to ask why later:**
![demo](./demo-fix.png)
# Installation
Install the plugin
```sh
$ npm install eslint-plugin-why --save-dev
```# Configuration
Add the following preset to your ESLint configuration:
```json
"extends": [
"plugin:why/error"
]
```But if you find it too aggressive, there's a preset that uses warnings instead of errors:
```json
"extends": [
"plugin:why/warning"
]
```Or you can add the rule yourself:
```json
"rules": {
"why/tell-me-why": "error"
}
```## Rule: why/tell-me-why
![fun gif](./dont-open-this.gif)
### Good Examples
```js
// eslint-why some people just want to watch the world burn
// eslint-disable-next-line semi
someCodeHere();
``````js
/*
eslint-why
because I like unexpected surprises
*/
// eslint-disable-next-line semi
someCodeHere();
```### Bad Examples
No why comment:
```js
someCodeHere();// eslint-disable-next-line semi
someCodeThere();
```Why comment is too far away:
```js
// eslint-why because testing in production is the only way we doconsole.log("I like turtles");
// eslint-disable-next-line semi
someCodeHere();
```Why comment is empty:
```js
// eslint-why
// eslint-disable-next-line semi
someCodeHere();
```Savage attempt to disable the why rule:
```js
// eslint-disable-next-line why/tell-me-why
// eslint-disable-next-line semi
someCodeHere();
```## Contributors
- [Cole Turner](https://github.com/coleturner)