Categories
JavaScript Answers

How to tell ESLint to prefer single quotes around strings?

Spread the love

Sometimes, we want to tell ESLint to prefer single quotes around strings.

In this article, we’ll look at how to tell ESLint to prefer single quotes around strings.

How to tell ESLint to prefer single quotes around strings?

To tell ESLint to prefer single quotes around strings, we add the singleQuote option.

For instance, we write

{
  //...
  "rules": {
    "prettier/prettier": [
      "warn",
      {
        "singleQuote": true,
        "semi": true
      }
    ]
  }
  //...
}

to set the singleQuote option to true in .eslintrc`.

Then ESLint will send a warning if single quote strings aren’t being used.

Conclusion

To tell ESLint to prefer single quotes around strings, we add the singleQuote option.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *