{"record":{"id":"f1e0c5bd76d77fc6","repo":"oxc-project/oxc","slug":"prop-prop-name-requires-default-value-to-be-se","errorCode":null,"errorMessage":"Prop '{prop_name}' requires default value to be set.","messagePattern":"Prop '(.+?)' requires default value to be set\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/require_default_prop.rs","lineNumber":27,"sourceCode":"use oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    frameworks::FrameworkOptions,\n    rule::Rule,\n    utils::{\n        find_property, for_each_define_props_type_signature,\n        is_vue_component_options_object_excluding_instance,\n    },\n};\n\nconst NATIVE_TYPES: [&str; 7] =\n    [\"String\", \"Number\", \"Boolean\", \"Function\", \"Object\", \"Array\", \"Symbol\"];\n\nfn require_default_prop_diagnostic(span: Span, prop_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Prop '{prop_name}' requires default value to be set.\"))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct RequireDefaultProp;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Requires default value to be set for props that are not marked as\n    /// `required`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// A prop that is neither required nor given a default is implicitly\n    /// `undefined` when omitted. Forcing a default keeps the component's\n    /// behavior explicit and avoids `undefined` leaking into the template and\n    /// logic. `Boolean` props are exempt because they already default to","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/require_default_prop.rs#L9-L45","documentation":"Emitted by check_object_props and check_type_signature in the vue require-default-prop rule when a prop is marked optional (or not required) in the component options or defineProps type signature but has no default value. It is a validation guard: optional props without defaults resolve to undefined, which often hides runtime bugs.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vue/require_default_prop.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a default value in the prop definition, e.g. props: { foo: { type: String, default: '' } }","For type-based defineProps, mark the prop required by omitting the optional '?' so a default is unnecessary","Use a compiler macro option like withDefaults(defineProps<...>(), { foo: '' }) for type signatures"],"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"}