diff --git a/lib/rules/require-emit-validator.js b/lib/rules/require-emit-validator.js
index 9d6e5d7f1..083e39e6d 100644
--- a/lib/rules/require-emit-validator.js
+++ b/lib/rules/require-emit-validator.js
@@ -9,6 +9,7 @@ const utils = require('../utils')
/**
* @typedef {import('../utils').ComponentArrayEmit} ComponentArrayEmit
* @typedef {import('../utils').ComponentObjectEmit} ComponentObjectEmit
+ * @typedef {import('../utils').ComponentTypeEmit} ComponentTypeEmit
*/
// ------------------------------------------------------------------------------
@@ -83,8 +84,20 @@ module.exports = {
// Public
// ----------------------------------------------------------------------
- return utils.executeOnVue(context, (obj) => {
- utils.getComponentEmits(obj).forEach(checker)
- })
+ return utils.compositingVisitors(
+ utils.executeOnVue(context, (obj) => {
+ utils.getComponentEmits(obj).forEach(checker)
+ }),
+ utils.defineScriptSetupVisitor(context, {
+ onDefineEmitsEnter(_node, emits) {
+ for (const emit of emits) {
+ if (emit.type === 'type') {
+ continue
+ }
+ checker(emit)
+ }
+ }
+ })
+ )
}
}
diff --git a/tests/lib/rules/require-emit-validator.js b/tests/lib/rules/require-emit-validator.js
index 6c1170e95..b63248cd7 100644
--- a/tests/lib/rules/require-emit-validator.js
+++ b/tests/lib/rules/require-emit-validator.js
@@ -163,6 +163,20 @@ ruleTester.run('require-emit-validator', rule, {
}
`,
parserOptions: { ecmaVersion: 6, sourceType: 'module' }
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parser: require.resolve('vue-eslint-parser'),
+ parserOptions: {
+ ecmaVersion: 6,
+ sourceType: 'module',
+ parser: require.resolve('@typescript-eslint/parser')
+ }
}
],
@@ -325,6 +339,46 @@ ruleTester.run('require-emit-validator', rule, {
line: 4
}
]
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parser: require.resolve('vue-eslint-parser'),
+ parserOptions: {
+ ecmaVersion: 6,
+ sourceType: 'module'
+ },
+ errors: [
+ {
+ messageId: 'missing',
+ data: { name: 'foo' },
+ line: 3
+ }
+ ]
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parser: require.resolve('vue-eslint-parser'),
+ parserOptions: {
+ ecmaVersion: 6,
+ sourceType: 'module'
+ },
+ errors: [
+ {
+ messageId: 'skipped',
+ data: { name: 'foo' },
+ line: 3
+ }
+ ]
}
]
})