vue/valid-define-options
enforce valid
defineOptions
compiler macro
This rule checks whether defineOptions
compiler macro is valid.
📖 Rule Details
This rule reports defineOptions
compiler macros in the following cases:
defineOptions
is referencing locally declared variables.defineOptions
has been called multiple times.- Options are not defined in
defineOptions
. defineOptions
has type arguments.defineOptions
hasprops
,emits
,expose
orslots
options.
1
2
3
4
5
<script setup>
/* ✓ GOOD */
defineOptions({ name: 'foo' })
</script>
1
2
3
4
5
6
7
8
<script>
const def = { name: 'foo' }
</script>
<script setup>
/* ✓ GOOD */
defineOptions(def)
</script>
1
2
3
4
5
6
<script setup>
/* ✗ BAD */
const def = { name: 'foo' }
defineOptions(def)
</script>
1
2
3
4
5
6
<script setup>
/* ✗ BAD */
defineOptions({ name: 'foo' })
defineOptions({ inheritAttrs: false })
</script>
1
2
3
4
5
<script setup>
/* ✗ BAD */
defineOptions()
</script>
1
2
3
4
5
<script setup lang="ts">
/* ✗ BAD */
defineOptions<{ name: 'Foo' }>()
</script>
1
2
3
4
5
<script setup>
/* ✗ BAD */
defineOptions({ props: { msg: String } })
</script>
🔧 Options
Nothing.
👫 Related Rules
🚀 Version
This rule was introduced in eslint-plugin-vue v9.13.0