noVueOptionsApi
Ce contenu n’est pas encore disponible dans votre langue.
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noVueOptionsApi - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noVueOptionsApi": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>Related Rules
Section titled “Related Rules”- useVueVapor: Enforces the use of Vapor mode in Vue components
Resources
Section titled “Resources”Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.