{"record":{"id":"a2f0250466adea05","repo":"oxc-project/oxc","slug":"use-type-based-declaration-instead-of-runtime-decl-a2f025","errorCode":null,"errorMessage":"Use type-based declaration instead of runtime declaration","messagePattern":"Use type-based declaration instead of runtime declaration","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/vue/define_props_declaration.rs","lineNumber":21,"sourceCode":"use oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    frameworks::FrameworkOptions,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn use_runtime_declaration_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use runtime declaration instead of type-based declaration\")\n        .with_label(span)\n}\n\nfn use_type_based_declaration_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use type-based declaration instead of runtime declaration\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Serialize, Deserialize)]\n#[serde(rename_all = \"kebab-case\")]\nenum DeclarationStyle {\n    /// Enforce type-based declaration.\n    #[default]\n    TypeBased,\n    /// Enforce runtime declaration.\n    Runtime,\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct DefinePropsDeclaration(DeclarationStyle);\n\ndeclare_oxc_lint!(\n    /// ### What it does","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/define_props_declaration.rs#L3-L39","documentation":"Diagnostic from oxlint's vue/define-props-declaration rule (style category, since oxlint 1.15.0). It fires inside <script setup lang=\"ts\"> when props are declared with the runtime object form defineProps({...}) while the rule enforces type-based declarations (DeclarationStyle::TypeBased, the default). Purely stylistic: it pushes teams toward one uniform way to declare props.","triggerScenarios":"Rule enabled with default or explicit \"type-based\" option, and the file contains `const props = defineProps({ kind: { type: String } })` in a script-setup TS block. The rule matches only CallExpressions whose callee identifier is exactly `defineProps`.","commonSituations":"Codebases migrating options/runtime-style components into <script setup>, or shared lint configs that enable the rule with its default; CI fails on newly copied Vue 2-style props objects.","solutions":["Convert to the type-based form: defineProps<{ kind: string }>()","Keep runtime form and set the rule option to \"runtime\" in .oxlintrc.json","Disable the rule via an inline oxlint-disable comment if the file cannot be converted yet"],"exampleFix":"// before (option \"type-based\", the default)\nconst props = defineProps({ kind: { type: String } })\n// after\nconst props = defineProps<{ kind: string }>()","handlingStrategy":"validation","validationCode":"# find runtime-style declarations before enforcing \"type-based\"\ngrep -rnE \"defineProps\\(\\{\" --include='*.vue' src","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the rule option explicit in shared configs so new files cannot guess the wrong default","Codemod defineProps styles in one commit rather than fixing file-by-file"],"tags":["vue","oxlint","lint","script-setup","defineprops","style","typescript"],"backgroundTag":"vue-props-declaration-style","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"}