For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/eslint/no-dupe-keys.md.
close

no-dupe-keys

Added in v0.2.2

Configuration

PresetConfigured Value
✅ js.configs.recommended"error"
rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-dupe-keys': 'error',
    },
  },
]);

Rule Details

Disallow duplicate keys in object literals. Multiple properties with the same key in object literals can cause unexpected behavior.

Examples of incorrect code for this rule:

var foo = {
  bar: 'baz',
  bar: 'qux',
};

var foo = {
  bar: 'baz',
  bar: 'qux',
};

Examples of correct code for this rule:

var foo = {
  bar: 'baz',
  qux: 'quux',
};

// getter and setter with same name is valid
var foo = {
  get bar() {},
  set bar(v) {},
};

Original Documentation