Skip to content

noAstroSetHtmlDirective (HTML)

Language HTML
biome.json
{
"linter": {
"rules": {
"nursery": {
"noAstroSetHtmlDirective": "error"
}
}
}
}

Disallow the use of Astro’s set:html directive.

set:html renders HTML without escaping it. Using set:html can introduce cross-site scripting vulnerabilities. When raw HTML is required, sanitize the value before passing it to set:html, then suppress the diagnostic with an explanation.

<div set:html={content} />
code-block.astro:1:6 lint/nursery/noAstroSetHtmlDirective ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The set:html directive inserts unescaped HTML.

> 1 │ <div set:html={content} />
^^^^^^^^^^^^^^^^^^
2 │

Using set:html can introduce cross-site scripting vulnerabilities.

Use a regular Astro expression to render text, or suppress this diagnostic with an explanation if raw HTML is required.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<div>{content}</div>