Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.48 KB

experimental-script-setup-vars.md

File metadata and controls

42 lines (29 loc) · 1.48 KB
pageClass sidebarDepth title description
rule-details
0
vue/experimental-script-setup-vars
prevent variables defined in `<script setup>` to be marked as undefined

vue/experimental-script-setup-vars

prevent variables defined in <script setup> to be marked as undefined

  • ⚙️ This rule is included in all of "plugin:vue/base", "plugin:vue/essential", "plugin:vue/vue3-essential", "plugin:vue/strongly-recommended", "plugin:vue/vue3-strongly-recommended", "plugin:vue/recommended" and "plugin:vue/vue3-recommended".

:::warning This rule is an experimental rule. It may be removed without notice. :::

This rule will find variables defined in <script setup="args"> and mark them as defined variables.

This rule only has an effect when the no-undef rule is enabled.

📖 Rule Details

Without this rule this code triggers warning:

<script setup="props, { emit }">
import { watchEffect } from 'vue'

watchEffect(() => console.log(props.msg))
emit('foo')
</script>

After turning on, props and emit are being marked as defined and no-undef rule doesn't report an issue.

🔍 Implementation