{"record":{"id":"3e33af7ff2242ea3","repo":"oxc-project/oxc","slug":"defineprops-has-been-called-multiple-times","errorCode":null,"errorMessage":"`defineProps` has been called multiple times.","messagePattern":"`defineProps` has been called multiple times\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_define_props.rs","lineNumber":20,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    frameworks::FrameworkOptions,\n    rule::Rule,\n    utils::{DefineMacroProblem, check_define_macro_call_expression, has_default_exports_property},\n};\n\nfn has_type_and_arguments_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineProps` has both a type-only emit and an argument.\")\n        .with_help(\"remove the argument for better type inference.\")\n        .with_label(span)\n}\n\nfn called_multiple_times(span: Span, second_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineProps` has been called multiple times.\")\n        .with_help(\"combine all `defineProps` calls into a single `defineProps` call.\")\n        .with_labels([\n            span.label(\"`defineProps` is called here\"),\n            second_span.label(\"`defineProps` is called here too\"),\n        ])\n}\n\nfn events_not_defined(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Props are not defined.\")\n        .with_help(\"Define at least one prop in `defineProps`.\")\n        .with_label(span)\n}\n\nfn referencing_locally(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineProps` is referencing locally declared variables.\")\n        .with_help(\"inline the variable or import it from another module.\")\n        .with_label(span)\n}","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_define_props.rs#L2-L38","documentation":"Diagnostic from the oxlint rule `vue/valid-define-props`. The rule's `run_once` remembers the first `defineProps` call span in `found`; every subsequent `defineProps` call in the same program reports this diagnostic with two labels — the current call ('`defineProps` is called here') and the first one ('`defineProps` is called here too'). The Vue compiler allows exactly one `defineProps` per component; a second call fails compilation of `<script setup>`.","triggerScenarios":"Two or more calls to `defineProps(...)` in one .vue program when the VueSetup framework option is active. Example from the fail tests: `defineProps({ msg: String }); defineProps({ count: Number })`. The rule matches any CallExpression whose callee is the identifier `defineProps`, including aliased local calls with that exact name.","commonSituations":"Merging two components or composables that each declared props; copy-pasting a prop block from another SFC; adding new props by writing a fresh `defineProps` instead of extending the existing one.","solutions":["Merge all prop declarations into a single `defineProps({ msg: String, count: Number })` (or one type-only `defineProps<{...}>()`).","If you merged two files, delete the losing component's `defineProps` and fold its props into the survivor's call.","Run the lint again to confirm the duplicate-call diagnostic (and its two labels) are gone."],"exampleFix":"// before\n<script setup>\ndefineProps({ msg: String })\ndefineProps({ count: Number })\n</script>\n\n// after\n<script setup>\ndefineProps({ msg: String, count: Number })\n</script>","handlingStrategy":"validation","validationCode":"const count = (setup.match(/\\bdefineProps\\s*\\(/g) ?? []).length;\nif (count > 1) throw new Error(`Expected one defineProps call, found ${count}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extend the existing defineProps object when adding props instead of adding a new call.","When merging components, dedupe defineProps along with everything else."],"tags":["vue","script-setup","compiler-macro","defineprops","lint","duplicate-call"],"backgroundTag":"vue-script-setup-macro-misuse","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"}