noAstroSetHtmlDirective (HTML)
Language HTML
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noAstroSetHtmlDirective - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
astro/no-set-html-directive
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noAstroSetHtmlDirective": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>References
Section titled “References”Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.