Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/privatenumber/eslint-plugin-fix-later
ESLint plugin to suppresses ESLint errors as warnings for future resolution
https://github.com/privatenumber/eslint-plugin-fix-later
errors eslint fix later plugin suppress warnings
Last synced: about 2 months ago
JSON representation
ESLint plugin to suppresses ESLint errors as warnings for future resolution
- Host: GitHub
- URL: https://github.com/privatenumber/eslint-plugin-fix-later
- Owner: privatenumber
- Created: 2024-01-13T08:22:45.000Z (11 months ago)
- Default Branch: develop
- Last Pushed: 2024-08-17T10:57:58.000Z (4 months ago)
- Last Synced: 2024-10-19T01:11:25.398Z (2 months ago)
- Topics: errors, eslint, fix, later, plugin, suppress, warnings
- Language: TypeScript
- Homepage:
- Size: 126 KB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 📌 eslint-plugin-fix-later
This plugin automatically suppresses ESLint errors with "fix later" comments, turning them into warnings for future resolution.
Before
After auto-fix
```js
console.log(data)
```❌ **Error** `no-console Unexpected console statement`
```js
// eslint-disable-next-line no-console -- Fix later
console.log(data)
```⚠️ **Warning** `[REMINDER] Fix later`
> [!TIP]
> Use the `git blame` feature documented below to tag the author in the "fix later" comment.## Why?
In large projects with many developers, ESLint helps keep code consistent and high-quality. But, updating the ESLint config with new rules can be challenging when it surfaces many new errors. This would be too much for one dev to fix, and potentially risky if it's outside of their familiarity.
This plugin solves this by temporarily suppressing these errors into "fix later" warnings, allowing the right dev to address them when ready. This keeps the project moving forward without sacrificing code quality.
## Install
```
pnpm i -D eslint-plugin-fix-later
```## Setup
In your ESLint config:
```json5
{
plugins: [
// ...
'fix-later',
],
rules: {
// ...
'fix-later/fix-later': ['warn', {
// Options...
}]
}
}
```### Recommended workflow
1. **Activate this plugin**
Set up the `fix-later` rule to emit a _warning_ (as opposed to `errors`).
2. **Automate linting on commit**
Use [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks) & [lint-staged](https://github.com/lint-staged/lint-staged) to auto-lint changed files when committing
3. **Disallow linting warnings on commit**
Configure your commit hook to reject warnings: `eslint --max-warnings=0`
This encourages devs working in the file to address outstanding warnings if they can. If not, they can commit with `--no-verify`.
4. **Disallow linting errors on CI**
On CI, run ESLint with warnings allowed: `eslint .`
This approach prevents errors from slipping through while accommodating "fix later" notes.
### Suppressing auto-fixable errors (ESLint v8+)
Pass in the [`--fix-type=directive`](https://eslint.org/docs/latest/use/command-line-interface#--fix-type) flag to ESLint to only apply the fix-later auto-fix.
## Options
### includeWarnings
Type: `boolean`
Default: `false`
Whether to suppress warnings in addition to errors.
### insertDisableComment
Type: `'above-line' | 'end-of-line'`
Default: `'end-of-line'`
Whether to put the `eslint-disable` comment on the same line or on the line above.
### commentTemplate
Type: string
Default: `'Fix later'`
The template for the `eslint-disable` comment. The `{{ eslint-disable }}` handlebar is required to interpolate the `eslint-disable` type into.
#### Git blame
You can get the `git blame` author of the errorneous code:
```
Please fix: {{ blame.author }} <{{ blame.author-mail }}>
```Which will create the following comment:
```
// eslint-disable-line -- Please fix: John Doe
```All properties from `git blame` are available:
```json5
{
"author": "John Doe",
"author-mail": "[email protected]",
"author-time": "1708498454",
"author-tz": "+0100",
"committer": "John Doe",
"committer-mail": "",
"committer-time": "1708498454",
"committer-tz": "+0100"
}
```#### CODEOWNER
You can get the [CODEOWNER](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) of the file:
```
Please fix: {{ codeowner }}
```