Ir al contenido

noVueOptionsApi

Esta página aún no está disponible en tu idioma.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueOptionsApi": "error"
}
}
}
}

Disallow the use of Vue Options API.

Vue 3.6’s Vapor Mode does not support the Options API. Components must use the Composition API (<script setup> or defineComponent with function signature) instead.

This rule helps prepare codebases for Vapor Mode by detecting Options API patterns that are incompatible with the new rendering mode.

<script>
export default {
data() {
return { count: 0 }
}
}
</script>
code-block.vue:1:16 lint/nursery/noVueOptionsApi ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Using the Options API is not allowed.

> 1 │ export default {
^
> 2 │ data() {
> 3 │ return { count: 0 }
> 4 │ }
> 5 │ }
^
6 │

Although the Options API is still supported by Vue, using the Composition API is recommended, and makes it possible to use Vue’s Vapor mode for better performance.

Use <script setup> or defineComponent with a function signature to use the Composition API instead.

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>
export default {
methods: {
increment() {
this.count++
}
}
}
</script>
code-block.vue:1:16 lint/nursery/noVueOptionsApi ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Using the Options API is not allowed.

> 1 │ export default {
^
> 2 │ methods: {
> 3 │ increment() {
> 4 │ this.count++
> 5 │ }
> 6 │ }
> 7 │ }
^
8 │

Although the Options API is still supported by Vue, using the Composition API is recommended, and makes it possible to use Vue’s Vapor mode for better performance.

Use <script setup> or defineComponent with a function signature to use the Composition API instead.

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>
export default {
computed: {
doubled() {
return this.count * 2
}
}
}
</script>
code-block.vue:1:16 lint/nursery/noVueOptionsApi ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Using the Options API is not allowed.

> 1 │ export default {
^
> 2 │ computed: {
> 3 │ doubled() {
> 4 │ return this.count * 2
> 5 │ }
> 6 │ }
> 7 │ }
^
8 │

Although the Options API is still supported by Vue, using the Composition API is recommended, and makes it possible to use Vue’s Vapor mode for better performance.

Use <script setup> or defineComponent with a function signature to use the Composition API instead.

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>
export default {
mounted() {
console.log('Component mounted')
}
}
</script>
code-block.vue:1:16 lint/nursery/noVueOptionsApi ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Using the Options API is not allowed.

> 1 │ export default {
^
> 2 │ mounted() {
> 3 │ console.log(‘Component mounted’)
> 4 │ }
> 5 │ }
^
6 │

Although the Options API is still supported by Vue, using the Composition API is recommended, and makes it possible to use Vue’s Vapor mode for better performance.

Use <script setup> or defineComponent with a function signature to use the Composition API instead.

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.

import { defineComponent } from 'vue'
defineComponent({
name: 'MyComponent',
data() {
return { count: 0 }
}
})
code-block.js:3:17 lint/nursery/noVueOptionsApi ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Using the Options API is not allowed.

1 │ import { defineComponent } from ‘vue’
2 │
> 3 │ defineComponent({
^
> 4 │ name: ‘MyComponent’,
> 5 │ data() {
> 6 │ return { count: 0 }
> 7 │ }
> 8 │ })
^
9 │

Although the Options API is still supported by Vue, using the Composition API is recommended, and makes it possible to use Vue’s Vapor mode for better performance.

Use <script setup> or defineComponent with a function signature to use the Composition API instead.

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>
import { ref } from 'vue'
const count = ref(0)
</script>
<script setup>
import { ref, computed } from 'vue'
const count = ref(0)
const doubled = computed(() => count.value * 2)
</script>
<script setup>
import { onMounted } from 'vue'
onMounted(() => {
console.log('Component mounted')
})
</script>
  • useVueVapor: Enforces the use of Vapor mode in Vue components