Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upNew rule suggestion: Object key names should only be quoted if necessary #503
Comments
This comment has been minimized.
This comment has been minimized.
|
How do we feel about objects where some keys require quoting? I think it's more readable if they are all quoted: const map = {
'test-1': 73,
'normal': 843,
'other-key': 386,
'1pass': 284,
'sword': 83,
'heavy-sword': 738
} |
This comment has been minimized.
This comment has been minimized.
|
I think quotes in keys should only be allowed for escaping, the same way we apply the rule to double quotes for strings. |
This comment has been minimized.
This comment has been minimized.
|
The reason that I initially did not enable this rule is because of the case that @LinusU points out. As with all new rule proposals, the first step is to see how many repos would fail with it enabled. |
feross
added
feature request
enhancement
and removed
feature request
labels
Apr 28, 2016
This comment has been minimized.
This comment has been minimized.
|
@LinusU: That works, too. I guess I thought part of the purpose of this standard was to reduce wiggle room. I recently came across a case in my own code where I had been inconsistent in my use of quoting and it seemed like something that fit neatly into what standard was trying to accomplish. |
This comment has been minimized.
This comment has been minimized.
|
I think quote only if necessary is fine. It is consistent with our other idiosyncrasies (e.g semicolons). |
This comment has been minimized.
This comment has been minimized.
|
Adding the rule:
Results in the following failures:
which seems fairly high for a purely stylistic rule addition. Maybe we can add it once the rule is automatically fixable with ESLint's |
feross
added
the
blocked
label
Jul 13, 2016
This comment has been minimized.
This comment has been minimized.
|
Let's re-open this issue once ESLint makes |
scouten commentedApr 27, 2016
Good:
Bad: