You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add no-unnecessary-array-splice-count rule, Rename no-length-as-slice-end to no-unnecessary-slice-end, Support checking Infinity in no-unnecessary-slice-end (#2614)
# Disallow using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#{splice,toSpliced}()`
2
+
3
+
💼 This rule is enabled in the ✅ `recommended`[config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).
4
+
5
+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6
+
7
+
<!-- end auto-generated rule header -->
8
+
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` -->
9
+
10
+
<!-- Remove this comment, add more detailed description. -->
11
+
12
+
When calling `Array#splice(start, deleteCount)` and `Array#toSpliced(start, skipCount)`, omitting the `deleteCount` and `skipCount` argument will delete or skip all elements after `start`. Using `.length` or `Infinity` is unnecessary.
# Disallow using `.length` as the `end` argument of `{Array,String,TypedArray}#slice()`
1
+
# Disallow using `.length`or `Infinity`as the `end` argument of `{Array,String,TypedArray}#slice()`
2
2
3
3
💼 This rule is enabled in the ✅ `recommended`[config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config).
4
4
@@ -7,24 +7,30 @@
7
7
<!-- end auto-generated rule header -->
8
8
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` -->
9
9
10
-
When calling `{String,Array,TypedArray}#slice(start, end)`, omitting the `end` argument defaults it to the object's `.length`. Passing it explicitly is unnecessary.
10
+
When calling `{String,Array,TypedArray}#slice(start, end)`, omitting the `end` argument defaults it to the object's `.length`. Passing it explicitly or using `Infinity`is unnecessary.
Copy file name to clipboardExpand all lines: readme.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,6 @@ export default [
92
92
|[no-invalid-fetch-options](docs/rules/no-invalid-fetch-options.md)| Disallow invalid options in `fetch()` and `new Request()`. | ✅ |||
93
93
|[no-invalid-remove-event-listener](docs/rules/no-invalid-remove-event-listener.md)| Prevent calling `EventTarget#removeEventListener()` with the result of an expression. | ✅ |||
94
94
|[no-keyword-prefix](docs/rules/no-keyword-prefix.md)| Disallow identifiers starting with `new` or `class`. ||||
95
-
|[no-length-as-slice-end](docs/rules/no-length-as-slice-end.md)| Disallow using `.length` as the `end` argument of `{Array,String,TypedArray}#slice()`. | ✅ | 🔧 ||
96
95
|[no-lonely-if](docs/rules/no-lonely-if.md)| Disallow `if` statements as the only statement in `if` blocks without `else`. | ✅ | 🔧 ||
97
96
|[no-magic-array-flat-depth](docs/rules/no-magic-array-flat-depth.md)| Disallow a magic number as the `depth` argument in `Array#flat(…).`| ✅ |||
98
97
|[no-named-default](docs/rules/no-named-default.md)| Disallow named usage of default import and export. | ✅ | 🔧 ||
|[no-unnecessary-array-splice-count](docs/rules/no-unnecessary-array-splice-count.md)| Disallow using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#{splice,toSpliced}()`. | ✅ | 🔧 ||
|[no-unnecessary-polyfills](docs/rules/no-unnecessary-polyfills.md)| Enforce the use of built-in methods instead of unnecessary polyfills. | ✅ |||
114
+
|[no-unnecessary-slice-end](docs/rules/no-unnecessary-slice-end.md)| Disallow using `.length` or `Infinity` as the `end` argument of `{Array,String,TypedArray}#slice()`. | ✅ | 🔧 ||
0 commit comments