Skip to main content

js/noDuplicateKeys

disallow duplicate keys in object literals

ESLint Equivalent: no-dupe-keys

Examples

Invalid

const foo = {
	test: true,
	test2: true,
	test: false,
};

 file.ts:2:1 lint/js/noDuplicateKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid duplicate component key. Check the test key.

    1const foo = {
  > 2  test: true,
       ^^^^
    3  test2: true,
    4  test: false,

  Defined already here

    2  test: true,
    3  test2: true,
  > 4  test: false,
       ^^^^
    5};