Skip to content
Latchkey

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

.stylelintrc.json
{
  "extends": ["stylelint-config-standard-scss"],
  "rules": {
    "color-no-invalid-hex": true,
    "declaration-block-no-duplicate-properties": [true, { "severity": "warning" }],
    "indentation": null
  }
}

Config keys

KeyWhat it does
extendsInherit one or more shareable configs
pluginsLoad rule packs (e.g. stylelint-scss)
rulesEnable/disable/tune individual rules
rules.<rule> severitySet "error" or "warning" per rule
overridesApply config to a file glob subset
ignoreFilesGlobs 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →