Back to Biomejs

noDuplicateFontNames

src/content/docs/linter/rules/no-duplicate-font-names.mdx

latest8.5 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="CSS" icon="seti:css"> ## Summary - Rule available since: `v1.8.0` - Diagnostic Category: [`lint/suspicious/noDuplicateFontNames`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`font-family-no-duplicate-names`](https://github.com/stylelint/stylelint/blob/main/lib/rules/font-family-no-duplicate-names/README.md)

How to configure

json
{
	"linter": {
		"rules": {
			"suspicious": {
				"noDuplicateFontNames": "error"
			}
		}
	}
}

Description

Disallow duplicate names within font families.

This rule checks the font and font-family properties for duplicate font names.

This rule ignores var(--custom-property) variable syntaxes now.

Examples

Invalid

css
a { font-family: "Lucida Grande", 'Arial', sans-serif, sans-serif; }
<pre class="language-text"><code class="language-text">code-block.css:1:56 <a href="https://biomejs.dev/linter/rules/no-font-family-duplicate-names">lint/suspicious/noDuplicateFontNames</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Duplicate font names are redundant and unnecessary: </span><span style="color: Tomato;"><strong>sans-serif</strong></span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; font-family: &quot;Lucida Grande&quot;, 'Arial', sans-serif, sans-serif; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This is where the duplicate font name is found:</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; font-family: &quot;Lucida Grande&quot;, 'Arial', sans-serif, sans-serif; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Remove duplicate font names within the property.</span> </code></pre>
css
a { font-family: 'Arial', "Lucida Grande", Arial, sans-serif; }
<pre class="language-text"><code class="language-text">code-block.css:1:44 <a href="https://biomejs.dev/linter/rules/no-font-family-duplicate-names">lint/suspicious/noDuplicateFontNames</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Duplicate font names are redundant and unnecessary: </span><span style="color: Tomato;"><strong>Arial</strong></span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; font-family: 'Arial', &quot;Lucida Grande&quot;, Arial, sans-serif; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This is where the duplicate font name is found:</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; font-family: 'Arial', &quot;Lucida Grande&quot;, Arial, sans-serif; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Remove duplicate font names within the property.</span> </code></pre>
css
a { FONT: italic 300 16px/30px Arial, " Arial", serif; }
<pre class="language-text"><code class="language-text">code-block.css:1:39 <a href="https://biomejs.dev/linter/rules/no-font-family-duplicate-names">lint/suspicious/noDuplicateFontNames</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">Duplicate font names are redundant and unnecessary: </span><span style="color: Tomato;"><strong>&quot; Arial&quot;</strong></span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; FONT: italic 300 16px/30px Arial, &quot; Arial&quot;, serif; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This is where the duplicate font name is found:</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a &#123; FONT: italic 300 16px/30px Arial, &quot; Arial&quot;, serif; &#125; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Remove duplicate font names within the property.</span> </code></pre>

Valid

css
a { font-family: "Lucida Grande", "Arial", sans-serif; }
b { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif; }
c { font-family: SF Mono, Liberation Mono, sans-serif; }
d { font: 1em SF Mono, Liberation Mono, sans-serif; }
</TabItem> </Tabs>