question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-dupe-keys - warn about non-static key names with similar AST

See original GitHub issue

What rule do you want to change? no-dupe-keys

Does this change cause the rule to produce more or fewer warnings? More

How will the change be implemented? (New option, new default behavior, etc.)? Right now rule works only with static property names https://github.com/eslint/eslint/blob/master/lib/rules/no-dupe-keys.js#L122

Rule could also check for calculated property names with similar AST

Please provide some example code that this change will affect:

/* eslint-disable no-console */
const obj1 = {
    ['aaa']: 1,
    ['aaa']: 1 // here duplicate keys are detected
};

const name = 'aaa';

const obj2 = {
    [name]: 1,
    [name]: 1 // here duplicate keys are not detected
};

console.log(obj1, obj2);

What does the rule currently do for this code? Rule detects duplicate keys only in obj1

  4:6  error  Duplicate key 'aaa'  no-dupe-keys

✖ 1 problem (1 error, 0 warnings)

What will the rule do after it’s changed? The rule will detect also duplicate keys in obj2

  4:6  error  Duplicate key 'aaa'  no-dupe-keys
 11:6  error  Duplicate key [name]  no-dupe-keys

✖ 2 problems (2 errors, 0 warnings)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
victor-homyakovcommented, Aug 5, 2018

@platinumazure I changed the initial post according to the rule enhancement proposal template

0reactions
ljharbcommented, Dec 11, 2018

Is there a reason this wasn’t accepted? Can it be revisited?

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-dupe-keys - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Code Issues - Embold Help Center
Embold helps to identify the code issues in your software and provide the solutions for the same. There are different languages in which...
Read more >
List of warning definitions - QualityGate
Cryptographic keys should not be too short (csharpsquid:S4426) - P0 - Vulnerability ... Methods and field names should not be the same or...
Read more >
avoid from - OSCHINA - 中文开源技术交流社区
... but at the same time thread B holds lock M and try to acquire lock L, ... with sophisticated non-linear learning algorithms...
Read more >
ftp.jaist.ac.jp/pub/tdf/libreoffice/src/commits-ta...
HAVE_FEATURE_DBCONNECTIVITY anyway [Caolán McNamara] + add debug name to an Idle ... nRow [Stephan Bergmann] + avoid valgrind warning [David Tardon] + avoid ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found