{"record":{"id":"dd46b6dd1e3c953c","repo":"oxc-project/oxc","slug":"custom-events-are-defined-in-both-defineemits-an","errorCode":null,"errorMessage":"Custom events are defined in both `defineEmits` and `export default {}`.","messagePattern":"Custom events are defined in both `defineEmits` and `export default (.+?)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_define_emits.rs","lineNumber":41,"sourceCode":"            span.label(\"`defineEmits` is called here\"),\n            second_span.label(\"`defineEmits` is called here too\"),\n        ])\n}\n\nfn events_not_defined(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Custom events are not defined.\")\n        .with_help(\"Define at least one event in `defineEmits`.\")\n        .with_label(span)\n}\n\nfn referencing_locally(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineEmits` is referencing locally declared variables.\")\n        .with_help(\"inline the variable or import it from another module.\")\n        .with_label(span)\n}\n\nfn define_in_both(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Custom events are defined in both `defineEmits` and `export default {}`.\")\n        .with_help(\"Remove `export default`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ValidDefineEmits;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce valid usage of the `defineEmits` compiler macro in Vue.\n    ///\n    /// This rule reports `defineEmits` compiler macros in the following cases:\n    ///\n    /// - `defineEmits` is referencing locally declared variables.\n    /// - `defineEmits` has both a literal type and an argument. e.g. `defineEmits<(e: 'foo')=>void>(['bar'])`\n    /// - `defineEmits` has been called multiple times.\n    /// - Custom events are defined in both `defineEmits` and `export default {}`.","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_define_emits.rs#L23-L59","documentation":"Emitted by run_once of the vue valid-define-emits rule (define_in_both) when custom events are declared both via the defineEmits macro and via the emits option in an export default {} block. Duplicating the declaration is redundant and can desynchronize the two lists.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vue/valid_define_emits.rs:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep only the defineEmits macro declaration in <script setup> and remove the emits option from export default","Or, in non-setup scripts, keep only the export default emits option and drop defineEmits"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}