noRestrictedElements (HTML)
Summary
Section titled “Summary”- Diagnostic Category:
lint/correctness/noRestrictedElements - 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.
- Sources:
- Inspired from
vue/no-restricted-html-elements - Inspired from
svelte/no-restricted-html-elements
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "correctness": { "noRestrictedElements": "error" } } }}Description
Section titled “Description”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.
Options
Section titled “Options”elements
Section titled “elements”A map of element names to the message to show when the element is used. Defaults to no restricted elements.
{ "linter": { "rules": { "correctness": { "noRestrictedElements": { "level": "on", "options": { "elements": { "marquee": "Use CSS animations instead.", "RouterLink": "Use NuxtLink instead." } } } } } }}Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.