# @typescript-eslint/no-array-delete

> Disallow `delete` on an element of an array

`delete items[1]` doesn't remove the element. It leaves a hole, so the array keeps its length and `items[1]` reads as `undefined`. To take the element out and close the gap, use `splice`.

The report comes with a suggestion that rewrites the `delete` as a `splice` call. That moves the later items, so only `--fix-dangerously` applies it, not `--fix-suggestions`.

`bun lint --type-aware` turns this rule on in TypeScript files.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. This rule needs types, so turning it on makes `bun lint` type check your code first.

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-array-delete" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```ts
const items = ["a", "b", "c"];

delete items[1]; // ["a", <empty>, "c"], length 3
```

Not reported:

{/* good */}
```ts
const items = ["a", "b", "c"];

items.splice(1, 1); // ["a", "c"], length 2

const scores: Record<string, number> = { ada: 1 };
delete scores["ada"];
```
