Skip to content

Commit

Permalink
Disallow quotes around object literal property names that are not str…
Browse files Browse the repository at this point in the history
…ictly required
  • Loading branch information
feross committed Jul 5, 2019
1 parent 17c2792 commit f2fac9a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"padded-blocks": ["error", { "blocks": "never", "switches": "never", "classes": "never" }],
"prefer-const": "error",
"prefer-promise-reject-errors": "error",
"quote-props": ["error", "as-needed"],
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"rest-spread-spacing": ["error", "never"],
"semi": ["error", "never"],
Expand Down

3 comments on commit f2fac9a

@hagaigold
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feross , if quotes are "as-needed", why not relax it with consistent-as-needed?
from all the 4 options, this one look the least prettier. with "as-needed" we get mixed object.
I wonder what is the benfit from using as-needed?

headers: {
  'Content-Type': 'application/json',
  Accept: 'application/json',
  'API-Key': '12345'
},

@mightyiam
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hagaigold with the consistent option, imagine a literal object with many keys where none of them require quotes. Then, a single new key is added which does require quotes. All of the keys now require quotes. I don't like that. It's just a key. It shouldn't affect the other keys. In this case, prettiness is not as important as other considerations (at least this one).

@hagaigold
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, fair enough ;)

Please sign in to comment.