Skip to content

Commit

Permalink
feat!: separate the rules of ES2022 - ES2024 by features (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Jul 1, 2024
1 parent e0a952c commit 3a31ae4
Show file tree
Hide file tree
Showing 76 changed files with 2,954 additions and 236 deletions.
162 changes: 162 additions & 0 deletions docs/configs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,167 @@ export default [
}
```

## no-array-grouping

disallow proposal ES2024 [Array Grouping](https://github.com/tc39/proposal-array-grouping)

This configs includes rules for [es-x/no-map-groupby](../rules/no-map-groupby.md) and [es-x/no-object-groupby](../rules/no-object-groupby.md).

### [Config (Flat Config)]

eslint.config.js:

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

### [Legacy Config]

.eslintrc.*:

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

## no-is-usv-string

disallow proposal ES2024 [Well-Formed Unicode Strings](https://github.com/tc39/proposal-is-usv-string)

This configs includes rules for [es-x/no-string-prototype-iswellformed](../rules/no-string-prototype-iswellformed.md) and [es-x/no-string-prototype-towellformed](../rules/no-string-prototype-towellformed.md).

### [Config (Flat Config)]

eslint.config.js:

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

### [Legacy Config]

.eslintrc.*:

```json
{
"extends": ["plugin:es-x/no-is-usv-string"],
}
```

## no-change-array-by-copy

disallow proposal ES2023 [Change Array by Copy](https://github.com/tc39/proposal-change-array-by-copy)

This configs includes rules for [es-x/no-array-prototype-toreversed](../rules/no-array-prototype-toreversed.md), [es-x/no-array-prototype-tosorted](../rules/no-array-prototype-tosorted.md), [es-x/no-array-prototype-tospliced](../rules/no-array-prototype-tospliced.md), and [es-x/no-array-prototype-with](../rules/no-array-prototype-with.md).

### [Config (Flat Config)]

eslint.config.js:

```js
import pluginESx from "eslint-plugin-es-x"
export default [
pluginESx.configs['flat/no-change-array-by-copy']
]
```

### [Legacy Config]

.eslintrc.*:

```json
{
"extends": ["plugin:es-x/no-change-array-by-copy"],
}
```

## no-intl-numberformat-v3

disallow proposal ES2023 Intl API [Intl.NumberFormat V3](https://github.com/tc39/proposal-intl-numberformat-v3)

This configs includes rules for [es-x/no-intl-numberformat-prototype-formatrange](../rules/no-intl-numberformat-prototype-formatrange.md), [es-x/no-intl-numberformat-prototype-formatrangetoparts](../rules/no-intl-numberformat-prototype-formatrangetoparts.md), and [es-x/no-intl-pluralrules-prototype-selectrange](../rules/no-intl-pluralrules-prototype-selectrange.md).

### [Config (Flat Config)]

eslint.config.js:

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

### [Legacy Config]

.eslintrc.*:

```json
{
"extends": ["plugin:es-x/no-intl-numberformat-v3"],
}
```

## no-class-fields

disallow proposal ES2022 [Class Fields](https://github.com/tc39/proposal-class-fields)

This configs includes rules for [es-x/no-class-instance-fields](../rules/no-class-instance-fields.md), [es-x/no-class-private-fields](../rules/no-class-private-fields.md), [es-x/no-class-private-methods](../rules/no-class-private-methods.md), and [es-x/no-class-static-fields](../rules/no-class-static-fields.md).

### [Config (Flat Config)]

eslint.config.js:

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

### [Legacy Config]

.eslintrc.*:

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

## no-relative-indexing-method

disallow proposal ES2022 [An .at() method on all the built-in indexables](https://github.com/tc39/proposal-relative-indexing-method)

This configs includes rules for [es-x/no-array-prototype-at](../rules/no-array-prototype-at.md) and [es-x/no-string-prototype-at](../rules/no-string-prototype-at.md).

### [Config (Flat Config)]

eslint.config.js:

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

### [Legacy Config]

.eslintrc.*:

```json
{
"extends": ["plugin:es-x/no-relative-indexing-method"],
}
```

[Config (Flat Config)]: https://eslint.org/docs/latest/use/configure/configuration-files-new
[Legacy Config]: https://eslint.org/docs/latest/use/configure/configuration-files
25 changes: 21 additions & 4 deletions docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ There are multiple configs that enable all rules in this category: [`no-new-in-e
|:--------|:------------|:--:|
| [es-x/no-arraybuffer-prototype-transfer](./no-arraybuffer-prototype-transfer.md) | disallow the `ArrayBuffer.prototype.transfer` method. | |
| [es-x/no-atomics-waitasync](./no-atomics-waitasync.md) | disallow the `Atomics.waitAsync` method. | |
| [es-x/no-object-map-groupby](./no-object-map-groupby.md) | disallow the `{Object,Map}.groupBy()` function (array grouping). | |
| [es-x/no-map-groupby](./no-map-groupby.md) | disallow the `Map.groupBy()` method. | |
| [es-x/no-object-groupby](./no-object-groupby.md) | disallow the `Object.groupBy()` method. | |
| [es-x/no-promise-withresolvers](./no-promise-withresolvers.md) | disallow the `Promise.withResolvers()` method. | |
| [es-x/no-regexp-v-flag](./no-regexp-v-flag.md) | disallow RegExp `v` flag. | |
| [es-x/no-resizable-and-growable-arraybuffers](./no-resizable-and-growable-arraybuffers.md) | disallow resizable and growable ArrayBuffers. | |
| [es-x/no-string-prototype-iswellformed-towellformed](./no-string-prototype-iswellformed-towellformed.md) | disallow the `String.prototype.{isWellFormed,toWellFormed}` methods. | |
| [es-x/no-string-prototype-iswellformed](./no-string-prototype-iswellformed.md) | disallow the `String.prototype.isWellFormed` methods. | |
| [es-x/no-string-prototype-towellformed](./no-string-prototype-towellformed.md) | disallow the `String.prototype.toWellFormed` methods. | |

## ES2023

Expand Down Expand Up @@ -64,14 +66,18 @@ There are multiple configs that enable all rules in this category: [`no-new-in-e
| Rule ID | Description | |
|:--------|:------------|:--:|
| [es-x/no-arbitrary-module-namespace-names](./no-arbitrary-module-namespace-names.md) | disallow arbitrary module namespace names. | |
| [es-x/no-array-string-prototype-at](./no-array-string-prototype-at.md) | disallow the `{Array,String}.prototype.at()` methods. | |
| [es-x/no-class-fields](./no-class-fields.md) | disallow class fields. | |
| [es-x/no-array-prototype-at](./no-array-prototype-at.md) | disallow the `Array.prototype.at()` methods. | |
| [es-x/no-class-instance-fields](./no-class-instance-fields.md) | disallow instance class fields. | |
| [es-x/no-class-private-fields](./no-class-private-fields.md) | disallow private class fields. | |
| [es-x/no-class-private-methods](./no-class-private-methods.md) | disallow private class methods. | |
| [es-x/no-class-static-block](./no-class-static-block.md) | disallow class static block. | |
| [es-x/no-class-static-fields](./no-class-static-fields.md) | disallow static class fields. | |
| [es-x/no-error-cause](./no-error-cause.md) | disallow Error Cause. | |
| [es-x/no-object-hasown](./no-object-hasown.md) | disallow the `Object.hasOwn` method. | |
| [es-x/no-private-in](./no-private-in.md) | disallow `#x in obj`. | |
| [es-x/no-regexp-d-flag](./no-regexp-d-flag.md) | disallow RegExp `d` flag. | |
| [es-x/no-regexp-unicode-property-escapes-2022](./no-regexp-unicode-property-escapes-2022.md) | disallow the new values of RegExp Unicode property escape sequences in ES2022. | |
| [es-x/no-string-prototype-at](./no-string-prototype-at.md) | disallow the `String.prototype.at()` methods. | |
| [es-x/no-top-level-await](./no-top-level-await.md) | disallow top-level `await`. | |

## ES2022 Intl API
Expand Down Expand Up @@ -353,6 +359,17 @@ Rules in this category are not included in any preset.
| [es-x/no-string-prototype-substr](./no-string-prototype-substr.md) | disallow the `String.prototype.substr` method. | |
| [es-x/no-string-prototype-trimleft-trimright](./no-string-prototype-trimleft-trimright.md) | disallow the `String.prototype.{trimLeft,trimRight}` methods. | 🔧 |

## Deprecated

😇 We don't fix bugs which are in deprecated rules since we don't have enough resources.

| Rule ID | Replaced By |
|:--------|:------------:|
| [es-x/no-array-string-prototype-at](./no-array-string-prototype-at.md) | [es-x/no-array-prototype-at](./no-array-prototype-at.md), [es-x/no-string-prototype-at](./no-string-prototype-at.md) |
| [es-x/no-class-fields](./no-class-fields.md) | [es-x/no-class-instance-fields](./no-class-instance-fields.md), [es-x/no-class-private-fields](./no-class-private-fields.md), [es-x/no-class-private-methods](./no-class-private-methods.md), [es-x/no-class-static-fields](./no-class-static-fields.md) |
| [es-x/no-object-map-groupby](./no-object-map-groupby.md) | [es-x/no-object-groupby](./no-object-groupby.md), [es-x/no-map-groupby](./no-map-groupby.md) |
| [es-x/no-string-prototype-iswellformed-towellformed](./no-string-prototype-iswellformed-towellformed.md) | [es-x/no-string-prototype-iswellformed](./no-string-prototype-iswellformed.md), [es-x/no-string-prototype-towellformed](./no-string-prototype-towellformed.md) |

[`no-new-in-esnext`]: ../configs/index.md#no-new-in-esnext
[`no-new-in-es2024`]: ../configs/index.md#no-new-in-es2024
[`restrict-to-es2023`]: ../configs/index.md#restrict-to-es2023
Expand Down
58 changes: 58 additions & 0 deletions docs/rules/no-array-prototype-at.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: "es-x/no-array-prototype-at"
description: "disallow the `Array.prototype.at()` methods"
---

# es-x/no-array-prototype-at
> disallow the `Array.prototype.at()` methods
- ❗ <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-es2022], [no-relative-indexing-method], [restrict-to-es3], [restrict-to-es5], [restrict-to-es2015], [restrict-to-es2016], [restrict-to-es2017], [restrict-to-es2018], [restrict-to-es2019], [restrict-to-es2020], and [restrict-to-es2021]

This rule reports ES2022 [`{Array,TypedArray}.prototype.at` methods](https://github.com/tc39/proposal-relative-indexing-method) 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-array-prototype-at: [error, { aggressive: true }] */
[foo].at(-1)
```

</eslint-playground>

## 🔧 Options

This rule has an option.

```yaml
rules:
es-x/no-array-prototype-at: [error, { aggressive: false }]
```
### aggressive: boolean
Configure the aggressive mode for only this rule.
This is prior to the `settings['es-x'].aggressive` setting.

## 📚 References

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

[no-new-in-es2022]: ../configs/index.md#no-new-in-es2022
[no-relative-indexing-method]: ../configs/index.md#no-relative-indexing-method
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
[restrict-to-es2015]: ../configs/index.md#restrict-to-es2015
[restrict-to-es2016]: ../configs/index.md#restrict-to-es2016
[restrict-to-es2017]: ../configs/index.md#restrict-to-es2017
[restrict-to-es2018]: ../configs/index.md#restrict-to-es2018
[restrict-to-es2019]: ../configs/index.md#restrict-to-es2019
[restrict-to-es2020]: ../configs/index.md#restrict-to-es2020
[restrict-to-es2021]: ../configs/index.md#restrict-to-es2021
3 changes: 2 additions & 1 deletion docs/rules/no-array-prototype-toreversed.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v6.0.0"
# es-x/no-array-prototype-toreversed
> disallow the `Array.prototype.toReversed` method
- ✅ The following configurations enable this rule: [no-new-in-es2023], [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], and [restrict-to-es2022]
- ✅ The following configurations enable this rule: [no-change-array-by-copy], [no-new-in-es2023], [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], and [restrict-to-es2022]

This rule reports ES2023 [`Array.prototype.toReversed` methods](https://github.com/tc39/proposal-change-array-by-copy) as errors.

Expand Down Expand Up @@ -49,6 +49,7 @@ This rule was introduced in v6.0.0.
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-array-prototype-toreversed.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-array-prototype-toreversed.js)

[no-change-array-by-copy]: ../configs/index.md#no-change-array-by-copy
[no-new-in-es2023]: ../configs/index.md#no-new-in-es2023
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/no-array-prototype-tosorted.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v6.0.0"
# es-x/no-array-prototype-tosorted
> disallow the `Array.prototype.toSorted` method
- ✅ The following configurations enable this rule: [no-new-in-es2023], [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], and [restrict-to-es2022]
- ✅ The following configurations enable this rule: [no-change-array-by-copy], [no-new-in-es2023], [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], and [restrict-to-es2022]

This rule reports ES2023 [`Array.prototype.toSorted` methods](https://github.com/tc39/proposal-change-array-by-copy) as errors.

Expand Down Expand Up @@ -49,6 +49,7 @@ This rule was introduced in v6.0.0.
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-array-prototype-tosorted.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-array-prototype-tosorted.js)

[no-change-array-by-copy]: ../configs/index.md#no-change-array-by-copy
[no-new-in-es2023]: ../configs/index.md#no-new-in-es2023
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/no-array-prototype-tospliced.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v6.0.0"
# es-x/no-array-prototype-tospliced
> disallow the `Array.prototype.toSpliced` method
- ✅ The following configurations enable this rule: [no-new-in-es2023], [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], and [restrict-to-es2022]
- ✅ The following configurations enable this rule: [no-change-array-by-copy], [no-new-in-es2023], [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], and [restrict-to-es2022]

This rule reports ES2023 [`Array.prototype.toSpliced` methods](https://github.com/tc39/proposal-change-array-by-copy) as errors.

Expand Down Expand Up @@ -49,6 +49,7 @@ This rule was introduced in v6.0.0.
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-array-prototype-tospliced.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-array-prototype-tospliced.js)

[no-change-array-by-copy]: ../configs/index.md#no-change-array-by-copy
[no-new-in-es2023]: ../configs/index.md#no-new-in-es2023
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/no-array-prototype-with.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v6.0.0"
# es-x/no-array-prototype-with
> disallow the `Array.prototype.with` method
- ✅ The following configurations enable this rule: [no-new-in-es2023], [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], and [restrict-to-es2022]
- ✅ The following configurations enable this rule: [no-change-array-by-copy], [no-new-in-es2023], [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], and [restrict-to-es2022]

This rule reports ES2023 [`Array.prototype.with` methods](https://github.com/tc39/proposal-change-array-by-copy) as errors.

Expand Down Expand Up @@ -49,6 +49,7 @@ This rule was introduced in v6.0.0.
- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-array-prototype-with.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-array-prototype-with.js)

[no-change-array-by-copy]: ../configs/index.md#no-change-array-by-copy
[no-new-in-es2023]: ../configs/index.md#no-new-in-es2023
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
Expand Down
13 changes: 1 addition & 12 deletions docs/rules/no-array-string-prototype-at.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v5.0.0"
# es-x/no-array-string-prototype-at
> disallow the `{Array,String}.prototype.at()` methods
- ✅ The following configurations enable this rule: [no-new-in-es2022], [restrict-to-es3], [restrict-to-es5], [restrict-to-es2015], [restrict-to-es2016], [restrict-to-es2017], [restrict-to-es2018], [restrict-to-es2019], [restrict-to-es2020], and [restrict-to-es2021]
- 🚫 This rule was deprecated and replaced by [es-x/no-array-prototype-at](./no-array-prototype-at.md),[es-x/no-string-prototype-at](./no-string-prototype-at.md) rules.

This rule reports ES2022 [`{Array,String,TypedArray}.prototype.at` methods](https://github.com/tc39/proposal-relative-indexing-method) as errors.

Expand Down Expand Up @@ -49,14 +49,3 @@ This rule was introduced in v5.0.0.

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

[no-new-in-es2022]: ../configs/index.md#no-new-in-es2022
[restrict-to-es3]: ../configs/index.md#restrict-to-es3
[restrict-to-es5]: ../configs/index.md#restrict-to-es5
[restrict-to-es2015]: ../configs/index.md#restrict-to-es2015
[restrict-to-es2016]: ../configs/index.md#restrict-to-es2016
[restrict-to-es2017]: ../configs/index.md#restrict-to-es2017
[restrict-to-es2018]: ../configs/index.md#restrict-to-es2018
[restrict-to-es2019]: ../configs/index.md#restrict-to-es2019
[restrict-to-es2020]: ../configs/index.md#restrict-to-es2020
[restrict-to-es2021]: ../configs/index.md#restrict-to-es2021
Loading

0 comments on commit 3a31ae4

Please sign in to comment.