Skip to content

Commit 6fff93d

Browse files
authored
Add no-symbol-* rules (#264)
1 parent 5b615df commit 6fff93d

27 files changed

+598
-14
lines changed

.changeset/no-string-matchall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-es-x": minor
3+
---
4+
5+
Add `no-string-matchall` config.

.changeset/no-symbol-asyncdispose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-es-x": minor
3+
---
4+
5+
Add `es-x/no-symbol-asyncdispose` rule

.changeset/no-symbol-dispose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-es-x": minor
3+
---
4+
5+
Add `es-x/no-symbol-dispose` rule

.changeset/no-symbol-matchall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-es-x": minor
3+
---
4+
5+
Add `es-x/no-symbol-matchall` rule

.changeset/real-kiwis-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-es-x": major
3+
---
4+
5+
Update configs: `no-new-in-es2020`, and `restrict-to-es3` - `restrict-to-es2019`.

docs/configs/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,5 +1401,32 @@ export default [
14011401
}
14021402
```
14031403

1404+
## no-string-matchall
1405+
1406+
disallow proposal ES2020 [String.prototype.matchAll](https://github.com/tc39/proposal-string-matchall)
1407+
1408+
This configs includes rules for [es-x/no-string-prototype-matchall](../rules/no-string-prototype-matchall.md) and [es-x/no-symbol-matchall](../rules/no-symbol-matchall.md).
1409+
1410+
### [Config (Flat Config)]
1411+
1412+
eslint.config.js:
1413+
1414+
```js
1415+
import pluginESx from "eslint-plugin-es-x"
1416+
export default [
1417+
pluginESx.configs['flat/no-string-matchall']
1418+
]
1419+
```
1420+
1421+
### [Legacy Config]
1422+
1423+
.eslintrc.*:
1424+
1425+
```json
1426+
{
1427+
"extends": ["plugin:es-x/no-string-matchall"],
1428+
}
1429+
```
1430+
14041431
[Config (Flat Config)]: https://eslint.org/docs/latest/use/configure/configuration-files
14051432
[Legacy Config]: https://eslint.org/docs/latest/use/configure/configuration-files-deprecated

docs/rules/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ There are multiple configs that enable all rules in this category: [`no-new-in-e
5252
| [es-x/no-set-prototype-issupersetof](./no-set-prototype-issupersetof.md) | disallow the `Set.prototype.isSupersetOf` method. | |
5353
| [es-x/no-set-prototype-symmetricdifference](./no-set-prototype-symmetricdifference.md) | disallow the `Set.prototype.symmetricDifference` method. | |
5454
| [es-x/no-set-prototype-union](./no-set-prototype-union.md) | disallow the `Set.prototype.union` method. | |
55+
| [es-x/no-symbol-asyncdispose](./no-symbol-asyncdispose.md) | disallow the `Symbol.asyncDispose` property. | |
56+
| [es-x/no-symbol-dispose](./no-symbol-dispose.md) | disallow the `Symbol.dispose` property. | |
5557
| [es-x/no-trailing-dynamic-import-commas](./no-trailing-dynamic-import-commas.md) | disallow trailing commas in `import()`. | 🔧 |
5658

5759
## ES2025 Intl API
@@ -171,6 +173,7 @@ There are multiple configs that enable all rules in this category: [`no-new-in-e
171173
| [es-x/no-promise-all-settled](./no-promise-all-settled.md) | disallow `Promise.allSettled` function. | |
172174
| [es-x/no-regexp-unicode-property-escapes-2020](./no-regexp-unicode-property-escapes-2020.md) | disallow the new values of RegExp Unicode property escape sequences in ES2020. | |
173175
| [es-x/no-string-prototype-matchall](./no-string-prototype-matchall.md) | disallow the `String.prototype.matchAll` method. | |
176+
| [es-x/no-symbol-matchall](./no-symbol-matchall.md) | disallow the `Symbol.matchAll` property. | |
174177

175178
## ES2020 Intl API
176179

docs/rules/no-string-prototype-matchall.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ since: "[eslint-plugin-es] v5.0.0"
77
# es-x/no-string-prototype-matchall
88
> disallow the `String.prototype.matchAll` method
99
10-
- ✅ The following configurations enable this rule: [no-new-in-es2020], [restrict-to-es3], [restrict-to-es5], [restrict-to-es2015], [restrict-to-es2016], [restrict-to-es2017], [restrict-to-es2018], and [restrict-to-es2019]
10+
- ✅ The following configurations enable this rule: [no-new-in-es2020], [no-string-matchall], [restrict-to-es3], [restrict-to-es5], [restrict-to-es2015], [restrict-to-es2016], [restrict-to-es2017], [restrict-to-es2018], and [restrict-to-es2019]
1111

1212
This rule reports ES2020 [`String.prototype.matchAll` method](https://github.com/tc39/proposal-string-matchall) as errors.
1313

@@ -66,6 +66,7 @@ This rule was introduced in [eslint-plugin-es] v5.0.0.
6666
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-string-prototype-matchall.js)
6767

6868
[no-new-in-es2020]: ../configs/index.md#no-new-in-es2020
69+
[no-string-matchall]: ../configs/index.md#no-string-matchall
6970
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
7071
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
7172
[restrict-to-es2015]: ../configs/index.md#restrict-to-es2015

docs/rules/no-symbol-asyncdispose.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: "es-x/no-symbol-asyncdispose"
3+
description: "disallow the `Symbol.asyncDispose` property"
4+
---
5+
6+
# es-x/no-symbol-asyncdispose
7+
> disallow the `Symbol.asyncDispose` property
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-new-in-es2025], [restrict-to-es3], [restrict-to-es5], [restrict-to-es2015], [restrict-to-es2016], [restrict-to-es2017], [restrict-to-es2018], [restrict-to-es2019], [restrict-to-es2020], [restrict-to-es2021], [restrict-to-es2022], [restrict-to-es2023], and [restrict-to-es2024]
11+
12+
This rule reports ES2025 [`Symbol.asyncDispose` property]($$LINK$$) 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-symbol-asyncdispose: error */
22+
x[Symbol.asyncDispose];
23+
```
24+
25+
</eslint-playground>
26+
27+
## 🔧 Options
28+
29+
This rule has an option.
30+
31+
```jsonc
32+
{
33+
"rules": {
34+
"es-x/no-symbol-asyncdispose": [
35+
"error",
36+
{
37+
"allowTestedProperty": false
38+
}
39+
]
40+
}
41+
}
42+
```
43+
44+
### allowTestedProperty: boolean
45+
46+
Configure the allowTestedProperty mode for only this rule.
47+
This is prior to the `settings['es-x'].allowTestedProperty` setting.
48+
49+
## 📚 References
50+
51+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-symbol-asyncdispose.js)
52+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-symbol-asyncdispose.js)
53+
54+
[no-new-in-es2025]: ../configs/index.md#no-new-in-es2025
55+
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
56+
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
57+
[restrict-to-es2015]: ../configs/index.md#restrict-to-es2015
58+
[restrict-to-es2016]: ../configs/index.md#restrict-to-es2016
59+
[restrict-to-es2017]: ../configs/index.md#restrict-to-es2017
60+
[restrict-to-es2018]: ../configs/index.md#restrict-to-es2018
61+
[restrict-to-es2019]: ../configs/index.md#restrict-to-es2019
62+
[restrict-to-es2020]: ../configs/index.md#restrict-to-es2020
63+
[restrict-to-es2021]: ../configs/index.md#restrict-to-es2021
64+
[restrict-to-es2022]: ../configs/index.md#restrict-to-es2022
65+
[restrict-to-es2023]: ../configs/index.md#restrict-to-es2023
66+
[restrict-to-es2024]: ../configs/index.md#restrict-to-es2024

docs/rules/no-symbol-dispose.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: "es-x/no-symbol-dispose"
3+
description: "disallow the `Symbol.dispose` property"
4+
---
5+
6+
# es-x/no-symbol-dispose
7+
> disallow the `Symbol.dispose` property
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-new-in-es2025], [restrict-to-es3], [restrict-to-es5], [restrict-to-es2015], [restrict-to-es2016], [restrict-to-es2017], [restrict-to-es2018], [restrict-to-es2019], [restrict-to-es2020], [restrict-to-es2021], [restrict-to-es2022], [restrict-to-es2023], and [restrict-to-es2024]
11+
12+
This rule reports ES2025 [`Symbol.dispose` property]($$LINK$$) 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-symbol-dispose: error */
22+
x[Symbol.dispose];
23+
```
24+
25+
</eslint-playground>
26+
27+
## 🔧 Options
28+
29+
This rule has an option.
30+
31+
```jsonc
32+
{
33+
"rules": {
34+
"es-x/no-symbol-dispose": [
35+
"error",
36+
{
37+
"allowTestedProperty": false
38+
}
39+
]
40+
}
41+
}
42+
```
43+
44+
### allowTestedProperty: boolean
45+
46+
Configure the allowTestedProperty mode for only this rule.
47+
This is prior to the `settings['es-x'].allowTestedProperty` setting.
48+
49+
## 📚 References
50+
51+
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-symbol-dispose.js)
52+
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-symbol-dispose.js)
53+
54+
[no-new-in-es2025]: ../configs/index.md#no-new-in-es2025
55+
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
56+
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
57+
[restrict-to-es2015]: ../configs/index.md#restrict-to-es2015
58+
[restrict-to-es2016]: ../configs/index.md#restrict-to-es2016
59+
[restrict-to-es2017]: ../configs/index.md#restrict-to-es2017
60+
[restrict-to-es2018]: ../configs/index.md#restrict-to-es2018
61+
[restrict-to-es2019]: ../configs/index.md#restrict-to-es2019
62+
[restrict-to-es2020]: ../configs/index.md#restrict-to-es2020
63+
[restrict-to-es2021]: ../configs/index.md#restrict-to-es2021
64+
[restrict-to-es2022]: ../configs/index.md#restrict-to-es2022
65+
[restrict-to-es2023]: ../configs/index.md#restrict-to-es2023
66+
[restrict-to-es2024]: ../configs/index.md#restrict-to-es2024

0 commit comments

Comments
 (0)