prefer-stylelint-report-invalid-scope-disables
Require enabling Stylelint's reportInvalidScopeDisables 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 reportInvalidScopeDisables is:
- missing
- explicitly
false - configured as an array whose primary option is not
true
Why this rule existsโ
Stylelint can report disable comments that reference rules outside the active config. That catches stale or mistyped disable comments that silently stop being meaningful.
โ Incorrectโ
export default {
rules: {
"color-no-invalid-hex": true,
},
};
โ Correctโ
export default {
reportInvalidScopeDisables: true,
rules: {
"color-no-invalid-hex": true,
},
};
Behavior and migration notesโ
- Missing properties are autofixed by inserting
reportInvalidScopeDisables: 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 {
reportInvalidScopeDisables: [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 invalid-scope disable comments to pass silently.
Package documentationโ
Stylelint package documentation:
Rule catalog ID: R004