Search code examples
javascriptreactjsvisual-studio-codeeslintprettier

How to get visual studio code to not turn my double quotes into single quotes?


Visual studio code keeps on turning my double quotes into single quotes, and I have no idea how to get it not to.

I'm working on a team project and since they prefer double quotes to single quotes, I noticed that vscode turns my double quotes into single quotes and I've tried everything I could find and nothing. I'm using prettier, but I have "prettier.singleQuote": false so I don't know why it keeps turning my single to double quotes.

here is my eslintrc.js code :

module.exports = {
  "parser": 'babel-eslint',
  "env": {
  "browser": true,
  "commonjs": true,
  "es6": true,
  "node": true,
  "jest": true,
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parserOptions": {
  "ecmaFeatures": {
    "experimentalObjectRestSpread": true,
    "jsx": true
  },
  "sourceType": "module"
},
"plugins": [ "react" ],
"rules": {
  "react/prop-types": ["off"],
  "indent": ["warn", 2],
  "linebreak-style": ["error","unix"],
  "quotes": ["error","single"],
  "no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
  "no-console": ["off", { "allow": ["info", "error"] }]
}

};

my settings modifications :

{
  "editor.formatOnSave": true,
  "[javascript]": {
  "editor.formatOnSave": false
},
  "eslint.autoFixOnSave": true,
  "prettier.disableLanguages": ["js"],
  "eslint.alwaysShowStatus": true,
  "files.autoSave": "onFocusChange",
  "workbench.editor.enablePreview": false,
  "breadcrumbs.enabled": true
}

expected: double quotes result: single quotes


Solution

  • For options how to modify the "quotes": ["error","single"], eslint rule, see https://eslint.org/docs/rules/quotes#avoidescape