Skip to content

noVueContentOutsideBlock (HTML)

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

Disallow content outside of the top-level blocks in Vue components.

A Vue component file is made of top-level blocks, such as <template>, <script>, <style>, and custom blocks like <docs>. Vue only reads what is inside these blocks and drops everything between them. Text or code placed outside of a block never renders or runs, so it is usually a leftover or a mistake.

HTML comments outside of the blocks are allowed.

<template>
<div>Hello</div>
</template>
console.log("hello");
<script>
export default {};
</script>
code-block.vue:5:1 lint/nursery/noVueContentOutsideBlock  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This content is outside of the top-level blocks.

3 │ </template>
4 │
> 5 │ console.log("hello");
│ ^^^^^^^^^^^^^^^^^^^^^
6 │
7 │ <script>

ℹ Vue only reads the top-level blocks of a component, such as <template>, <script>, and <style>. Anything outside of them is dropped, so it never renders or runs.

ℹ Move this content into a block, or remove it.

ℹ 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.

ℹ Unsafe fix: Remove the content outside of the top-level blocks.

2 2 │ <div>Hello</div>
3 3 │ </template>
4 │ -
5 │ - console.log("hello");
6 4 │
7 5 │ <script>

<!-- A comment between the blocks -->
<template>
<div>Hello</div>
</template>
<script>
console.log("hello");
export default {};
</script>
<docs>
Some documentation.
</docs>