{"record":{"id":"0c525f3815758a10","repo":"oxc-project/oxc","slug":"defineemits-is-referencing-locally-declared-vari","errorCode":null,"errorMessage":"`defineEmits` is referencing locally declared variables.","messagePattern":"`defineEmits` is referencing locally declared variables\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_define_emits.rs","lineNumber":35,"sourceCode":"}\n\nfn called_multiple_times(span: Span, second_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineEmits` has been called multiple times.\")\n        .with_help(\"combine all events into a single `defineEmits` call.\")\n        .with_labels([\n            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    ///","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_define_emits.rs#L17-L53","documentation":"Emitted by run_once of the vue valid-define-emits rule (referencing_locally) when the defineEmits declaration references a variable declared locally in the SFC setup scope. The macro is compiled away and hoisted outside setup, so local references cannot be resolved and produce broken output.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vue/valid_define_emits.rs:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inline the referenced variable's value directly into defineEmits","Import the declaration from another module so it resolves at module scope"],"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"}