Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jul 1, 2024
1 parent 0efed2b commit 8eeee70
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 128 deletions.
27 changes: 27 additions & 0 deletions docs/configs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,33 @@ export default [
}
```

## 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)
Expand Down
6 changes: 5 additions & 1 deletion docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ There are multiple configs that enable all rules in this category: [`no-new-in-e
|:--------|:------------|:--:|
| [es-x/no-arbitrary-module-namespace-names](./no-arbitrary-module-namespace-names.md) | disallow arbitrary module namespace names. | |
| [es-x/no-array-prototype-at](./no-array-prototype-at.md) | disallow the `Array.prototype.at()` methods. | |
| [es-x/no-class-fields](./no-class-fields.md) | disallow class fields. | |
| [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`. | |
Expand Down Expand Up @@ -363,6 +366,7 @@ Rules in this category are not included in any preset.
| 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) |

Expand Down
13 changes: 1 addition & 12 deletions docs/rules/no-class-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ since: "v5.0.0"
# es-x/no-class-fields
> disallow class fields
- ✅ 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-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) rules.

This rule reports class fields as errors.

Expand Down Expand Up @@ -52,14 +52,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-class-fields.js)
- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-class-fields.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
45 changes: 45 additions & 0 deletions docs/rules/no-class-instance-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "es-x/no-class-instance-fields"
description: "disallow instance class fields"
---

# es-x/no-class-instance-fields
> disallow instance class fields
- ❗ <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-class-fields], [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 reports class fields as errors.

## 💡 Examples

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

<eslint-playground type="bad">

```js
/*eslint es-x/no-class-instance-fields: error */
class A {
a = 0
#b = 0
}
```

</eslint-playground>

## 📚 References

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

[no-class-fields]: ../configs/index.md#no-class-fields
[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
50 changes: 50 additions & 0 deletions docs/rules/no-class-private-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "es-x/no-class-private-fields"
description: "disallow private class fields"
---

# es-x/no-class-private-fields
> disallow private class fields
- ❗ <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-class-fields], [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 reports class fields as errors.

## 💡 Examples

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

<eslint-playground type="bad">

```js
/*eslint es-x/no-class-private-fields: error */
class A {
#b = 0
static #f = 0

fn () {
this.#b++
A.#f++
}
}
```

</eslint-playground>

## 📚 References

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

[no-class-fields]: ../configs/index.md#no-class-fields
[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
50 changes: 50 additions & 0 deletions docs/rules/no-class-private-methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "es-x/no-class-private-methods"
description: "disallow private class methods"
---

# es-x/no-class-private-methods
> disallow private class 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-class-fields], [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 reports class fields as errors.

## 💡 Examples

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

<eslint-playground type="bad">

```js
/*eslint es-x/no-class-private-methods: error */
class A {
#c() {}
get #d() {}
set #d(v) {}

static #g() {}
static get #h() {}
static set #h(v) {}
}
```

</eslint-playground>

## 📚 References

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

[no-class-fields]: ../configs/index.md#no-class-fields
[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
45 changes: 45 additions & 0 deletions docs/rules/no-class-static-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "es-x/no-class-static-fields"
description: "disallow static class fields"
---

# es-x/no-class-static-fields
> disallow static class fields
- ❗ <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-class-fields], [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 reports class fields as errors.

## 💡 Examples

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

<eslint-playground type="bad">

```js
/*eslint es-x/no-class-static-fields: error */
class A {
static e = 0
static #f = 0
}
```

</eslint-playground>

## 📚 References

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

[no-class-fields]: ../configs/index.md#no-class-fields
[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
19 changes: 19 additions & 0 deletions lib/configs/flat/no-class-fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 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-class-instance-fields": "error",
"es-x/no-class-private-fields": "error",
"es-x/no-class-private-methods": "error",
"es-x/no-class-static-fields": "error",
},
}
5 changes: 4 additions & 1 deletion lib/configs/flat/no-new-in-es2022.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ module.exports = {
rules: {
"es-x/no-arbitrary-module-namespace-names": "error",
"es-x/no-array-prototype-at": "error",
"es-x/no-class-fields": "error",
"es-x/no-class-instance-fields": "error",
"es-x/no-class-private-fields": "error",
"es-x/no-class-private-methods": "error",
"es-x/no-class-static-block": "error",
"es-x/no-class-static-fields": "error",
"es-x/no-error-cause": "error",
"es-x/no-object-hasown": "error",
"es-x/no-private-in": "error",
Expand Down
15 changes: 15 additions & 0 deletions lib/configs/no-class-fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* 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-class-instance-fields": "error",
"es-x/no-class-private-fields": "error",
"es-x/no-class-private-methods": "error",
"es-x/no-class-static-fields": "error",
},
}
5 changes: 4 additions & 1 deletion lib/configs/no-new-in-es2022.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ module.exports = {
rules: {
"es-x/no-arbitrary-module-namespace-names": "error",
"es-x/no-array-prototype-at": "error",
"es-x/no-class-fields": "error",
"es-x/no-class-instance-fields": "error",
"es-x/no-class-private-fields": "error",
"es-x/no-class-private-methods": "error",
"es-x/no-class-static-block": "error",
"es-x/no-class-static-fields": "error",
"es-x/no-error-cause": "error",
"es-x/no-object-hasown": "error",
"es-x/no-private-in": "error",
Expand Down
6 changes: 6 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
configs: {
"flat/no-array-grouping": require("./configs/flat/no-array-grouping"),
"flat/no-change-array-by-copy": require("./configs/flat/no-change-array-by-copy"),
"flat/no-class-fields": require("./configs/flat/no-class-fields"),
"flat/no-intl-numberformat-v3": require("./configs/flat/no-intl-numberformat-v3"),
"flat/no-is-usv-string": require("./configs/flat/no-is-usv-string"),
"flat/no-new-in-es5": require("./configs/flat/no-new-in-es5"),
Expand Down Expand Up @@ -62,6 +63,7 @@ module.exports = {
"flat/restrict-to-es2023-intl-api": require("./configs/flat/restrict-to-es2023-intl-api"),
"no-array-grouping": require("./configs/no-array-grouping"),
"no-change-array-by-copy": require("./configs/no-change-array-by-copy"),
"no-class-fields": require("./configs/no-class-fields"),
"no-intl-numberformat-v3": require("./configs/no-intl-numberformat-v3"),
"no-is-usv-string": require("./configs/no-is-usv-string"),
"no-new-in-es5": require("./configs/no-new-in-es5"),
Expand Down Expand Up @@ -177,7 +179,11 @@ module.exports = {
"no-block-scoped-functions": require("./rules/no-block-scoped-functions"),
"no-block-scoped-variables": require("./rules/no-block-scoped-variables"),
"no-class-fields": require("./rules/no-class-fields"),
"no-class-instance-fields": require("./rules/no-class-instance-fields"),
"no-class-private-fields": require("./rules/no-class-private-fields"),
"no-class-private-methods": require("./rules/no-class-private-methods"),
"no-class-static-block": require("./rules/no-class-static-block"),
"no-class-static-fields": require("./rules/no-class-static-fields"),
"no-classes": require("./rules/no-classes"),
"no-computed-properties": require("./rules/no-computed-properties"),
"no-date-now": require("./rules/no-date-now"),
Expand Down
Loading

0 comments on commit 8eeee70

Please sign in to comment.