Skip to content

noRestrictedElements (HTML)

biome.json
{
"linter": {
"rules": {
"correctness": {
"noRestrictedElements": "error"
}
}
}
}

Disallow the use of configured elements.

This rule disallows the use of configured elements in HTML, Vue, Svelte, and Astro files. Without elements configured, this rule doesn’t do anything.

This rule is useful when a project wants to enforce a component or a different element instead of certain HTML elements. For example, a project might restrict <a> in favor of a router link component that handles client-side navigation.

Native HTML, SVG, and MathML element names are matched case-insensitively, so restricting marquee also reports <MARQUEE>. Component names, such as <RouterLink> in Vue, Svelte, and Astro files, are matched exactly.

A map of element names to the message to show when the element is used. Defaults to no restricted elements.

biome.json
{
"linter": {
"rules": {
"correctness": {
"noRestrictedElements": {
"level": "on",
"options": {
"elements": {
"marquee": "Use CSS animations instead.",
"RouterLink": "Use NuxtLink instead."
}
}
}
}
}
}
}
<marquee>Breaking news</marquee>
code-block.html:1:2 lint/correctness/noRestrictedElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The marquee element is restricted in this project.

> 1 │ <marquee>Breaking news</marquee>
│ ^^^^^^^
2 │

ℹ Use CSS animations instead.

<template>
<RouterLink to="/">Home</RouterLink>
</template>
code-block.vue:2:6 lint/correctness/noRestrictedElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The RouterLink element is restricted in this project.

1 │ <template>
> 2 │ <RouterLink to="/">Home</RouterLink>
│ ^^^^^^^^^^
3 │ </template>
4 │

ℹ Use NuxtLink instead.

<template>
<p>Breaking news</p>
<NuxtLink to="/">Home</NuxtLink>
</template>