sveltejs / eslint-config

An ESLint config for Svelte
14 stars 11 forks source link

Allow either single quotes or template literals #7

Closed benmccann closed 3 years ago

benmccann commented 3 years ago

Please vote with a thumbs up or thumbs down on whether you prefer this potential change

This PR allows strings to use either single quotes and template literals as the user chooses. This would allow the user to write strings in template literals without escaping single quotes such as No custom element 'tag' option was specified

The currently checked in code does not allow template literals unless they reference a variable, so strings with single quotes should be written either as No custom element \'tag\' option was specified or No custom element "tag" option was specified. It offers more firmness around users using single quotes for a string like foobar with no quotes or variables

antony commented 3 years ago

Not having to escape things is endlessly cleaner to look at.

vwkd commented 3 years ago

Why not simply use the "avoidEscape": true property and use the opposite quote style?

allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise

In your case, this would mean using double quotes, since you use single quotes to declare a string. IMO the wrong choice to use single quotes, because they are used by words like aren't, can't, don't, that's, I'd, haven't, etc., but that's another topic.

benmccann commented 3 years ago

I've sent https://github.com/sveltejs/eslint-config/pull/8 as an alternative to this