Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell eslint that you prefer single quotes around your strings

Tags:

node.js

eslint

I'm new to eslint and it's spewing out a ton of errors telling me to use doublequotes:

error  Strings must use doublequote 

That's not my preference. I've got an .eslintrc file set up with the basics:

{   "env": {     "node": 1   } } 

I'd like to configure it for single quotes.

like image 701
Antonius Bloch Avatar asked Mar 28 '15 02:03

Antonius Bloch


People also ask

How do I disable ESLint double quotes?

To completely disable the quotes rule, set it to either 0 or off in your eslint configuration file (see the different configuration formats here). Example for disabling in json configuration file: { "rules": { "quotes": "off", ... } }

How do you pass a single quote in a string?

Enclosing Quotation Marks That means strings containing single quotes need to use double quotes and strings containing double quotes need to use single quotes. "It's six o'clock."; 'Remember to say "please" and "thank you."'; Alternatively, you can use a backslash \ to escape the quotation marks.

Can the value of a string be surrounded by single quotes?

Enclosing characters in single quotes preserves the literal value of each character within the quotes.


1 Answers

http://eslint.org/docs/rules/quotes.html

{   "env": {     "node": 1   },   "rules": {     "quotes": [2, "single", { "avoidEscape": true }]   } } 
like image 174
Antonius Bloch Avatar answered Oct 02 '22 19:10

Antonius Bloch