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
# Enforce combining multiple `Array#push()`, `Element#classList.{add,remove}()`, and `importScripts()` into one call
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) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
6
+
7
+
<!-- end auto-generated rule header -->
8
+
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` -->
9
+
10
+
[`Array#push()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push), [`Element#classList.add()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList), [`Element#classList.remove()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList), and [`importScripts`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts) accepts multiple arguments. Multiple calls should be combined into one.
11
+
12
+
## Examples
13
+
14
+
```js
15
+
// ❌
16
+
foo.push(1);
17
+
foo.push(2, 3);
18
+
19
+
// ✅
20
+
foo.push(1, 2, 3);
21
+
```
22
+
23
+
```js
24
+
// ❌
25
+
element.classList.add('foo');
26
+
element.classList.add('bar', 'baz');
27
+
28
+
// ✅
29
+
element.classList.add('foo', 'bar', 'baz');
30
+
```
31
+
32
+
```js
33
+
// ❌
34
+
importScripts("https://example.com/foo.js");
35
+
importScripts("https://example.com/bar.js");
36
+
37
+
// ✅
38
+
importScripts(
39
+
"https://example.com/foo.js",
40
+
"https://example.com/bar.js",
41
+
);
42
+
```
43
+
44
+
## Options
45
+
46
+
Type: `object`
47
+
48
+
### ignore
49
+
50
+
Type: `string[]`
51
+
52
+
Functions to ignore.
53
+
54
+
`stream.push`, `this.push`, and `this.stream.push` are ignored by default.
Copy file name to clipboardExpand all lines: readme.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,6 @@ export default [
79
79
|[no-array-callback-reference](docs/rules/no-array-callback-reference.md)| Prevent passing a function reference directly to iterator methods. | ✅ || 💡 |
80
80
|[no-array-for-each](docs/rules/no-array-for-each.md)| Prefer `for…of` over the `forEach` method. | ✅ | 🔧 | 💡 |
81
81
|[no-array-method-this-argument](docs/rules/no-array-method-this-argument.md)| Disallow using the `this` argument in array methods. | ✅ | 🔧 | 💡 |
82
-
|[no-array-push-push](docs/rules/no-array-push-push.md)| Enforce combining multiple `Array#push()` into one call. | ✅ | 🔧 | 💡 |
83
82
|[no-array-reduce](docs/rules/no-array-reduce.md)| Disallow `Array#reduce()` and `Array#reduceRight()`. | ✅ |||
84
83
|[no-await-expression-member](docs/rules/no-await-expression-member.md)| Disallow member access from await expression. | ✅ | 🔧 ||
85
84
|[no-await-in-promise-methods](docs/rules/no-await-in-promise-methods.md)| Disallow using `await` in `Promise` method parameters. | ✅ || 💡 |
@@ -165,6 +164,7 @@ export default [
165
164
|[prefer-regexp-test](docs/rules/prefer-regexp-test.md)| Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`. | ✅ | 🔧 | 💡 |
166
165
|[prefer-set-has](docs/rules/prefer-set-has.md)| Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. | ✅ | 🔧 | 💡 |
167
166
|[prefer-set-size](docs/rules/prefer-set-size.md)| Prefer using `Set#size` instead of `Array#length`. | ✅ | 🔧 ||
167
+
|[prefer-single-call](docs/rules/prefer-single-call.md)| Enforce combining multiple `Array#push()`, `Element#classList.{add,remove}()`, and `importScripts()` into one call. | ✅ | 🔧 | 💡 |
168
168
|[prefer-spread](docs/rules/prefer-spread.md)| Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()` and `String#split('')`. | ✅ | 🔧 | 💡 |
169
169
|[prefer-string-raw](docs/rules/prefer-string-raw.md)| Prefer using the `String.raw` tag to avoid escaping `\`. | ✅ | 🔧 ||
170
170
|[prefer-string-replace-all](docs/rules/prefer-string-replace-all.md)| Prefer `String#replaceAll()` over regex searches with the global flag. | ✅ | 🔧 ||
0 commit comments