diff --git a/lib/rules/no-unused-emit-declarations.js b/lib/rules/no-unused-emit-declarations.js
index 1a88d2417..146438935 100644
--- a/lib/rules/no-unused-emit-declarations.js
+++ b/lib/rules/no-unused-emit-declarations.js
@@ -63,6 +63,7 @@ function hasReferenceId(value, setupContext) {
* @returns {boolean}
*/
function isEmitVariableName(name, emitReferenceIds) {
+ if (emitReferenceIds.size === 0) return false
const emitVariable = emitReferenceIds.values().next().value.name
return emitVariable === name
}
diff --git a/tests/lib/rules/no-unused-emit-declarations.js b/tests/lib/rules/no-unused-emit-declarations.js
index 17b2f441b..cccbcbb98 100644
--- a/tests/lib/rules/no-unused-emit-declarations.js
+++ b/tests/lib/rules/no-unused-emit-declarations.js
@@ -369,6 +369,19 @@ tester.run('no-unused-emit-declarations', rule, {
const m = defineModel('foo')
`
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `
}
],
invalid: [
@@ -750,6 +763,27 @@ tester.run('no-unused-emit-declarations', rule, {
line: 3
}
]
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ errors: [
+ {
+ messageId: 'unused',
+ line: 4,
+ column: 19,
+ endColumn: 24
+ }
+ ]
}
]
})