# no-unnecessary-slice-end

Disallow slice end arguments that cannot shorten the result

Passing the source length or positive infinity as a slice end selects every remaining value.
Instead, you SHOULD omit an end argument that cannot shorten the result.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function tail(values: int32[]): int32[] {
    return values.slice(1, values.length as isize);
}
```

## Accepted

```ds title="main.ds"
function tail(values: int32[]): int32[] {
    return values.slice(1);
}
```

## Prior art

- [eslint-plugin-unicorn · no-unnecessary-slice-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-slice-end.md)

[language/linter/src/rules/style/no_unnecessary_slice_end.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/no_unnecessary_slice_end.rs#L8)
