prefer-stylelint-report-needless-disables
Require enabling Stylelint's reportNeedlessDisables 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 reportNeedlessDisables is:
- missing
- explicitly
false - configured as an array whose primary option is not
true
Why this rule existsโ
Stylelint can report disable comments that do not suppress any active finding. That helps teams remove stale disable comments instead of letting them accumulate as dead configuration noise.
โ Incorrectโ
export default {
rules: {
"color-no-invalid-hex": true,
},
};
โ Correctโ
export default {
reportNeedlessDisables: true,
rules: {
"color-no-invalid-hex": true,
},
};
Behavior and migration notesโ
- Missing properties are autofixed by inserting
reportNeedlessDisables: true. falsevalues are autofixed totrue.- Array-form values preserve secondary options while rewriting the primary option to
true.
Additional examplesโ
โ Correct โ keep secondary optionsโ
export default {
reportNeedlessDisables: [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 needless disable comments to remain in place without reporting.
Package documentationโ
Stylelint package documentation:
Rule catalog ID: R005