This plugin automatically suppresses ESLint errors with "fix later" comments, turning them into warnings for future resolution.
| Before | After auto-fix |
|---|---|
console.log(data)
❌ Error |
// eslint-disable-next-line no-console -- Fix later
console.log(data)
|
Tip
Use the git blame feature documented below to tag the author in the "fix later" comment.
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.
pnpm i -D eslint-plugin-fix-later
In your ESLint config:
{
plugins: [
// ...
'fix-later',
],
rules: {
// ...
'fix-later/fix-later': ['warn', {
// Options...
}]
}
}-
Activate this plugin
Set up the
fix-laterrule 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=0This 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.
Pass in the --fix-type=directive flag to ESLint to only apply the fix-later auto-fix.
Type: boolean
Default: false
Whether to suppress warnings in addition to errors.
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.
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.
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 <john@doe.org>
All properties from git blame are available:
{
"author": "John Doe",
"author-mail": "john@doe.org",
"author-time": "1708498454",
"author-tz": "+0100",
"committer": "John Doe",
"committer-mail": "<john@doe.org>",
"committer-time": "1708498454",
"committer-tz": "+0100"
}You can get the CODEOWNER of the file:
Please fix: {{ codeowner }}