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.
stylelint
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.
Terminal
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
// .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).
Related guides
ESLint "Command failed with exit code 1" on lint errors in CIFix ESLint exiting with code 1 in CI - ESLint returns a non-zero exit when any error-level rule is violated,…
Prettier "Code style issues found" with --check in CIFix Prettier "[warn] Code style issues found in the above file(s). Run Prettier with --write to fix." in CI -…
ruff check exits 1 on lint violations in CIFix ruff check failing in CI - ruff exits 1 when it finds lint violations, printing "Found N errors" and the…