# jsonc/comma-dangle

require or disallow trailing commas

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

# 📖 Rule Details

This rule enforces consistent use of trailing commas in object and array literals.

Now loading...

# 🔧 Options

{
    "jsonc/comma-dangle": ["error",
        "never"
    ],
    // or
    "jsonc/comma-dangle": ["error",
        {
            "arrays": "never",
            "objects": "never"
        }
    ]
}

Same as comma-dangle (opens new window) rule option. See here (opens new window) for details.

  • "never" (default) ... disallows trailing commas
  • "always" ... requires trailing commas
  • "always-multiline" ... requires trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }
  • "only-multiline" ... allows (but does not require) trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }

You can also use an object option to configure this rule for each type of syntax.

# 🚀 Version

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

# 🔍 Implementation

Taken with ❤️ from ESLint core (opens new window)

Last Updated: 10/28/2022, 6:54:42 PM