Skip to content

vue/require-explicit-emits ​

require emits option with name triggered by $emit()

  • ⚙️ This rule is included in the following preset configs:
    • *.configs["flat/strongly-recommended"]
    • *.configs["flat/recommended"]
    • "plugin:vue/strongly-recommended"
    • "plugin:vue/recommended"
  • 💡 Some problems reported by this rule are manually fixable by editor suggestions.

📖 Rule Details ​

This rule reports event triggers not declared with the emits option. (The emits option is a new in Vue.js 3.0.0+)

Explicit emits declaration serves as self-documenting code. This can be useful for other developers to instantly understand what events the component is supposed to emit. Also, with attribute fallthrough changes in Vue.js 3.0.0+, v-on listeners on components will fallthrough as native listeners by default. Declare it as a component-only event in emits to avoid unnecessary registration of native listeners.

Now loading...
Now loading...
Now loading...

🔧 Options ​

json
{
  "vue/require-explicit-emits": ["error", {
    "allowProps": false,
    "ignoreMixins": false
  }]
}
  • "allowProps" ... If true, allow event names defined in props. default false
  • "ignoreMixins" ... If true, skip components that use the mixins option, since events declared in mixins cannot be checked. default false

"allowProps": true ​

Now loading...

"ignoreMixins": true ​

Now loading...

📚 Further Reading ​

🚀 Version ​

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

🔍 Implementation ​