Skip to main content

no-duplicate-src-format

Disallow duplicate explicit format() hints within a single @font-face src declaration.

Rule catalog ID: R024

Targeted pattern scopeโ€‹

  • Explicit format(...) hints within @font-face src declarations.

What this rule reportsโ€‹

  • @font-face src lists where the same format hint string appears more than once (for example two separate format("woff2") entries).

Why this rule existsโ€‹

Browsers select a font source by scanning the src list from left to right and downloading the first entry whose format they support. Once a browser finds a matching format and begins downloading, it stops evaluating the rest of the list. Any subsequent entry with the same format hint is unreachable โ€” the browser will never fetch it.

Duplicate format hints are therefore always a bug: either a copy-paste error that left a stale entry, or an accidental duplication during a refactor. The dead entry increases stylesheet bytes and misleads readers about the intended source list structure.

โŒ Incorrectโ€‹

/* Two woff2 entries โ€” browser stops at the first one and never fetches the second */
@font-face {
font-family: "Inter";
src:
url("./inter-subset-latin.woff2") format("woff2"),
url("./inter-subset-ext.woff2") format("woff2");
}
/* Accidentally duplicated during a woff2-only migration */
@font-face {
font-family: "Roboto";
src:
url("./roboto.woff2") format("woff2"),
url("./roboto-fallback.woff2") format("woff2"),
url("./roboto.woff") format("woff");
}

โœ… Correctโ€‹

/* Each format appears at most once */
@font-face {
font-family: "Inter";
src:
url("./inter.woff2") format("woff2"),
url("./inter.woff") format("woff");
}

When not to use itโ€‹

If your build tool intentionally emits multiple source entries with the same format (for example for A/B CDN redundancy using a custom browser-extension mechanism), disable this rule for the generated file.

Further readingโ€‹