noVueOptionsApi
Summary
Section titled “Summary”- Rule available since:
v2.3.12 - Diagnostic Category:
lint/style/noVueOptionsApi - This rule isn’t recommended, so you need to enable it.
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "style": { "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/style/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.
<script>export default { methods: { increment() { this.count++ } }}</script>code-block.vue:1:16 lint/style/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.
<script>export default { computed: { doubled() { return this.count * 2 } }}</script>code-block.vue:1:16 lint/style/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.
<script>export default { mounted() { console.log('Component mounted') }}</script>code-block.vue:1:16 lint/style/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.
import { defineComponent } from 'vue'
defineComponent({ name: 'MyComponent', data() { return { count: 0 } }})code-block.js:3:17 lint/style/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.
<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.