# no-length-as-slice-end

Rule `unicorn/no-length-as-slice-end`. Replaced by `unicorn/no-unnecessary-slice-end` which covers more cases.

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-length-as-slice-end` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/deleted-and-deprecated-rules.md#no-length-as-slice-end) |
| Oxlint | `unicorn/no-length-as-slice-end` | no | safe | plugin `unicorn`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.html) |

## Code examples

### Incorrect: the rule reports this

```js
foo.slice(1, foo.length)
```

### Correct: the rule accepts this

```js
foo.slice(1)
```

Examples from the Oxlint documentation.

## Enable it

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

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

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-length-as-slice-end": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/no-length-as-slice-end": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [unicorn/prefer-import-meta-properties](https://lintradar.dev/rules/unicorn/prefer-import-meta-properties.md): Prefer `import.meta.{dirname,filename}` over legacy techniques for getting file paths.
- [unicorn/require-post-message-target-origin](https://lintradar.dev/rules/unicorn/require-post-message-target-origin.md): Enforce using the `targetOrigin` argument with `window.postMessage()`.
- [unicorn/custom-error-definition](https://lintradar.dev/rules/unicorn/custom-error-definition.md): Enforce correct `Error` subclassing.
- [unicorn/no-array-for-each](https://lintradar.dev/rules/unicorn/no-array-for-each.md): Forbids the use of `Array#forEach` in favor of a for loop.
- [unicorn/no-invalid-file-input-accept](https://lintradar.dev/rules/unicorn/no-invalid-file-input-accept.md): Disallow invalid `accept` values on file inputs.
- [unicorn/no-empty-link-text](https://lintradar.dev/rules/unicorn/no-empty-link-text.md): Disallow empty link text in Markdown.

---

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