# no-unnecessary-splice πŸ“ Disallow `Array#splice()` when simpler alternatives exist. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). Prefer clearer array methods over `Array#splice()` when no elements are removed, when adding or removing at the start or end, or when emptying an array. ## Examples ```js // ❌ array.splice(index, 0); // βœ… // Remove the no-op call. ``` ```js // ❌ array.splice(0, 1); // βœ… array.shift(); ``` ```js // ❌ array.splice(0, 0, item); // βœ… array.unshift(item); ``` ```js // ❌ array.splice(array.length - 1, 1); // βœ… array.pop(); ``` ```js // ❌ array.splice(array.length, 0, item); // βœ… array.push(item); ``` ```js // ❌ array.splice(0); // βœ… array.length = 0; ```