oxc-project/oxc · warning · OxcDiagnostic
Duplicate key '{name}'. May cause name collision in script o
Error message
Duplicate key '{name}'. May cause name collision in script or template tag. What it means
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).
Source
Thrown at crates/oxc_linter/src/rules/vue/no_dupe_keys.rs:29
PropertyKey, PropertyKind, Statement, TSSignature,
},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::SymbolId;
use oxc_span::{GetSpan, Span};
use oxc_syntax::number::ToJsString;
use crate::{
AstNode,
context::LintContext,
frameworks::FrameworkOptions,
rule::{DefaultRuleConfig, Rule},
utils::{for_each_define_props_type_signature, is_vue_component_options_object},
};
fn duplicate_key_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"Duplicate key '{name}'. May cause name collision in script or template tag."
))
.with_label(span)
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NoDupeKeysConfig {
/// Additional group names to search for duplicate keys in, on top of the
/// built-in `props`, `computed`, `data`, `methods` and `setup` groups.
groups: Vec<String>,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
pub struct NoDupeKeys(Box<NoDupeKeysConfig>);
declare_oxc_lint!(
/// ### What it doesView on GitHub (pinned to a3d33dda7c)
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.
Example fix
// before
export default {
props: ['status'],
data() {
return { status: 'idle' } // duplicate key 'status'
}
}
// after
export default {
props: ['status'],
data() {
return { localStatus: 'idle' }
}
} Defensive patterns
Strategy: validation
Validate before calling
# fail the build before merge if any duplicate keys exist npx oxlint --eslint.config js --vue src/
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- TS5081
- Prop "{prop_name}" should be optional.
- Key `{name}` is reserved.
- Key `{key}` is reserved in `{group}` group.
- Props are defined in both `defineProps` and `export default
AI-assisted analysis of oxc-project/oxc@a3d33dda7c (2026-08-20).
Data as JSON: /api/errors/1d47c90ea8411dee.
Report an issue: GitHub.