Skip to content

vue/no-unused-components ​

disallow registering components that are not used inside templates

  • ⚙️ This rule is included in the following preset configs:
    • *.configs["flat/essential"]
    • *.configs["flat/vue2-essential"]
    • *.configs["flat/strongly-recommended"]
    • *.configs["flat/vue2-strongly-recommended"]
    • *.configs["flat/recommended"]
    • *.configs["flat/vue2-recommended"]
    • "plugin:vue/essential"
    • "plugin:vue/vue2-essential"
    • "plugin:vue/strongly-recommended"
    • "plugin:vue/vue2-strongly-recommended"
    • "plugin:vue/recommended"
    • "plugin:vue/vue2-recommended"

📖 Rule Details ​

This rule reports components that haven't been used in the template.

Now loading...
Now loading...

Note

A component counts as used when Vue can resolve it from the template, the same way Vue does at runtime. For a tag in the template, Vue looks for a registration named exactly like the tag, then like the tag in camelCase, then like the tag in PascalCase. So a component registered as TheButton is found by <TheButton>, <the-button> and <theButton>. But a component registered as theButton is not found by <TheButton>, because Vue never lowercases the first letter of a tag.

🔧 Options ​

json
{
  "vue/no-unused-components": ["error", {
    "ignoreWhenBindingPresent": true
  }]
}
  • ignoreWhenBindingPresent ... suppresses all errors if binding has been detected in the template default true

ignoreWhenBindingPresent: false ​

Now loading...
Now loading...

🚀 Version ​

This rule was introduced in eslint-plugin-vue v7.0.0

🔍 Implementation ​