{"record":{"id":"c7dfef56e64ae27b","repo":"oxc-project/oxc","slug":"props-are-not-defined","errorCode":null,"errorMessage":"Props are not defined.","messagePattern":"Props are not defined\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_define_props.rs","lineNumber":29,"sourceCode":"};\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}\n\nfn define_in_both(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Props are defined in both `defineProps` and `export default {}`.\")\n        .with_help(\"Remove `export default`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ValidDefineProps;","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_define_props.rs#L11-L47","documentation":"Diagnostic from the oxlint rule `vue/valid-define-props`. The shared helper `check_define_macro_call_expression` returns `DefineMacroProblem::EventsNotDefined` when a `defineProps` call declares no props at all: no type parameter, no runtime argument, and no `props` property in a sibling plain `<script>` block's `export default {}` (checked via `has_default_exports_property(&ctx.other_file_hosts(), \"props\")`). An empty `defineProps()` is dead code at best and usually a migration leftover that silently breaks prop passing.","triggerScenarios":"A bare `defineProps()` (no type args, no arguments) in a component that also does not declare `props` inside a sibling `export default {}`. The pass tests confirm `defineProps()` is accepted only when the plain `<script>` block has `export default { props: { msg: String } }`; a standalone `defineProps()` in `<script setup>` fails.","commonSituations":"Scaffolding a component and leaving the macro empty 'for later'; removing props during a refactor but keeping the call; generators that always emit `defineProps()` regardless of need.","solutions":["Declare the props you actually use: `defineProps({ msg: String })`, `defineProps(['msg'])`, or `defineProps<{ msg?: string }>()`.","If the component truly takes no props, delete the `defineProps()` call.","If props are intentionally declared in the Options API sibling block, keep `export default { props: {...} }` and remove the empty macro, or move the declaration into `defineProps`."],"exampleFix":"// before\n<script setup>\ndefineProps()\n</script>\n\n// after\n<script setup>\ndefineProps({ msg: String })\n</script>","handlingStrategy":"validation","validationCode":"const hasExportDefaultProps = /export\\s+default\\s*\\{[\\s\\S]*?\\bprops\\s*:/.test(src);\nconst bare = /\\bdefineProps\\s*\\(\\s*\\)/.test(setup);\nif (bare && !hasExportDefaultProps) {\n  throw new Error('defineProps() declares nothing and no props exist in export default {}');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete scaffolded empty defineProps() calls before committing.","Keep the vue/valid-define-props rule enabled so empty calls are reported."],"tags":["vue","script-setup","compiler-macro","defineprops","lint","missing-argument"],"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-14T00:17:10.932Z"}