Proposing a "computed-property-as-needed" rule
See original GitHub issueWith ES6 Computed Properties, one can do the following:
let prop = 'b';
return {
'a': 1,
[prop]: 2,
c: 3,
['d']: 4
}
Note how the brackets around the ['d']
property are superfluous. It could instead be written as 'd'
or d
.
When does this rule warn? Please describe and show example code:
If enabled, the following would trigger:
{
['x']: 1
}
Any property which does not need to be computed could trigger the rule.
Is this rule preventing an error or is it stylistic?
Stylistic
Why is this rule a candidate for inclusion instead of creating a custom rule?
This rule affects basic ES6 syntax for situations where there are two equivalent ways to write the same code.
Are you willing to create the rule yourself?
I will attempt to if nobody else is interested.
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (15 by maintainers)
Top Results From Across the Web
[Pitch] Effectful Read-only Properties - Swift Forums
A read-only computed property is a computed property that only defines a get -ter, which can be mutating . Throughout the remainder of...
Read more >Content of Computed property not picked up by the template ...
Now the problem is that the products property is seen as empty by the template. It's completely fine when I go to this...
Read more >Computed Properties - Vue.js
Think of a computed property as declaratively describing how to derive a value based on other values - its only responsibility should be...
Read more >swift language - Where to put private computed properties?
If a computed property is used to satisfy a conformance to a protocol, then I would put it in the extension that defines...
Read more >Rule 4001. Relief from Automatic Stay; Prohibiting or ...
If the proposed credit agreement or form of order includes any of the ... (i) a grant of priority or a lien on...
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
Or just
no-useless-computed-property
. That rule would be very similar to dot-notation rule.Thanks, @BYK!