Skip to main content

disallow-stylelint-default-severity

Disallow configuring Stylelint's top-level defaultSeverity option inside authored Stylelint config files.

Targeted pattern scopeโ€‹

This rule targets Stylelint config modules such as stylelint.config.ts, stylelint.config.mjs, and .stylelintrc.js.

It focuses on top-level exported config objects, including configs wrapped in defineConfig(...).

What this rule reportsโ€‹

This rule reports Stylelint config objects that include a top-level defaultSeverity property.

Why this rule existsโ€‹

defaultSeverity applies a global warning/error policy across rules. In an ESLint-first workflow, that global Stylelint severity layer can conflict with the severity contract already defined at the ESLint rule boundary.

Keeping severity explicit per Stylelint rule (or enforced at the ESLint config layer) makes review outcomes easier to reason about and avoids hidden global severity drift.

โŒ Incorrectโ€‹

export default {
defaultSeverity: "warning",
rules: {},
};

โœ… Correctโ€‹

export default {
rules: {},
};

Behavior and migration notesโ€‹

  • This rule removes the top-level defaultSeverity property.
  • It preserves the rest of the config object.
  • If you need warning/error policy differences, keep them explicit in rule-level secondary options or the ESLint config that enables this plugin.

Additional examplesโ€‹

โœ… Correct โ€” severity stays local to a ruleโ€‹

export default {
rules: {
"number-max-precision": [2, { severity: "warning" }],
},
};

ESLint flat config exampleโ€‹

import stylelint2 from "eslint-plugin-stylelint-2";

export default [stylelint2.configs.configuration];

When not to use itโ€‹

Do not use this rule if your team intentionally enforces one global Stylelint default severity in committed config and accepts that policy being coupled to shared config files.

Package documentationโ€‹

Stylelint package documentation:

Rule catalog ID: R009

Further readingโ€‹