vue/valid-v-slot
enforce valid
v-slot
directives
- ⚙️ This rule is included in all of
"plugin:vue/vue3-essential"
,"plugin:vue/essential"
,"plugin:vue/vue3-strongly-recommended"
,"plugin:vue/strongly-recommended"
,"plugin:vue/vue3-recommended"
and"plugin:vue/recommended"
.
This rule checks whether every v-slot
directive is valid.
📖 Rule Details
This rule reports v-slot
directives in the following cases:
- The directive is not owned by a custom element. E.g.
<div v-slot=""></div>
- The directive is a named slot and is on a custom element directly. E.g.
<my-component v-slot:foo></my-component>
- The directive is the default slot, is on a custom element directly, and there are other named slots. E.g.
<my-component v-slot=""><template v-slot:foo></template></my-component>
- The element which has the directive has another
v-slot
directive. E.g.<my-component v-slot:one v-slot:two></my-component>
- The element which has the directive has another
v-slot
directive that is distributed to the same slot. E.g.<my-component><template v-slot:foo></template><template v-slot:foo></template></my-component>
- The directive has a dynamic argument which uses the scope properties that the directive defined. E.g.
<my-component><template v-slot:[data]="data"></template></my-component>
- The directive has any modifier. E.g.
<my-component v-slot.foo></my-component>
- The directive is the default slot, is on a custom element directly, and has no value. E.g.
<my-component v-slot></my-component>
Note
This rule does not check syntax errors in directives because it's checked by vue/no-parsing-error rule.
🔧 Options
json
{
"vue/valid-v-slot": ["error", {
"allowModifiers": false
}]
}
allowModifiers
(boolean
) ... allows having modifiers in the argument ofv-slot
directives. Modifiers just afterv-slot
are still disallowed. E.g.<template v-slot.foo>
defaultfalse
.
allowModifiers: true
👫 Related Rules
🚀 Version
This rule was introduced in eslint-plugin-vue v7.0.0