How to get eslint in Visual Studio Code to allow double quotes?

Viewed 13285
  • I created a vue-js CLI project
  • I want to be able to use double-quotes instead of single quotes
  • when I use double quotes, npm run dev reports eslint errors
  • Where do I tell eslint to allow double quotes?

enter image description here

6 Answers

Check your .eslintrc.js file, you can either set the value of the quotes rule to double or set the error level to warning or disable it altogether. Have a look at the docs. This would be an example:

"rules": {
    "quotes": ["error", "double"]
}

quotes: [0, "double"] works for me

Sometimes it is cumbersome to find a specific syntax to disallow a specific eslint rule. In this situations you can use "global" disabling for a code block as the following:

/*eslint-disable */

//suppress all warnings between comments
console.info("foo");

/*eslint-enable */

If you use the ESLint extension https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint.

It comes with a command to initialize the .eslintrc file :

Run Ctrl+Maj+P then ESLint : Create ESLint configuration

In the resulting .eslintrc.js file that has been generated at the root of your Workspace add the quotes: [0, "double"] line as stated by others.

File should look something like this

module.exports = {
  quotes: [0, "double"]
}

Another way which is the easier one is to just go into the.eslintignore file and add * at the end of the file will do the magic for you

The following rule will get rid of the double quotes error however then you will start getting single quotes error:

"rules": {
   "quotes": ["error", "double"]
}

And if you want to disable the quotes rule then add this:

rules: {
    quotes: "off"  
}
Related