Back to Biomejs

useSymbolDescription

src/content/docs/linter/rules/use-symbol-description.mdx

latest4.8 KB
Original Source

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

<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v2.0.0` - Diagnostic Category: [`lint/style/useSymbolDescription`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`symbol-description`](https://eslint.org/docs/latest/rules/symbol-description)

How to configure

json
{
	"linter": {
		"rules": {
			"style": {
				"useSymbolDescription": "error"
			}
		}
	}
}

Description

Require a description parameter for the Symbol().

Symbol can have an optional description parameter which can be useful for debugging and making the purpose of the symbol clearer.

Examples

Invalid

js
Symbol();
<pre class="language-text"><code class="language-text">code-block.js:1:7 <a href="https://biomejs.dev/linter/rules/use-symbol-description">lint/style/useSymbolDescription</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;"><strong>Symbol()</strong></span><span style="color: lightgreen;"> is missing a description parameter.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>Symbol(); <strong> │ </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;">Add explicit description which can be useful in debugging and making the purpose of the symbol clearer.</span> </code></pre>
js
Symbol('');
<pre class="language-text"><code class="language-text">code-block.js:1:7 <a href="https://biomejs.dev/linter/rules/use-symbol-description">lint/style/useSymbolDescription</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;"><strong>Symbol()</strong></span><span style="color: lightgreen;"> is missing a description parameter.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>Symbol(''); <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>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Add explicit description which can be useful in debugging and making the purpose of the symbol clearer.</span> </code></pre>
js
 Symbol(``);
<pre class="language-text"><code class="language-text">code-block.js:1:8 <a href="https://biomejs.dev/linter/rules/use-symbol-description">lint/style/useSymbolDescription</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;"><strong>Symbol()</strong></span><span style="color: lightgreen;"> is missing a description parameter.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong> Symbol(&#96;&#96;); <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>2 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Add explicit description which can be useful in debugging and making the purpose of the symbol clearer.</span> </code></pre>

Valid

js
Symbol('description');
</TabItem> </Tabs>