Skip to content

Latest commit

 

History

History
119 lines (86 loc) · 2.46 KB

valid-define-options.md

File metadata and controls

119 lines (86 loc) · 2.46 KB
pageClass sidebarDepth title description
rule-details
0
vue/valid-define-options
enforce valid `defineOptions` compiler macro

vue/valid-define-options

enforce valid defineOptions compiler macro

  • This rule has not been released yet.

This rule checks whether defineOptions compiler macro is valid.

📖 Rule Details

This rule reports defineOptions compiler macros in the following cases:

  • defineOptions are referencing locally declared variables.
  • defineOptions has been called multiple times.
  • Options are not defined in defineOptions.
  • defineOptions has type arguments.
  • defineOptions has props, emits, expose or slots options.
<script setup>
/* ✓ GOOD */
defineOptions({ name: 'foo' })
</script>
<script>
const def = { name: 'foo' }
</script>
<script setup>
/* ✓ GOOD */
defineOptions(def)
</script>
<script setup>
/* ✗ BAD */
const def = { name: 'foo' }
defineOptions(def)
</script>
<script setup>
/* ✗ BAD */
defineOptions({ name: 'foo' })
defineOptions({ inheritAttrs: false })
</script>
<script setup>
/* ✗ BAD */
defineOptions()
</script>
<script setup lang="ts">
/* ✗ BAD */
defineOptions<{ name: 'Foo' }>()
</script>
<script setup>
/* ✗ BAD */
defineOptions({ props: { msg: String } })
</script>

🔧 Options

Nothing.

👫 Related Rules

🔍 Implementation