Skip to content

useVueDefineOptions (JavaScript)

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

Enforce defineOptions() instead of a default export in components that use <script setup>.

A Vue single-file component can have two script blocks: a plain <script> block and a <script setup> block. Before Vue 3.3, options such as name or inheritAttrs could only be set with export default { ... } in the plain <script> block, so the component was split across both blocks.

Since Vue 3.3, the defineOptions() macro sets these options directly inside <script setup>. A macro is a function that the Vue compiler handles at build time, so it doesn’t need to be imported. Using it keeps the whole component in one block.

This rule reports the default export of a plain <script> block when the same file also has a <script setup> block.

<script>
export default {
name: "MyComponent",
inheritAttrs: false,
};
</script>
<script setup>
const props = defineProps(["title"]);
</script>
<script setup>
defineOptions({
name: "MyComponent",
inheritAttrs: false,
});
const props = defineProps(["title"]);
</script>

A component without <script setup> still uses a default export:

<script>
export default {
name: "MyComponent",
};
</script>