With ESLint 10 bulk suppressions, why does a run exit with code 2 after someone fixes a suppressed violation, and what happens when one more is added?
answer
- a count, not a location
- fewer than recorded means stale
- more than recorded means all reported
- exit 2 before the error count
- prune, or pass on unpruned
basics
~20 seslint-suppressions.json stores a count per file and rule. Fewer violations than recorded leaves a stale entry, so ESLint exits 2 until --prune-suppressions; more than recorded and every violation of that rule in that file is reported.
solid answer
~40 sBulk suppressions record how many error-level violations of each rule each file had, not where they were. On every run ESLint compares the current count with the recorded one, file by file and rule by rule. If the current count is lower, because someone fixed one, the leftover entry is unused: ESLint prints "There are suppressions left that do not occur anymore" and exits with code 2, even when there are no lint errors. Running `eslint --prune-suppressions` lowers or removes those entries and the updated file is committed; `--pass-on-unpruned-suppressions` instead lets the run ignore them. If the current count is higher, nothing for that rule in that file is suppressed: a fifth `==` in a file with four recorded makes all five `eqeqeq` errors appear, because ESLint cannot tell which one is new.
go deeper
Recall that the suppressions file stores counts, and that fixing a suppressed violation means updating the file with --prune-suppressions.
Explain the comparison: equal or fewer violations are hidden, more means all are reported, and fewer leaves stale entries.
Diagnose exit 2 versus exit 1 on a run with suppressions, and choose between pruning in the same change and passing on unpruned entries.
Decide which jobs fail on stale entries and which pass on them, so cleanup is enforced without blocking unrelated work.
## What ESLint compares on every run An `eslint-suppressions.json` file, created with `--suppress-all` or `--suppress-rule` (introduced in ESLint 9.24.0), maps each file path to the rules suppressed in it and a **count** of error-level violations. There are no line numbers. On each run, for every file that was linted and has an entry, ESLint counts that file's current error-level violations per rule and compares: | Current violations vs. recorded count | What ESLint does | |---|---| | Equal | All of that rule's violations in the file are hidden | | Fewer | All are hidden, and the difference is recorded as an **unused** suppression | | More | **None** are hidden: every violation of that rule in that file is reported | | Rule has no violations left | The whole entry is unused | Warnings are never counted, and files the run did not lint are not compared at all. ## Why a fix makes the run exit with 2 Say `src/guide/epg-grid.js` has `"eqeqeq": { "count": 4 }` and a developer fixes one comparison. Three violations remain, all hidden, and one suppression is now unused. ESLint then: 1. prints "There are suppressions left that do not occur anymore", followed by advice to re-run with `--prune-suppressions` or use `--pass-on-unpruned-suppressions`; 2. returns **exit code 2**, the code ESLint otherwise uses for configuration problems and internal errors, not the 1 that lint errors produce; 3. does this check before it looks at the error count, so a run with both lint errors and unused suppressions still exits with 2. The point of failing is to keep the file honest: an entry that is allowed to stay at four would quietly let a new violation back in later. ## Clearing it - `eslint --prune-suppressions` lowers the count to the current number or removes the entry, then the developer commits the smaller file in the same pull request as the fix. - Since ESLint 9.29.0, pruning also drops entries for files that no longer exist. - `eslint --pass-on-unpruned-suppressions` leaves the file alone and lets unused entries stop affecting the exit code; it suits a job that should not fail for cleanup the author has not done yet. - `--prune-suppressions` cannot be combined with `--suppress-all` or `--suppress-rule`. ## Why one new violation surfaces all of them Because the file stores only a number, ESLint cannot tell which of five `==` comparisons is the new one. So when the current count exceeds the recorded count, it hides none of them and reports all five as errors. That is surprising the first time, and it is deliberate: - the developer touching the file sees the whole debt for that rule, not just the new line; - the run fails with exit code 1, the ordinary lint-error result; - the fix is either to remove the new violation, which brings the count back to four, or to fix enough of the old ones to go below it and then prune. Re-running `--suppress-rule eqeqeq` to record five would also silence the failure, but it re-freezes the new violation, which defeats the purpose. ## A worked timeline 1. Monday: `eslint --fix --suppress-rule eqeqeq` records `count: 4` for `src/guide/epg-grid.js`; the file is committed and every run passes. 2. Tuesday: a developer fixes one comparison. The run exits with 2 and the "do not occur anymore" message. They run `--prune-suppressions`, the count drops to 3, and both changes ship in one commit. 3. Wednesday: another developer adds a new `==` to the same file. Four violations now exceed the recorded three, so all four are reported and the run exits with 1. 4. They replace the new comparison with `===`, the count is back at three, and the run passes again. ## Diagnosing a red run - **Exit 2 with the "do not occur anymore" message**: someone fixed suppressed violations; prune and commit. - **Exit 1 with old violations in one file**: that file gained a violation of a suppressed rule; find the new one. - **Exit 1 with old violations everywhere**: the run is not reading the file, often a moved file without `--suppressions-location` or a different working directory.
- A run lints only three files named on the command line. Can it fail on unused suppressions recorded for other files?No. ESLint compares counts only for files it linted in that run, so entries for unstaged files are not checked. A full run over the repository, typically in CI, is what catches every stale entry.
- Why not just re-run `--suppress-rule eqeqeq` when a file goes from four violations to five?It would record five and turn the run green, but the new violation would then be frozen like the old ones. The intended path is to remove the new violation so the count returns to four, or fix older ones and prune.
Like a cloakroom ledger that records only how many coats each guest left, not which ones: if a guest collects more than the ledger shows, the attendant checks every coat; if fewer come back, the ledger is wrong and must be corrected before the evening closes.
- Expects only the one new violation to be reported when a suppressed file gains one
- Thinks the suppressions file records line numbers for each violation
- Says unused suppressions only produce a warning with exit code 0
- Re-runs --suppress-rule to silence a newly added violation
- Believes lint errors take precedence over unused suppressions in the exit code
Assumes ESLint 10; bulk suppressions arrived in ESLint 9.24.0, --pass-on-unpruned-suppressions in 9.28.0, and pruning of entries for deleted files in 9.29.0.