{"record":{"id":"1d47c90ea8411dee","repo":"oxc-project/oxc","slug":"duplicate-key-name-may-cause-name-collision-i","errorCode":null,"errorMessage":"Duplicate key '{name}'. May cause name collision in script or template tag.","messagePattern":"Duplicate key '(.+?)'\\. May cause name collision in script or template tag\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/vue/no_dupe_keys.rs","lineNumber":29,"sourceCode":"        PropertyKey, PropertyKind, Statement, TSSignature,\n    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::SymbolId;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::number::ToJsString;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    frameworks::FrameworkOptions,\n    rule::{DefaultRuleConfig, Rule},\n    utils::{for_each_define_props_type_signature, is_vue_component_options_object},\n};\n\nfn duplicate_key_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Duplicate key '{name}'. May cause name collision in script or template tag.\"\n    ))\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoDupeKeysConfig {\n    /// Additional group names to search for duplicate keys in, on top of the\n    /// built-in `props`, `computed`, `data`, `methods` and `setup` groups.\n    groups: Vec<String>,\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]\npub struct NoDupeKeys(Box<NoDupeKeysConfig>);\n\ndeclare_oxc_lint!(\n    /// ### What it does","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/oxc-project/oxc/blob/a3d33dda7cb69da23db4fcaa2c0c05de61e760a1/crates/oxc_linter/src/rules/vue/no_dupe_keys.rs#L11-L47","documentation":"The vue/no-dupe-keys rule from oxlint's Vue plugin reports a name that appears more than once across a component's option groups. Vue merges the built-in groups `props`, `computed`, `data`, `methods` and `setup` (plus any extra groups listed in the rule's `groups` config) onto the same component instance, so a later definition silently overwrites an earlier one. The message 'Duplicate key \\'{name}\\'. May cause name collision in script or template tag.' fires for both Options-API objects (detected via is_vue_component_options_object) and `defineProps` type signatures (via for_each_define_props_type_signature).","triggerScenarios":"Declaring a prop, data key, computed key, method, or setup-returned key whose name already exists in another (or the same) group, e.g. `props: [\\\"foo\\\"]` together with `data() { return { foo } }`. Adding a name to the rule's `groups` config (e.g. `asyncData`, a Nuxt group) and having it collide with a `data` or `computed` key. Duplicating two keys inside one object, or inside a `defineProps<{...}>()` type signature.","commonSituations":"Copy-pasting a prop name into local state; growing a component until a computed and a method share a name; Nuxt projects where `asyncData` overlaps `data`; teams that add custom option groups via the `groups` setting and forget pre-existing names.","solutions":["Rename the duplicate so each name is unique across props/computed/data/methods/setup and any configured `groups`.","If one of the two is redundant (e.g. a data property mirroring a prop), delete the redundant definition instead of renaming.","Check the rule's `groups` config for extra group names you added; remove stale groups that now collide.","Re-run oxlint to confirm the diagnostic is gone before committing."],"exampleFix":"// before\nexport default {\n  props: ['status'],\n  data() {\n    return { status: 'idle' } // duplicate key 'status'\n  }\n}\n\n// after\nexport default {\n  props: ['status'],\n  data() {\n    return { localStatus: 'idle' }\n  }\n}","handlingStrategy":"validation","validationCode":"# fail the build before merge if any duplicate keys exist\nnpx oxlint --eslint.config js --vue src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run oxlint with the Vue plugin in CI so duplicate keys block merges.","Keep one mental checklist of names across props/computed/data/methods/setup per component.","Prefer derive-over-store: don't mirror props into data.","When adding custom groups to the rule's `groups` option, re-lint the whole codebase immediately."],"tags":["vue","duplicate-key","lint","naming","options-api","script-setup"],"backgroundTag":"duplicate-identifier","analyzedSha":"a3d33dda7cb69da23db4fcaa2c0c05de61e760a1","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}