Back to Biomejs

useSingleJsDocAsterisk

src/content/docs/linter/rules/use-single-js-doc-asterisk.mdx

latest8.1 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/correctness/useSingleJsDocAsterisk`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`jsdoc/no-multi-asterisks`](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-multi-asterisks.md)

How to configure

json
{
	"linter": {
		"rules": {
			"correctness": {
				"useSingleJsDocAsterisk": "error"
			}
		}
	}
}

Description

Enforce JSDoc comment lines to start with a single asterisk, except for the first one.

This rule ensures that every line in a JSDoc block, except the opening one, starts with exactly one asterisk (*). Extra asterisks are unnecessary in JSDoc comments and are often introduced by mistake.

Double asterisks (**) are still allowed, because they mark the start of bold text.

Examples

Invalid

js
/**
** Description
*/
<pre class="language-text"><code class="language-text">code-block.js:2:1 <a href="https://biomejs.dev/linter/rules/use-single-js-doc-asterisk">lint/correctness/useSingleJsDocAsterisk</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">JSDoc comment line should start with a single asterisk.</span> <strong>1 │ </strong>/&#42;&#42; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong>&#42;&#42; Description <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><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>3 │ </strong>&#42;/ <strong>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">In JSDoc comments, extra asterisks beyond the first are unnecessary and are often added by mistake.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Remove additional asterisks.</span> <strong> 2 │ </strong>&#42;<span style="color: Tomato;">&#42;</span><span style="opacity: 0.8;">·</span>Description <strong> │ </strong> <span style="color: Tomato;">-</span> </code></pre>
js
/**
* Description
* */
<pre class="language-text"><code class="language-text">code-block.js:3:1 <a href="https://biomejs.dev/linter/rules/use-single-js-doc-asterisk">lint/correctness/useSingleJsDocAsterisk</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">JSDoc comment line should end with a single asterisk.</span> <strong>1 │ </strong>/&#42;&#42; <strong>2 │ </strong>&#42; Description <strong><span style="color: Tomato;">&gt;</span></strong> <strong>3 │ </strong>&#42; &#42;/ <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>4 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">In JSDoc comments, extra asterisks beyond the first are unnecessary and are often added by mistake.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Remove additional asterisks.</span> <strong> 3 │ </strong>&#42;<span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">&#42;</span>/ <strong> │ </strong> <span style="color: Tomato;">-</span><span style="color: Tomato;">-</span> </code></pre>
js
/** @ts-ignore **/
<pre class="language-text"><code class="language-text">code-block.js:1:1 <a href="https://biomejs.dev/linter/rules/use-single-js-doc-asterisk">lint/correctness/useSingleJsDocAsterisk</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">JSDoc comment line should end with a single asterisk.</span> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>/&#42;&#42; @ts-ignore &#42;&#42;/ <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><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;">In JSDoc comments, extra asterisks beyond the first are unnecessary and are often added by mistake.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Remove additional asterisks.</span> <strong> 1 │ </strong>/&#42;&#42;<span style="opacity: 0.8;">·</span>@ts-ignore<span style="opacity: 0.8;">·</span>&#42;<span style="color: Tomato;">&#42;</span>/ <strong> │ </strong> <span style="color: Tomato;">-</span> </code></pre>

Valid

js
/**
 * Description
 * @public
 */
js
/** @ts-ignore */
js
/**
 * **Bold** text
 */
</TabItem> </Tabs>