ESLint warn severities and the CI --max-warnings gate: advisory alerts or errors-only policy?
0 reputation · 22 Apr 2021, 23:43 UTC
0 reputation · 22 Apr 2021, 23:43 UTC
ESLint documents three per-rule severities — off, warn, and error — set in eslint.config.js (flat config, the default in ESLint v9+) or a legacy .eslintrc file. The intent is that error fails the run while warn surfaces advisory findings, letting teams introduce new or stylistic rules without breaking existing code.
The friction sits between the two integrations consuming these severities. Editor extensions such as the VS Code ESLint extension render warn inline in the same squiggle channel as error, so a large warning backlog can become visual noise that developers learn to dismiss. In CI, the documented --max-warnings flag makes the process exit non-zero once total warnings exceed a threshold, but the count spans all linted files, so one noisy generated or vendored file can trip the gate unless excluded through ignores.
That leaves a policy decision ESLint itself does not prescribe: some teams adopt an errors-only setup where every rule is either enforced or off, arguing that ungated warnings inevitably decay into ignored noise.
warn severity paired with a --max-warnings ratchet produce better long-term signal than an errors-only policy?warn to error?Use a non‑zero warning budget together with a decreasing --max-warnings threshold while keeping new rules at warn severity. This gives a visible, failing CI signal when the warning count stops improving, which an errors‑only policy cannot provide during early rollout. Switch to an errors‑only policy only when the team cannot tolerate any advisory output or when warnings are dominated by noisy generated/vendored code that cannot be ignored.
error as a failure (non‑zero exit) and warn as advisory.--max-warnings <n> makes the process exit non‑zero when the total warning count exceeds n..eslintrc the severity per rule is set via "error" or "warn" (or "off").warn with the same squiggle style as error.A non‑zero warning budget paired with a ratcheting --max-warnings limit lets teams surface new rules incrementally while still failing CI when the warning count stops decreasing. This provides a signal that an errors‑only setup would miss during the rollout phase, because errors‑only would either block the merge immediately (if set to error) or hide the rule entirely (if left off).
"warn".npx eslint . --max-warnings 0 locally, note the count, then set --max-warnings <current‑count> in CI)."error".eslintIgnore pattern for that file and recompute the budget.Only ask for the proportion of warnings coming from ignored/generated files if that proportion is high enough to make the --max-warnings gate unreliable; otherwise the above steps suffice.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.