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 does

View on GitHub (pinned to a3d33dda7c)

Solutions

  1. Rename the duplicate so each name is unique across props/computed/data/methods/setup and any configured `groups`.
  2. If one of the two is redundant (e.g. a data property mirroring a prop), delete the redundant definition instead of renaming.
  3. Check the rule's `groups` config for extra group names you added; remove stale groups that now collide.
  4. 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

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


AI-assisted analysis of oxc-project/oxc@a3d33dda7c (2026-08-20). Data as JSON: /api/errors/1d47c90ea8411dee. Report an issue: GitHub.