eslint-plugin-fix-later
v2.1.0
Published
ESLint plugin to suppresses ESLint errors as warnings for future resolution
Downloads
38
Maintainers
Readme
📌 eslint-plugin-fix-later
This plugin automatically suppresses ESLint errors with "fix later" comments, turning them into warnings for future resolution.
console.log(data)
❌ Error no-console Unexpected console statement
// 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:
{
plugins: [
// ...
'fix-later',
],
rules: {
// ...
'fix-later/fix-later': ['warn', {
// Options...
}]
}
}
Recommended workflow
Activate this plugin
Set up the
fix-later
rule to emit a warning (as opposed toerrors
).Automate linting on commit
Use simple-git-hooks & lint-staged to auto-lint changed files when committing
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
.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
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 <[email protected]>
All properties from git blame
are available:
{
"author": "John Doe",
"author-mail": "[email protected]",
"author-time": "1708498454",
"author-tz": "+0100",
"committer": "John Doe",
"committer-mail": "<[email protected]>",
"committer-time": "1708498454",
"committer-tz": "+0100"
}
CODEOWNER
You can get the CODEOWNER of the file:
Please fix: {{ codeowner }}