Skip to content

jsonc/quotes

enforce use of double or single quotes

  • ⚙️ This rule is included in "plugin:jsonc/recommended-with-json" and "plugin:jsonc/recommended-with-jsonc".
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule enforces the use of double or single quotes.

JSON5 allows you to define a string in one of two ways: double quotes or single quotes.
However, JSON and JSONC can only use double quotes.

Now loading...

🔧 Options

json
{
    "jsonc/quotes": ["error",
        "double",
        {"avoidEscape": false}
    ]
}

This rule has two options, a string option and an object option.

String option:

  • "double" (default) ... requires the use of double quotes wherever possible
  • "single" ... requires the use of single quotes wherever possible

Object option:

  • "avoidEscape" ... if true, allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise. default false

See here for details.

🚀 Version

This rule was introduced in eslint-plugin-jsonc v0.1.0

🔍 Implementation

Taken with ❤️ from ESLint core