Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 7 rules of es-x/no-set-prototype-* #145

Merged
merged 14 commits into from
Jun 1, 2024
28 changes: 28 additions & 0 deletions docs/configs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -928,5 +928,33 @@ export default [
}
```

## no-set-methods

disallow proposal ES2025 [Set Methods for JavaScript](https://github.com/tc39/proposal-set-methods)\
⚠️ This config will be changed in the minor versions of this plugin.

This configs includes rules for [es-x/no-set-prototype-difference](../rules/no-set-prototype-difference.md), [es-x/no-set-prototype-intersection](../rules/no-set-prototype-intersection.md), [es-x/no-set-prototype-isdisjointfrom](../rules/no-set-prototype-isdisjointfrom.md), [es-x/no-set-prototype-issubsetof](../rules/no-set-prototype-issubsetof.md), [es-x/no-set-prototype-issupersetof](../rules/no-set-prototype-issupersetof.md), [es-x/no-set-prototype-symmetricdifference](../rules/no-set-prototype-symmetricdifference.md), and [es-x/no-set-prototype-union](../rules/no-set-prototype-union.md).

### [Config (Flat Config)]

eslint.config.js:

```js
import pluginESx from "eslint-plugin-es-x"
export default [
pluginESx.configs['flat/no-set-methods']
]
```

### [Legacy Config]

.eslintrc.*:

```json
{
"extends": ["plugin:es-x/no-set-methods"],
}
```

[Config (Flat Config)]: https://eslint.org/docs/latest/use/configure/configuration-files-new
[Legacy Config]: https://eslint.org/docs/latest/use/configure/configuration-files
14 changes: 14 additions & 0 deletions docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ This plugin provides the following rules.

- 🔧 mark means that the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by the rule.

## ES2025

There is a config that enables the rules in this category: [`no-new-in-esnext`]

| Rule ID | Description | |
|:--------|:------------|:--:|
| [es-x/no-set-prototype-difference](./no-set-prototype-difference.md) | disallow the `Set.prototype.difference` method. | |
| [es-x/no-set-prototype-intersection](./no-set-prototype-intersection.md) | disallow the `Set.prototype.intersection` method. | |
| [es-x/no-set-prototype-isdisjointfrom](./no-set-prototype-isdisjointfrom.md) | disallow the `Set.prototype.isDisjointFrom` method. | |
| [es-x/no-set-prototype-issubsetof](./no-set-prototype-issubsetof.md) | disallow the `Set.prototype.isSubsetOf` method. | |
| [es-x/no-set-prototype-issupersetof](./no-set-prototype-issupersetof.md) | disallow the `Set.prototype.isSupersetOf` method. | |
| [es-x/no-set-prototype-symmetricdifference](./no-set-prototype-symmetricdifference.md) | disallow the `Set.prototype.symmetricDifference` method. | |
| [es-x/no-set-prototype-union](./no-set-prototype-union.md) | disallow the `Set.prototype.union` method. | |

## ES2024

There is a config that enables the rules in this category: [`no-new-in-esnext`]
Expand Down
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-difference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-difference"
description: "disallow the `Set.prototype.difference` method"
---

# es-x/no-set-prototype-difference
> disallow the `Set.prototype.difference` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.difference`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-difference: error */
const a = new Set()
const b = new Set()
a.difference(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-difference.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-difference.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-intersection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-intersection"
description: "disallow the `Set.prototype.intersection` method"
---

# es-x/no-set-prototype-intersection
> disallow the `Set.prototype.intersection` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.intersection`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-intersection: error */
const a = new Set()
const b = new Set()
a.intersection(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-intersection.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-intersection.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-isdisjointfrom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-isdisjointfrom"
description: "disallow the `Set.prototype.isDisjointFrom` method"
---

# es-x/no-set-prototype-isdisjointfrom
> disallow the `Set.prototype.isDisjointFrom` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.isDisjointFrom`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-isdisjointfrom: error */
const a = new Set()
const b = new Set()
a.isDisjointFrom(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-isdisjointfrom.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-isdisjointfrom.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-issubsetof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-issubsetof"
description: "disallow the `Set.prototype.isSubsetOf` method"
---

# es-x/no-set-prototype-issubsetof
> disallow the `Set.prototype.isSubsetOf` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.isSubsetOf`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-issubsetof: error */
const a = new Set()
const b = new Set()
a.isSubsetOf(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-issubsetof.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-issubsetof.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-issupersetof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-issupersetof"
description: "disallow the `Set.prototype.isSupersetOf` method"
---

# es-x/no-set-prototype-issupersetof
> disallow the `Set.prototype.isSupersetOf` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.isSupersetOf`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-issupersetof: error */
const a = new Set()
const b = new Set()
a.isSupersetOf(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-issupersetof.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-issupersetof.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-symmetricdifference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-symmetricdifference"
description: "disallow the `Set.prototype.symmetricDifference` method"
---

# es-x/no-set-prototype-symmetricdifference
> disallow the `Set.prototype.symmetricDifference` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.symmetricDifference`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-symmetricdifference: error */
const a = new Set()
const b = new Set()
a.symmetricDifference(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-symmetricdifference.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-symmetricdifference.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
37 changes: 37 additions & 0 deletions docs/rules/no-set-prototype-union.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "es-x/no-set-prototype-union"
description: "disallow the `Set.prototype.union` method"
---

# es-x/no-set-prototype-union
> disallow the `Set.prototype.union` method

- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
- ✅ The following configurations enable this rule: [no-new-in-esnext] and [no-set-methods]

This rule reports ES2025 [`Set.prototype.union`](https://github.com/tc39/proposal-set-methods) methods as errors.

This rule is silent by default because it's hard to know types. You need to configure [the aggressive mode](../#the-aggressive-mode) or TypeScript in order to enable this rule.

## 💡 Examples

⛔ Examples of **incorrect** code for this rule:

<eslint-playground type="bad">

```js
/*eslint es-x/no-set-prototype-union: error */
const a = new Set()
const b = new Set()
a.union(b)
```

</eslint-playground>

## 📚 References

- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-set-prototype-union.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-set-prototype-union.js)

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
[no-set-methods]: ../configs/index.md#no-set-methods
7 changes: 7 additions & 0 deletions lib/configs/flat/no-new-in-esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ module.exports = {
},
},
rules: {
"es-x/no-set-prototype-difference": "error",
"es-x/no-set-prototype-intersection": "error",
"es-x/no-set-prototype-isdisjointfrom": "error",
"es-x/no-set-prototype-issubsetof": "error",
"es-x/no-set-prototype-issupersetof": "error",
"es-x/no-set-prototype-symmetricdifference": "error",
"es-x/no-set-prototype-union": "error",
"es-x/no-arraybuffer-prototype-transfer": "error",
"es-x/no-atomics-waitasync": "error",
"es-x/no-object-map-groupby": "error",
Expand Down
22 changes: 22 additions & 0 deletions lib/configs/flat/no-set-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* DON'T EDIT THIS FILE.
* This file was generated by "scripts/update-lib-flat-configs.js" script.
*/
"use strict"

module.exports = {
plugins: {
get "es-x"() {
return require("../../index.js")
},
},
rules: {
"es-x/no-set-prototype-difference": "error",
"es-x/no-set-prototype-intersection": "error",
"es-x/no-set-prototype-isdisjointfrom": "error",
"es-x/no-set-prototype-issubsetof": "error",
"es-x/no-set-prototype-issupersetof": "error",
"es-x/no-set-prototype-symmetricdifference": "error",
"es-x/no-set-prototype-union": "error",
},
}
7 changes: 7 additions & 0 deletions lib/configs/no-new-in-esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
module.exports = {
plugins: ["es-x"],
rules: {
"es-x/no-set-prototype-difference": "error",
"es-x/no-set-prototype-intersection": "error",
"es-x/no-set-prototype-isdisjointfrom": "error",
"es-x/no-set-prototype-issubsetof": "error",
"es-x/no-set-prototype-issupersetof": "error",
"es-x/no-set-prototype-symmetricdifference": "error",
"es-x/no-set-prototype-union": "error",
"es-x/no-arraybuffer-prototype-transfer": "error",
"es-x/no-atomics-waitasync": "error",
"es-x/no-object-map-groupby": "error",
Expand Down
18 changes: 18 additions & 0 deletions lib/configs/no-set-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* DON'T EDIT THIS FILE.
* This file was generated by "scripts/update-lib-configs.js" script.
*/
"use strict"

module.exports = {
plugins: ["es-x"],
rules: {
"es-x/no-set-prototype-difference": "error",
"es-x/no-set-prototype-intersection": "error",
"es-x/no-set-prototype-isdisjointfrom": "error",
"es-x/no-set-prototype-issubsetof": "error",
"es-x/no-set-prototype-issupersetof": "error",
"es-x/no-set-prototype-symmetricdifference": "error",
"es-x/no-set-prototype-union": "error",
},
}