no-dupe-keys - warn about non-static key names with similar AST
See original GitHub issueWhat 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:
- Created 5 years ago
- Reactions:4
- Comments:6 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@platinumazure I changed the initial post according to the rule enhancement proposal template
Is there a reason this wasn’t accepted? Can it be revisited?