Getting Started
This guide gets you from zero to a production-safe baseline quickly.
Prerequisitesโ
- ESLint with Flat Config
- Stylelint installed in the same project
- A stylelint config file (for example
stylelint.config.mjs)
Step 1: Install dependenciesโ
npm install --save-dev eslint-plugin-stylelint-2 stylelint
Step 2: Start with one presetโ
Pick one adoption mode:
- Bridge only (just run Stylelint from ESLint):
stylelintOnly - Bridge + config quality (recommended for teams):
recommended
Example eslint.config.mjs:
import stylelint2 from "eslint-plugin-stylelint-2";
export default [
stylelint2.configs.recommended,
{
rules: {
// Optional: tune bridge behavior here.
"stylelint2/stylelint": "error",
},
},
];
Step 3: Run lint once and apply fixesโ
npx eslint . --fix
Review the PR diff and categorize findings:
- Safe autofixes (accept immediately)
- Configuration cleanups (plan staged rollout)
- Actual style violations (fix or suppress with rationale)
Step 4: Configure the bridge rule intentionallyโ
If your project needs custom syntax or special file matching, tune the stylelint rule.
Typical options include:
customSyntaxconfigFileconfigBasedirquietallowEmptyInput
Step 5: Roll out in phasesโ
Recommended rollout model:
- Enable preset + run in CI as warning-only (short period)
- Resolve baseline issues
- Switch to error-level enforcement
- Add stricter config-authoring rules over time
Common rollout mistakesโ
- Enabling
allimmediately: high noise and slower adoption - Mixing Stylelint CLI and ESLint bridge outputs in the same CI gate without clear ownership
- Skipping autofix pass before triage
Where to go nextโ
- Architecture and behavior: Stylelint Bridge
- Team standards and config conventions: Config Authoring
- Preset details: Preset Reference
- Common troubleshooting: FAQ