This repository was archived by the owner on Aug 31, 2023. It is now read-only.
useLiteralKeys rule should cover object properties
#4664
Conaclos
started this conversation in
Suggestions
Replies: 1 comment
-
|
Great suggestion! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
useLiteralKeyslint rule reports code where static property access can be used instead of computed acces.This implements the EsLint
dot-notationrule.The EsLint
no-useless-computed-keyrule reports useless computed keys on an object literal:{ - ["b"]: 0, - ["1+1"]: 2, - ["f"]() {}, + b: 0, + "1+1": 2, + f() {}, }I suggest merging these two EsLint rule into
useLiteralKeys.The only minor inconsistency in the rule name is the simplification of
["1+1"]to"1+1".The rule could also handle the following cases:
{ - "b": 0, - "f"() {}, + b: 0, + "f"() {}, }class C { - ["b"] = 0 - "c" = 0 - ["f"]() {} - "g"() {} + b = 0 + c = 0 + f() {} + g() {} }This could also be done on interfaces and object types.
This is not a breaking change since
useLiteralKeysis a nursery rule.Beta Was this translation helpful? Give feedback.
All reactions