Skip to content

Commit 58029a5

Browse files
authored
Add no-iterator-helpers rules (#211)
1 parent 7887af8 commit 58029a5

File tree

56 files changed

+4694
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4694
-265
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
"javascript",
44
"vue"
55
],
6+
"typescript.tsdk": "node_modules/typescript/lib",
67
}

docs/configs/index.md

+28
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,34 @@ export default [
10311031
}
10321032
```
10331033

1034+
## no-iterator-helpers
1035+
1036+
disallow proposal ES2025 [Iterator Helpers](https://github.com/tc39/proposal-iterator-helpers)\
1037+
⚠️ This config will be changed in the minor versions of this plugin.
1038+
1039+
This configs includes rules for [es-x/no-iterator-prototype-drop](../rules/no-iterator-prototype-drop.md), [es-x/no-iterator-prototype-every](../rules/no-iterator-prototype-every.md), [es-x/no-iterator-prototype-filter](../rules/no-iterator-prototype-filter.md), [es-x/no-iterator-prototype-find](../rules/no-iterator-prototype-find.md), [es-x/no-iterator-prototype-flatmap](../rules/no-iterator-prototype-flatmap.md), [es-x/no-iterator-prototype-foreach](../rules/no-iterator-prototype-foreach.md), [es-x/no-iterator-prototype-map](../rules/no-iterator-prototype-map.md), [es-x/no-iterator-prototype-reduce](../rules/no-iterator-prototype-reduce.md), [es-x/no-iterator-prototype-some](../rules/no-iterator-prototype-some.md), [es-x/no-iterator-prototype-take](../rules/no-iterator-prototype-take.md), [es-x/no-iterator-prototype-toarray](../rules/no-iterator-prototype-toarray.md), and [es-x/no-iterator](../rules/no-iterator.md).
1040+
1041+
### [Config (Flat Config)]
1042+
1043+
eslint.config.js:
1044+
1045+
```js
1046+
import pluginESx from "eslint-plugin-es-x"
1047+
export default [
1048+
pluginESx.configs['flat/no-iterator-helpers']
1049+
]
1050+
```
1051+
1052+
### [Legacy Config]
1053+
1054+
.eslintrc.*:
1055+
1056+
```json
1057+
{
1058+
"extends": ["plugin:es-x/no-iterator-helpers"],
1059+
}
1060+
```
1061+
10341062
## no-set-methods
10351063

10361064
disallow proposal ES2025 [Set Methods for JavaScript](https://github.com/tc39/proposal-set-methods)\

docs/rules/index.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@ There is a config that enables the rules in this category: [`no-new-in-esnext`]
1010

1111
| Rule ID | Description | |
1212
|:--------|:------------|:--:|
13-
| [es-x/no-dynamic-import-options](./no-dynamic-import-options.md) | disallow second parameter to `import()`. | |
13+
| [es-x/no-dynamic-import-options](./no-dynamic-import-options.md) | disallow the second parameter to `import()`. | |
1414
| [es-x/no-import-attributes](./no-import-attributes.md) | disallow Import Attributes. | |
15+
| [es-x/no-iterator-prototype-drop](./no-iterator-prototype-drop.md) | disallow the `Iterator.prototype.drop` method. | |
16+
| [es-x/no-iterator-prototype-every](./no-iterator-prototype-every.md) | disallow the `Iterator.prototype.every` method. | |
17+
| [es-x/no-iterator-prototype-filter](./no-iterator-prototype-filter.md) | disallow the `Iterator.prototype.filter` method. | |
18+
| [es-x/no-iterator-prototype-find](./no-iterator-prototype-find.md) | disallow the `Iterator.prototype.find` method. | |
19+
| [es-x/no-iterator-prototype-flatmap](./no-iterator-prototype-flatmap.md) | disallow the `Iterator.prototype.flatMap` method. | |
20+
| [es-x/no-iterator-prototype-foreach](./no-iterator-prototype-foreach.md) | disallow the `Iterator.prototype.forEach` method. | |
21+
| [es-x/no-iterator-prototype-map](./no-iterator-prototype-map.md) | disallow the `Iterator.prototype.map` method. | |
22+
| [es-x/no-iterator-prototype-reduce](./no-iterator-prototype-reduce.md) | disallow the `Iterator.prototype.reduce` method. | |
23+
| [es-x/no-iterator-prototype-some](./no-iterator-prototype-some.md) | disallow the `Iterator.prototype.some` method. | |
24+
| [es-x/no-iterator-prototype-take](./no-iterator-prototype-take.md) | disallow the `Iterator.prototype.take` method. | |
25+
| [es-x/no-iterator-prototype-toarray](./no-iterator-prototype-toarray.md) | disallow the `Iterator.prototype.toArray` method. | |
26+
| [es-x/no-iterator](./no-iterator.md) | disallow the `Iterator` class. | |
1527
| [es-x/no-json-modules](./no-json-modules.md) | disallow JSON Modules. | |
1628
| [es-x/no-promise-try](./no-promise-try.md) | disallow `Promise.try` function. | |
1729
| [es-x/no-regexp-duplicate-named-capturing-groups](./no-regexp-duplicate-named-capturing-groups.md) | disallow RegExp duplicate named capturing groups. | |

docs/rules/no-dynamic-import-options.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: "es-x/no-dynamic-import-options"
3-
description: "disallow second parameter to `import()`"
3+
description: "disallow the second parameter to `import()`"
44
---
55

66
# es-x/no-dynamic-import-options
7-
> disallow second parameter to `import()`
7+
> disallow the second parameter to `import()`
88
99
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
1010
- ✅ The following configurations enable this rule: [no-import-attributes] and [no-new-in-esnext]
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-drop"
3+
description: "disallow the `Iterator.prototype.drop` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-drop
7+
> disallow the `Iterator.prototype.drop` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.drop`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-drop: error */
22+
const result = naturals()
23+
.drop(3);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-drop.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-drop.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-every"
3+
description: "disallow the `Iterator.prototype.every` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-every
7+
> disallow the `Iterator.prototype.every` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.every`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-every: error */
22+
const result = naturals()
23+
.every(n => n % 2);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-every.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-every.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-filter"
3+
description: "disallow the `Iterator.prototype.filter` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-filter
7+
> disallow the `Iterator.prototype.filter` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.filter`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-filter: error */
22+
const result = naturals()
23+
.filter(n => n % 2);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-filter.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-filter.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-find"
3+
description: "disallow the `Iterator.prototype.find` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-find
7+
> disallow the `Iterator.prototype.find` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.find`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-find: error */
22+
const result = naturals()
23+
.find(n => n % 2);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-find.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-find.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-flatmap"
3+
description: "disallow the `Iterator.prototype.flatMap` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-flatmap
7+
> disallow the `Iterator.prototype.flatMap` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.flatMap`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-flatmap: error */
22+
const result = naturals()
23+
.flatMap(n => [n, -n]);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-flatmap.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-flatmap.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-foreach"
3+
description: "disallow the `Iterator.prototype.forEach` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-foreach
7+
> disallow the `Iterator.prototype.forEach` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.forEach`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-foreach: error */
22+
const result = naturals()
23+
.forEach(n => {/* ... */});
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-foreach.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-foreach.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-map"
3+
description: "disallow the `Iterator.prototype.map` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-map
7+
> disallow the `Iterator.prototype.map` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.map`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-map: error */
22+
const result = naturals()
23+
.map(n => n % 2);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-map.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-map.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "es-x/no-iterator-prototype-reduce"
3+
description: "disallow the `Iterator.prototype.reduce` method"
4+
---
5+
6+
# es-x/no-iterator-prototype-reduce
7+
> disallow the `Iterator.prototype.reduce` method
8+
9+
- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
10+
- ✅ The following configurations enable this rule: [no-iterator-helpers] and [no-new-in-esnext]
11+
12+
This rule reports ES2025 [`Iterator.prototype.reduce`](https://github.com/tc39/proposal-iterator-helpers) as errors.\
13+
14+
## 💡 Examples
15+
16+
⛔ Examples of **incorrect** code for this rule:
17+
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-iterator-prototype-reduce: error */
22+
const result = naturals()
23+
.reduce((sum, value) => sum + value, 3);
24+
25+
function* naturals() {
26+
// ...
27+
}
28+
```
29+
30+
</eslint-playground>
31+
32+
## 📚 References
33+
34+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-iterator-prototype-reduce.js)
35+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-iterator-prototype-reduce.js)
36+
37+
[no-iterator-helpers]: ../configs/index.md#no-iterator-helpers
38+
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext

0 commit comments

Comments
 (0)