no-sparse-arrays
eslint
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-sparse-arrays": "error",
},
},
];const items = [,];
const colors = [ "red",, "blue" ];const items = [];
const arr = new Array(23);
// trailing comma (after the last element) is not a problem
const colors = [ "red", "blue", ];Examples from the ESLint documentation.
no-sparse-arrays
eslint
export default [
{
rules: {
"no-sparse-arrays": "error",
},
},
];no-sparse-arrays
eslint plugin · correctness
{
"rules": {
"no-sparse-arrays": "error"
}
}suspicious/noSparseArray
suspicious · since 1.0.0
{
"linter": {
"rules": {
"suspicious": {
"noSparseArray": "error"
}
}
}
}Disallow identifiers from shadowing restricted names
Require calls to isNaN() when checking for NaN
Disallow assignments to native objects or read-only global variables
Disallow control characters in regular expressions
Disallow reassigning exceptions in catch clauses