Skip to content

Commit

Permalink
feat!: separate rules by features
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Apr 19, 2024
1 parent 2533c59 commit 861e11e
Show file tree
Hide file tree
Showing 22 changed files with 726 additions and 56 deletions.
61 changes: 43 additions & 18 deletions docs/configs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This plugin provides the following configs.

## no-new-in-esnext

disallow the new stuff to be planned for the next yearly ECMAScript snapshot.
disallow the new stuff to be planned for the next yearly ECMAScript snapshot.\
⚠️ This config will be changed in the minor versions of this plugin.

### [Config (Flat Config)]
Expand All @@ -30,7 +30,7 @@ export default [

## no-new-in-es2023

disallow new stuff that ES2023 doesn't include.
disallow new stuff in ES2023.

### [Config (Flat Config)]

Expand All @@ -55,7 +55,7 @@ export default [

## no-new-in-es2023-intl-api

disallow new stuff that ES2023 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2023 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -80,7 +80,7 @@ export default [

## no-new-in-es2022

disallow new stuff that ES2022 doesn't include.
disallow new stuff in ES2022.

### [Config (Flat Config)]

Expand All @@ -105,7 +105,7 @@ export default [

## no-new-in-es2022-intl-api

disallow new stuff that ES2022 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2022 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -130,7 +130,7 @@ export default [

## no-new-in-es2021

disallow new stuff that ES2021 doesn't include.
disallow new stuff in ES2021.

### [Config (Flat Config)]

Expand All @@ -155,7 +155,7 @@ export default [

## no-new-in-es2021-intl-api

disallow new stuff that ES2021 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2021 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -180,7 +180,7 @@ export default [

## no-new-in-es2020

disallow new stuff that ES2020 doesn't include.
disallow new stuff in ES2020.

### [Config (Flat Config)]

Expand All @@ -205,7 +205,7 @@ export default [

## no-new-in-es2020-intl-api

disallow new stuff that ES2020 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2020 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -230,7 +230,7 @@ export default [

## no-new-in-es2019

disallow new stuff that ES2019 doesn't include.
disallow new stuff in ES2019.

### [Config (Flat Config)]

Expand All @@ -255,7 +255,7 @@ export default [

## no-new-in-es2018

disallow new stuff that ES2018 doesn't include.
disallow new stuff in ES2018.

### [Config (Flat Config)]

Expand All @@ -280,7 +280,7 @@ export default [

## no-new-in-es2018-intl-api

disallow new stuff that ES2018 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2018 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -305,7 +305,7 @@ export default [

## no-new-in-es2017

disallow new stuff that ES2017 doesn't include.
disallow new stuff in ES2017.

### [Config (Flat Config)]

Expand All @@ -330,7 +330,7 @@ export default [

## no-new-in-es2017-intl-api

disallow new stuff that ES2017 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2017 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -355,7 +355,7 @@ export default [

## no-new-in-es2016

disallow new stuff that ES2016 doesn't include.
disallow new stuff in ES2016.

### [Config (Flat Config)]

Expand All @@ -380,7 +380,7 @@ export default [

## no-new-in-es2016-intl-api

disallow new stuff that ES2016 Intl API (ECMA-402) doesn't include.
disallow new stuff in ES2016 Intl API (ECMA-402).

### [Config (Flat Config)]

Expand All @@ -405,7 +405,7 @@ export default [

## no-new-in-es2015

disallow new stuff that ES2015 doesn't include.
disallow new stuff in ES2015.

### [Config (Flat Config)]

Expand All @@ -430,7 +430,7 @@ export default [

## no-new-in-es5

disallow new stuff that ES5 doesn't include.
disallow new stuff in ES5.

### [Config (Flat Config)]

Expand All @@ -453,6 +453,31 @@ export default [
}
```

## no-is-usv-string

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

### [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"],
}
```

## restrict-to-es2022

disallow new stuff that ES2023 doesn't include
Expand Down
13 changes: 11 additions & 2 deletions docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ There is a config that enables the rules in this category: [`no-new-in-esnext`]
| [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 @@ -320,7 +321,7 @@ There are multiple configs that enable all rules in this category: [`no-new-in-e

## Legacy

Rules in this category disallow the syntax contained in [Annex B](https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html) or Legacy. \
Rules in this category disallow the syntax contained in [Annex B](https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html) or Legacy.\
Rules in this category are not included in any preset.

| Rule ID | Description | |
Expand All @@ -338,6 +339,14 @@ 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-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-es2023`]: ../configs/index.md#no-new-in-es2023
[`restrict-to-es2022`]: ../configs/index.md#restrict-to-es2022
Expand Down
4 changes: 1 addition & 3 deletions docs/rules/no-string-prototype-iswellformed-towellformed.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v7.1.0"
# es-x/no-string-prototype-iswellformed-towellformed
> disallow the `String.prototype.{isWellFormed,toWellFormed}` methods
- ✅ The following configurations enable this rule: [no-new-in-esnext]
- 🚫 This rule was deprecated and replaced by [es-x/no-string-prototype-iswellformed](./no-string-prototype-iswellformed.md),[es-x/no-string-prototype-towellformed](./no-string-prototype-towellformed.md) rules.

This rule reports ES2024 [`String.prototype.{isWellFormed,toWellFormed}` methods](https://github.com/tc39/proposal-is-usv-string) as errors.

Expand Down Expand Up @@ -47,5 +47,3 @@ This rule was introduced in v7.1.0.

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

[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
51 changes: 51 additions & 0 deletions docs/rules/no-string-prototype-iswellformed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "es-x/no-string-prototype-iswellformed"
description: "disallow the `String.prototype.isWellFormed` methods"
since: "v7.1.0"
---

# es-x/no-string-prototype-iswellformed
> disallow the `String.prototype.isWellFormed` methods
- ✅ The following configurations enable this rule: [no-is-usv-string] and [no-new-in-esnext]

This rule reports ES2024 [`String.prototype.isWellFormed` methods](https://github.com/tc39/proposal-is-usv-string) as errors.

## 💡 Examples

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

<eslint-playground type="bad">

```js
/*eslint es-x/no-string-prototype-iswellformed: [error, { aggressive: true }] */
"str".isWellFormed()
```

</eslint-playground>a

## 🔧 Options

This rule has an option.

```yaml
rules:
es-x/no-string-prototype-iswellformed: [error, { aggressive: false }]
```

### aggressive: boolean

Configure the aggressive mode for only this rule.
This is prior to the `settings['es-x'].aggressive` setting.

## 🚀 Version

This rule was introduced in v7.1.0.

## 📚 References

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

[no-is-usv-string]: ../configs/index.md#no-is-usv-string
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
51 changes: 51 additions & 0 deletions docs/rules/no-string-prototype-towellformed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "es-x/no-string-prototype-towellformed"
description: "disallow the `String.prototype.toWellFormed` methods"
since: "v7.1.0"
---

# es-x/no-string-prototype-towellformed
> disallow the `String.prototype.toWellFormed` methods
- ✅ The following configurations enable this rule: [no-is-usv-string] and [no-new-in-esnext]

This rule reports ES2024 [`String.prototype.toWellFormed` methods](https://github.com/tc39/proposal-is-usv-string) as errors.

## 💡 Examples

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

<eslint-playground type="bad">

```js
/*eslint es-x/no-string-prototype-towellformed: [error, { aggressive: true }] */
"str".toWellFormed()
```

</eslint-playground>a

## 🔧 Options

This rule has an option.

```yaml
rules:
es-x/no-string-prototype-towellformed: [error, { aggressive: false }]
```

### aggressive: boolean

Configure the aggressive mode for only this rule.
This is prior to the `settings['es-x'].aggressive` setting.

## 🚀 Version

This rule was introduced in v7.1.0.

## 📚 References

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

[no-is-usv-string]: ../configs/index.md#no-is-usv-string
[no-new-in-esnext]: ../configs/index.md#no-new-in-esnext
17 changes: 17 additions & 0 deletions lib/configs/flat/no-is-usv-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* 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-string-prototype-iswellformed": "error",
"es-x/no-string-prototype-towellformed": "error",
},
}
3 changes: 2 additions & 1 deletion lib/configs/flat/no-new-in-esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
"es-x/no-promise-withresolvers": "error",
"es-x/no-regexp-v-flag": "error",
"es-x/no-resizable-and-growable-arraybuffers": "error",
"es-x/no-string-prototype-iswellformed-towellformed": "error",
"es-x/no-string-prototype-iswellformed": "error",
"es-x/no-string-prototype-towellformed": "error",
},
}
13 changes: 13 additions & 0 deletions lib/configs/no-is-usv-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* 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-string-prototype-iswellformed": "error",
"es-x/no-string-prototype-towellformed": "error",
},
}
3 changes: 2 additions & 1 deletion lib/configs/no-new-in-esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
"es-x/no-promise-withresolvers": "error",
"es-x/no-regexp-v-flag": "error",
"es-x/no-resizable-and-growable-arraybuffers": "error",
"es-x/no-string-prototype-iswellformed-towellformed": "error",
"es-x/no-string-prototype-iswellformed": "error",
"es-x/no-string-prototype-towellformed": "error",
},
}
Loading

0 comments on commit 861e11e

Please sign in to comment.