jsonc/no-sparse-arrays
disallow sparse arrays
- ⚙️ This rule is included in all of
"plugin:jsonc/recommended-with-json"
,"plugin:jsonc/recommended-with-json5"
and"plugin:jsonc/recommended-with-jsonc"
.
📖 Rule Details
This rule disallows sparse array literals which have "holes" where commas are not preceded by elements. It does not apply to a trailing comma following the last element.
JSON, JSONC and JSON5 do not allow arrays contain empty slots.
/* eslint jsonc/no-sparse-arrays: 'error' */
{
/* ✓ GOOD */
"GOOD": [1, 2, 3, 4],
"GOOD": [1, 2, 3, 4,],
/* ✗ BAD */
"BAD": [1, , , 4],
"BAD": [, 2, 3, 4]
}
🔧 Options
Nothing.
👫 Related rules
🚀 Version
This rule was introduced in eslint-plugin-jsonc v0.2.0
🔍 Implementation
Taken with ❤️ from ESLint core