Skip to main content

disallow-stylelint-duplicate-rule-option-values

Disallow duplicate scalar literals in array-valued Stylelint secondary rule options.

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โ€‹

Reports duplicate scalar literals in array-valued properties inside secondary option objects.

Why this rule existsโ€‹

Duplicate option values add noise and can obscure actual rule intent during config review.

โŒ Incorrectโ€‹

export default {
rules: {
"selector-class-pattern": [
"^[a-z]+$",
{
resolveNestedSelectors: [":global", ":global", ":host"],
},
],
},
};

โœ… Correctโ€‹

export default {
rules: {
"selector-class-pattern": [
"^[a-z]+$",
{
resolveNestedSelectors: [":global", ":host"],
},
],
},
};

Behavior and migration notesโ€‹

This rule auto-fixes by keeping the first occurrence of each duplicate scalar literal value.

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 stylelint secondary option arrays intentionally include duplicate scalar values for generated-tool compatibility.

Package documentationโ€‹

Stylelint package documentation:

Rule catalog ID: R032

Further readingโ€‹