jsonc/comma-dangle
require or disallow trailing commas
- ⚙️ This rule is included in
"plugin:jsonc/recommended-with-json". - 🔧 The
--fixoption on the command line 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.
🔧 Options
json
{
"jsonc/comma-dangle": ["error",
"never"
],
// or
"jsonc/comma-dangle": ["error",
{
"arrays": "never",
"objects": "never"
}
]
}Same as comma-dangle rule option. See here 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.
👫 Related rules
🚀 Version
This rule was introduced in eslint-plugin-jsonc v0.1.0
🔍 Implementation
Taken with ❤️ from ESLint core