eslint-config-formidable
eslint-config-formidable copied to clipboard
[Ongoing Discussion] Quotes: double vs. single.
Double is current convention (from all of the walmart code and the majority of big Formidable projects). Walmart also uses all template strings for es code.
To reduce churn on this contentious, yet functionally unimportant issue, we're going to have all discussion right here and not on the other issues. And, this is definitely a post 1.0 release thing.
Tasks:
- [ ] Decide a framework to evaluate how we're going for our quote style. ( @kenwheeler + @ryan-roemer )
- [ ] Gather inputs and make a decision of whether or not to keep double quotes.
My 15ç:
- From anecdotal experience, single-quotes seem overwhelmingly the more popular in JavaScript libraries across the githubs. One less point of friction onboarding new contributors if we used them as well.
- I prefer single-quotes, since
- they take one less keypress to type (no Shift required)
- they are a bit easier on the eye when scanning code (personal preference)
- When wanting to include single-quotes in a string, we can either escape them or use Template literals.
I don't necessary think that we need to convert all existing projects to single-quotes; If we decide to go with singles, we could use them in projects going forward.
And just so everyone's aware, since this is the eternal bikeshedding issue of doom, this is not going to be a straight democratic vote, but rather Ken and I taking in everyone's input, reviewing our client projects and all the existing Formidable projects, etc. and coming up with a workable default.
Equally important to remember -- this is just a default. Individual projects (client and/or Formidable) are free to choose a deviation based on what is most important on a per-project basis.
👍 on single quotes, for the same reasons @coopy described. I'd also add that there's a bit of muscle memory lost when switching from double (Formidacode) to single (other OSS, some clients). Not a huge deal, though.
I'm definitely used to double-quotes at this point, but I don't think it should be a sticking point for anybody, whichever way we go with it. 100% we should standardize if possible.
I'll start with my personal preference:
- Single quotes for string values in general.
import { this, that } from 'stuff';
writeFile('./dir');
- Double quotes for JSX string props
<Alert msg="oh no!"/>
- Backticks for prose copy and templating
console.error(`There's a problem with your configuration!`);
const fullName = `${firstName} ${lastName}`;
With that out of the way, there are a couple of reasons I would opt for standardization on primarily single quote style:
Everybody is doing it
If we look at the most popular eslint configs, Google, Airbnb, Canonical, Standard, they all use single quotes. The exception being eslint defaults itself and jquery style.
We don't want to encumber contribution
Almost all the examples I read and all the repos I work with or contribute to in my daily grind use single quotes. I have a real cognitive switch become apparent when working on different client projects and coming back to our open source/Walmart stuff.
So putting myself in the shoes of potential contributors, they would likely feel that same shift. I polled twitter to see what the general consensus of the hivemind was, and the results were telling:

Less effort
I can actually feel how smoother things go when switching between SQ and DQ projects throughout my day. Its simply far more ergonomic
JSON
The argument can be made that double quotes should be used because JSON enforces them and we want consistency. IMO I much prefer having contrast in this department. When accustomed to double quotes, JSON just looks like an object with string keys thats missing an export. I genuinely prefer to have JSON immediately recognizable for what it is.
My Preference
"jsx-quotes": [
2,
"prefer-double"
],
"quotes": [
2,
"single",
{"allowTemplateLiterals": true}
]
I am on board with Ken's reasoning and opinions regarding this.
The cognitive-switch is a compelling argument for converting Victory, Spectacle, and other popular projects to single-quotes.