-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow quotes around object literal property names that are not strictly required (quote-props) #791
Comments
NACK.
|
Me too, but it is messy for the eyes and we have autofix feature, so absolutely no problem. |
@tunnckoCore not true. If I have an object with 100 properties that has no quotes, then suddenly introduce What a mess that would be for any diff too. |
Kinda didn't thout for that case. But in any way
is some exotic case |
If we're using objects this much, even an object of 3-5 properties would feel like 100 properties. NACK. |
The intention of this rule is good, however I agree with @dcousens. Requoting unrelated keys due to adding a single property that needs quoting is not great.
I think we should avoid any rules while lean heavily on |
So, maybe I believe everyone should by default call standard with I even would suggest |
👍 on catching reserved keywords, maybe. A big 👎 on forcing too much coding style (even if fixable). Standard provides coding bliss because it steps out of the way and allows Zen coding w/o interruption. Add too much opinion and you lose that zen. Related reading: http://ben.balter.com/2016/07/21/removing-a-feature-is-a-feature/ |
@tunnckoCore I added a recommendation to use
This is correct. As cool as |
The ecosystem impact of this is 7.5%.
However, this is mitigated by the fact that the rule is fixable. Most of the failing cases are places where folks were consistently using quoted props, even though they're not needed. Like this: var yargKeys = {
'boolean': { transform: null, error: null },
'count': { transform: null, error: null },
'string': { transform: null, error: null },
'array': { transform: null, error: null },
'required': { transform: null, error: null },
'default:': { transform: null, error: null },
'choices:': { transform: null, error: null },
} We could try enabling this in a future beta version, so I'll leave this open for now. |
Prettier implements I prefer
I would prefer standard does not take a stance on this. I philosophically believe in what standardjs is doing in order avoid bikeshedding (or at least move it to a single repo 😂), but this rule greatly affects my ability to quickly scan/read code in my editor. The implementation of |
One additional note: Prettier is considering "Consistently add quotes to object keys" for v2.0. I would assume this change is due to overwhelming community feedback (although my assumption is probably based on my bias): With the following comment coming from @vjeux who appears to want to adjust this rule regardless of a v2.0 release:
|
|
I think we should go ahead with the following rule in
Ecosystem breakage is only 4%. |
Digging more and more in ESLint rules, i found some good ones which enforces good style and more readable code. This issue is for quote-props rule - fixable.
Suggested configuration.
Invalid
Valid
The text was updated successfully, but these errors were encountered: