stylelint problems exit code 2 in CI
stylelint exits with code 2 when it finds at least one lint problem (a different code, 1, signals an internal/config error). The non-zero exit fails the CI step by design.
What this error means
The stylelint step lists file: line:col message rule-name problems and the job ends with exit code 2.
src/styles/app.css
3:3 x Expected indentation of 2 spaces indentation
8:1 x Unexpected empty block block-no-empty
Error: Process completed with exit code 2.Common causes
Real lint problems in the stylesheets
stylelint found rule violations and exits 2, which is the expected failure for lint problems.
A wider config or version surfaced new rules
Adopting a stricter shared config or upgrading stylelint enabled rules that now flag existing CSS.
How to fix it
Fix the problems (autofix where possible)
- Run
stylelint "**/*.css" --fixto auto-correct fixable rules. - Resolve the remaining problems using the rule names.
- Re-run stylelint and confirm exit 0.
npx stylelint "**/*.css" --fix
npx stylelint "**/*.css"Adjust a rule deliberately
Turn a noisy rule off or change its options in the config instead of ignoring the exit code.
// .stylelintrc.json
{ "rules": { "block-no-empty": null } }How to prevent it
- Run stylelint locally or in pre-commit before pushing.
- Pin stylelint and its config to control when new rules apply.
- Distinguish exit 2 (lint problems) from exit 1 (config/internal error).