Skip to content
Latchkey

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)

  1. Run stylelint "**/*.css" --fix to auto-correct fixable rules.
  2. Resolve the remaining problems using the rule names.
  3. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →