Skip to content

noVueExportInScriptSetup (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueExportInScriptSetup": "error"
}
}
}
}

Disallow export in <script setup>.

Everything declared at the top level of <script setup> is already available to the component’s template, so there is nothing to export. Vue fails to compile a component whose <script setup> block exports a value.

To share values with other modules, export them from a separate, regular <script> block in the same file. To expose values to a parent component, use defineExpose().

TypeScript type exports, such as export type and export interface, are allowed, because they are removed when the code is compiled. TypeScript’s export = and export as namespace forms are also allowed.

<script setup>
export const message = "Hello";
</script>
code-block.vue:2:1 lint/nursery/noVueExportInScriptSetup ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ <script setup> can't contain exports.

1 │ <script setup>
> 2 │ export const message = "Hello";
│ ^^^^^^
3 │ </script>
4 │

ℹ Vue fails to compile a component when its <script setup> block exports a value. Top-level declarations are already available to the template.

ℹ Remove the export. To share the value with other modules, move the export to a regular <script> block. To expose it to a parent component, use defineExpose().

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

<script setup>
export default {};
</script>
code-block.vue:2:1 lint/nursery/noVueExportInScriptSetup ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ <script setup> can't contain exports.

1 │ <script setup>
> 2 │ export default {};
│ ^^^^^^^^^^^^^^^^^^
3 │ </script>
4 │

ℹ Vue fails to compile a component when its <script setup> block exports a value. Top-level declarations are already available to the template.

ℹ Remove the export. To share the value with other modules, move the export to a regular <script> block. To expose it to a parent component, use defineExpose().

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

<script setup>
const count = 1;
export { count };
</script>
code-block.vue:3:1 lint/nursery/noVueExportInScriptSetup ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ <script setup> can't contain exports.

1 │ <script setup>
2 │ const count = 1;
> 3 │ export { count };
│ ^^^^^^^^^^^^^^^^^
4 │ </script>
5 │

ℹ Vue fails to compile a component when its <script setup> block exports a value. Top-level declarations are already available to the template.

ℹ Remove the export. To share the value with other modules, move the export to a regular <script> block. To expose it to a parent component, use defineExpose().

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

<script lang="ts">
export const message = "Hello";
</script>
<script setup lang="ts">
export type Size = "small" | "large";
export interface Props {
size: Size;
}
const count = 1;
defineExpose({ count });
</script>