noVueExportInScriptSetup (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.8 - Diagnostic Category:
lint/nursery/noVueExportInScriptSetup - 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
vue/no-export-in-script-setup
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noVueExportInScriptSetup": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.