stylelint Configuration and extends
stylelint is configured by .stylelintrc (JSON/YAML/JS) or a stylelint key in package.json, where extends pulls in a shared config and rules tunes individual checks.
A config is required; stylelint has no default rules. Most projects extend a shared config and override a handful of rules.
What it does
stylelint loads .stylelintrc.{json,yml,js,cjs}, stylelint.config.js, or the package.json stylelint key. extends inherits a base config (such as stylelint-config-standard), rules sets each check, plugins adds rule packs, and overrides scopes config by file glob.
Common usage
{
"extends": ["stylelint-config-standard-scss"],
"rules": {
"color-no-invalid-hex": true,
"declaration-block-no-duplicate-properties": [true, { "severity": "warning" }],
"indentation": null
}
}Config keys
| Key | What it does |
|---|---|
| extends | Inherit one or more shareable configs |
| plugins | Load rule packs (e.g. stylelint-scss) |
| rules | Enable/disable/tune individual rules |
| rules.<rule> severity | Set "error" or "warning" per rule |
| overrides | Apply config to a file glob subset |
| ignoreFiles | Globs to skip |
Common errors in CI
"Could not find \"stylelint-config-standard\"" means the shared config is not installed; add it to devDependencies. "Unknown rule X" means a rule name typo or a missing plugin. After a major stylelint upgrade, removed rules (like the old indentation rule) error as unknown; migrate them or move to the recommended config.