sonarjs/no-array-delete
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-array-delete": "error",
},
},
];var myArray = ['a', 'b', 'c', 'd'];
delete myArray[2]; // Noncompliant. myArray => ['a', 'b', undefined, 'd']
console.log(myArray[2]); // expected value was 'd' but output is undefinedvar myArray = ['a', 'b', 'c', 'd'];
// removes 1 element from index 2
removed = myArray.splice(2, 1); // myArray => ['a', 'b', 'd']
console.log(myArray[2]); // outputs 'd'Examples from the ESLint documentation.
sonarjs/no-array-delete
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-array-delete": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow using the delete operator on array values
Angular built-in sanitization should not be disabled
"Array.prototype.sort()" and "Array.prototype.toSorted()" should use a compare function
Constructors should not contain asynchronous operations
All branches in a conditional structure should not have exactly the same implementation