Skip to main content

prefer-stylelint-report-descriptionless-disables

Require enabling Stylelint's reportDescriptionlessDisables config option in 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 when reportDescriptionlessDisables is:

  • missing
  • explicitly false
  • configured as an array whose primary option is not true

Why this rule existsโ€‹

Stylelint already ships a built-in config option for reporting disable comments that do not explain why a rule was turned off.

Enabling that option improves review quality because disable comments stop being silent escapes with no context.

โŒ Incorrectโ€‹

export default {
rules: {
"color-no-invalid-hex": true,
},
};

โœ… Correctโ€‹

export default {
reportDescriptionlessDisables: true,
rules: {
"color-no-invalid-hex": true,
},
};

Behavior and migration notesโ€‹

  • Missing properties are autofixed by inserting reportDescriptionlessDisables: true.
  • false values are autofixed to true.
  • Array-form values preserve the secondary options object while rewriting the primary option to true.

Additional examplesโ€‹

โœ… Correct โ€” keep secondary optionsโ€‹

export default {
reportDescriptionlessDisables: [true, { 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 allows undocumented Stylelint disable comments and does not want Stylelint to report them.

Package documentationโ€‹

Stylelint package documentation:

Rule catalog ID: R003

Further readingโ€‹