# no-confusing-array-splice

Rule `unicorn/no-confusing-array-splice`. Disallow confusing uses of `Array#{splice,toSpliced}()`.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 40.5M weekly downloads of presets that enable it
- Trend: +81.2% last quarter
- Rank: #446 by reach, #438 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-confusing-array-splice` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-confusing-array-splice.md) |
| Biome | `nursery/noConfusingArraySplice` | yes | unsafe | group nursery, since 2.6.8 | [docs](https://biomejs.dev/linter/rules/no-confusing-array-splice/) |

## Code examples

### Incorrect: the rule reports this

```js
array.splice(index, 1, element);
```

```js
const result = array.toSpliced(index, 1, element);
```

```js
array.splice(-1, 0, element);
```

### Correct: the rule accepts this

```js
array[index] = element;
```

```js
const result = array.with(index, element);
```

```js
const insertionIndex = Math.max(array.length - 1, 0);
array.splice(insertionIndex, 0, element);
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-confusing-array-splice": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noConfusingArraySplice": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-while-loop-condition](https://lintradar.dev/rules/unicorn/prefer-while-loop-condition.md): Prefer putting the condition in the while statement.
- [unicorn/no-duplicate-loops](https://lintradar.dev/rules/unicorn/no-duplicate-loops.md): Disallow `.map()` and `.filter()` in `for…of` and `for await…of` loop headers.
- [unicorn/prefer-unary-minus](https://lintradar.dev/rules/unicorn/prefer-unary-minus.md): Prefer the unary minus operator over multiplying or dividing by `-1`.
- [unicorn/no-late-current-target-access](https://lintradar.dev/rules/unicorn/no-late-current-target-access.md): Disallow accessing `event.currentTarget` after the synchronous event dispatch has finished.
- [unicorn/prefer-math-constants](https://lintradar.dev/rules/unicorn/prefer-math-constants.md): Prefer `Math` constants over their approximate numeric values.
- [unicorn/no-late-event-control](https://lintradar.dev/rules/unicorn/no-late-event-control.md): Disallow event-control method calls after the synchronous event dispatch has finished.

---

Web page: https://lintradar.dev/rules/unicorn/no-confusing-array-splice. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
