Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.17 KB

no-v-text-v-html-on-component.md

File metadata and controls

75 lines (53 loc) · 2.17 KB
pageClass sidebarDepth title description since
rule-details
0
vue/no-v-text-v-html-on-component
disallow v-text / v-html on component
v8.4.0

vue/no-v-text-v-html-on-component

disallow v-text / v-html on component

  • ⚙️ This rule is included in all of "plugin:vue/essential", *.configs["flat/vue2-essential"], "plugin:vue/vue3-essential", *.configs["flat/essential"], "plugin:vue/strongly-recommended", *.configs["flat/vue2-strongly-recommended"], "plugin:vue/vue3-strongly-recommended", *.configs["flat/strongly-recommended"], "plugin:vue/recommended", *.configs["flat/vue2-recommended"], "plugin:vue/vue3-recommended" and *.configs["flat/recommended"].

📖 Rule Details

This rule disallows the use of v-text / v-html on component.

If you use v-text / v-html on a component, it will overwrite the component's content and may break the component.

<template>
  <!-- ✓ GOOD -->
  <div v-text="content"></div>
  <div v-html="html"></div>
  <MyComponent>{{ content }}</MyComponent>

  <!-- ✗ BAD -->
  <MyComponent v-text="content"></MyComponent>
  <MyComponent v-html="html"></MyComponent>
</template>

🔧 Options

{
  "vue/no-v-text-v-html-on-component": [
    "error",
    { "allow": ["router-link", "nuxt-link"] }
  ]
}
  • allow (string[]) ... Specify a list of custom components for which the rule should not apply.

{ "allow": ["router-link", "nuxt-link"] }

<template>
  <!-- ✓ GOOD -->
  <router-link v-html="content" />
  <NuxtLink v-html="content" />

  <!-- ✗ BAD -->
  <MyComponent v-html="content" />
</template>

🚀 Version

This rule was introduced in eslint-plugin-vue v8.4.0

🔍 Implementation