Kreha
Kreha

Reputation: 195

How to force single quotes in VSC

Maybe this problem is stupid but I really don't know what's going on. In my .eslintrc I added this rule:

"quotes": [1, "single"]

and everytime I save file it changes every " to '. And that's nice. BUT. Every time I restart my Visual studio code. Or make commit using Sourcetree ALL quotes in my project are changed to double ones. Does anybody know what's causing this?

Upvotes: 0

Views: 164

Answers (1)

Yedhin
Yedhin

Reputation: 3189

Maybe it's because vscode doesnt know the exact location of your .eslintrc.json, so add the following to your vscode settings json file and reload vscode :

{
  "eslint.options": { "configFile": "C:/mydirectory/.eslintrc.json" }
}  

also I believe the right way to provide single quotes(even for strings) is like so :

"rules": {
    "quotes": [2, "single", { "avoidEscape": true }]
}

Upvotes: 1

Related Questions