7

Prettier formatter, AirBnB linter.

Prettier defaults to double quotes for strings. AirBnB loves it some single quotes. Would probably be able to change the configuration in order to maintain sanity *now*, but when I was a newbie dev, I was given a repo with AirBnB linting built in after being recommended Prettier.

It was not fun times.

Comments
  • 1
    Double quotes for strings, that's how all my nightmares start
  • 1
    @Tamrael single quotes for strings are my nightmares. Mainly because I started programming in C++ and C#. Single quotes are for characters (and thats how I use it in javascript and PHP as well)
  • 3
    @Codex404 Right? It seems so weird to use single quotes for something larger than a character.
  • 0
    @Codex404 I started that way but bad code with embedded variables (breaking all over the place, no escapes) has brought me to this dark place where I prefer the single quotes because at least the people get forced to think about where their strings end and variables begin.
  • 0
    @Tamrael how do the type of quotes break things?
  • 0
    @Codex404 some languages allow developers to include variables into double quoted strings. This has many downsides and can lead to many security issues. Readability suffers and things can get really messy.

    With those languages it's better to stick to single quoted strings to force the dev to think about what they are doing and if the variable they put into the string are really safe to use there.

    It's about how the code is structured in those languages and about better division of the concerns just like MVC patterns, having the string not containing some arbitrary untyped variable is a good idea.

    If all languages would treat double quoted strings as string not to be interpreted at all but just used as strings there would be no case against it for me. In languages where string are really just strings I use the standard, whichever that language prefers.
  • 0
    @Tamrael ah I always use double unless there is a good reason not to.
Add Comment