Skip to content

Repeated classes

Toggle: enabledChecks.repeated-classes plus repeatedClasses config · Fix: autofix.repeatedClasses · Command: repeated-classes

Counts repeated static class strings within configured extensions. The safe fix can extract repeated file-local literals into CONFIG or CLASSES constants. Dynamic class expressions and cross-file design decisions stay advisory.

Configure minimumCount, extensions, and ignoredDirectories. When repetition indicates a shared UI primitive, move it into the appropriate component or design-system abstraction.

Before — the same static classes appear in several JSX nodes:

<section className="rounded-xl border p-4">A</section>
<section className="rounded-xl border p-4">B</section>
<section className="rounded-xl border p-4">C</section>

After — a supported file-local autofix adds a constant in the existing CONFIG group and references it:

const ROUNDED_XL_BORDER_P_4_CLASS = 'rounded-xl border p-4';
<section className={ROUNDED_XL_BORDER_P_4_CLASS}>A</section>
<section className={ROUNDED_XL_BORDER_P_4_CLASS}>B</section>
<section className={ROUNDED_XL_BORDER_P_4_CLASS}>C</section>