Skip to content

jsonc/object-curly-spacing

enforce consistent spacing inside braces

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule enforces consistent spacing inside braces of object literals.

Now loading...

🔧 Options

json
{
    "jsonc/object-curly-spacing": ["error",
        "never",
        {
            "arraysInObjects": false,
            "objectsInObjects": false,
            "emptyObjects": "ignore"
        }
    ]
}

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

  • First option:

    • "never" (default) disallows spacing inside of braces
    • "always" requires spacing inside of braces (except {})
  • Second option:

    • "arraysInObjects" control spacing inside of braces of objects beginning and/or ending with an array element.
      • true requires spacing inside of braces of objects beginning and/or ending with an array element (applies when the first option is set to never)
      • false disallows spacing inside of braces of objects beginning and/or ending with an array element (applies when the first option is set to always)
    • "objectsInObjects" control spacing inside of braces of objects beginning and/or ending with an object element.
      • true requires spacing inside of braces of objects beginning and/or ending with an object element (applies when the first option is set to never)
      • false disallows spacing inside of braces of objects beginning and/or ending with an object element (applies when the first option is set to always)
    • "emptyObjects" control spacing within empty objects.
      • "ignore"(default) do not check spacing in empty objects.
      • "always" require a space in empty objects.
      • "never" disallow spaces in empty objects.

These options are almost identical to those of the @stylistic/object-curly-spacing rule. See here for details.

🚀 Version

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

🔍 Implementation

Taken with ❤️ from ESLint core