Repository: eslint-community/eslint-plugin-es-x
Pull request #26 (2022-03-19 02:10:48)

Add no-regexp-unicode-property-escapes-(2020 - 2022) rule
This PR contains breaking changes as it changes the configuration.


Patch:
diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml
new file mode 100644
index 0000000..05b310a
--- /dev/null
+++ b/.github/workflows/cron.yml
@@ -0,0 +1,24 @@
+name: cron
+on:
+  schedule:
+    - cron: 0 0 * * 0
+
+jobs:
+  check-resource-update:
+    name: check-resource-update
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+      - name: Install Node.js
+        uses: actions/setup-node@v3
+        with:
+          node-version: 14
+      - name: Install Packages
+        run: npm install
+      - name: Update
+        run: npm run resource-update:unicode-properties
+      - name: Check changes
+        run: |
+            git add --all && \
+            git diff-index --cached HEAD --stat --exit-code
diff --git a/docs/rules/index.md b/docs/rules/index.md
index 8b835ad..478bb64 100644
--- a/docs/rules/index.md
+++ b/docs/rules/index.md
@@ -27,6 +27,7 @@ There are multiple configs that enable all rules in this category: `plugin:es-x/
 | [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-top-level-await](./no-top-level-await.md) | disallow top-level `await`. |  |
 
 ## ES2021
@@ -38,6 +39,7 @@ There are multiple configs that enable all rules in this category: `plugin:es-x/
 | [es-x/no-logical-assignment-operators](./no-logical-assignment-operators.md) | disallow logical assignment operators. | 🔧 |
 | [es-x/no-numeric-separators](./no-numeric-separators.md) | disallow numeric separators. | 🔧 |
 | [es-x/no-promise-any](./no-promise-any.md) | disallow `Promise.any` function and `AggregateError` class. |  |
+| [es-x/no-regexp-unicode-property-escapes-2021](./no-regexp-unicode-property-escapes-2021.md) | disallow the new values of RegExp Unicode property escape sequences in ES2021. |  |
 | [es-x/no-string-prototype-replaceall](./no-string-prototype-replaceall.md) | disallow the `String.prototype.replaceAll` method. |  |
 | [es-x/no-weakrefs](./no-weakrefs.md) | disallow the `WeakRef` and `FinalizationRegistry` class. |  |
 
@@ -55,6 +57,7 @@ There are multiple configs that enable all rules in this category: `plugin:es-x/
 | [es-x/no-nullish-coalescing-operators](./no-nullish-coalescing-operators.md) | disallow nullish coalescing operators. |  |
 | [es-x/no-optional-chaining](./no-optional-chaining.md) | disallow optional chaining. |  |
 | [es-x/no-promise-all-settled](./no-promise-all-settled.md) | disallow `Promise.allSettled` function. |  |
+| [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. |  |
 | [es-x/no-string-prototype-matchall](./no-string-prototype-matchall.md) | disallow the `String.prototype.matchAll` method. |  |
 
 ## ES2019
diff --git a/docs/rules/no-regexp-unicode-property-escapes-2020.md b/docs/rules/no-regexp-unicode-property-escapes-2020.md
new file mode 100644
index 0000000..f2622b1
--- /dev/null
+++ b/docs/rules/no-regexp-unicode-property-escapes-2020.md
@@ -0,0 +1,42 @@
+---
+title: "es-x/no-regexp-unicode-property-escapes-2020"
+description: "disallow the new values of RegExp Unicode property escape sequences in ES2020"
+---
+
+# es-x/no-regexp-unicode-property-escapes-2020
+> disallow the new values of RegExp Unicode property escape sequences in ES2020
+
+- ❗ <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: `plugin:es-x/no-new-in-es2020`, `plugin:es-x/restrict-to-es3`, `plugin:es-x/restrict-to-es5`, `plugin:es-x/restrict-to-es2015`, `plugin:es-x/restrict-to-es2016`, `plugin:es-x/restrict-to-es2017`, `plugin:es-x/restrict-to-es2018`, and `plugin:es-x/restrict-to-es2019`
+
+This rule reports the new values of ES2018 [RegExp Unicode property escape sequences](https://github.com/tc39/proposal-regexp-unicode-property-escapes#readme) which were added in ES2020.
+
+For example, the following patterns are valid in ES2020, but syntax error in ES2019 environments:
+
+- `\p{Script=Elym}`
+- `\p{Script=Elymaic}`
+- `\p{Script=Hmnp}`
+- `\p{Script=Nand}`
+- `\p{Script=Nandinagari}`
+- `\p{Script=Nyiakeng_Puachue_Hmong}`
+- `\p{Script=Wancho}`
+- `\p{Script=Wcho}`
+
+## 💡 Examples
+
+⛔ Examples of **incorrect** code for this rule:
+
+<eslint-playground type="bad">
+
+```js
+/*eslint es-x/no-regexp-unicode-property-escapes-2020: error */
+const r1 = /\p{Script=Elym}/u
+const r2 = /\p{Script=Elymaic}/u
+```
+
+</eslint-playground>
+
+## 📚 References
+
+- [Rule source](https://github.com/ota-meshi/eslint-plugin-es-x/blob/master/lib/rules/no-regexp-unicode-property-escapes-2020.js)
+- [Test source](https://github.com/ota-meshi/eslint-plugin-es-x/blob/master/tests/lib/rules/no-regexp-unicode-property-escapes-2020.js)
diff --git a/docs/rules/no-regexp-unicode-property-escapes-2021.md b/docs/rules/no-regexp-unicode-property-escapes-2021.md
new file mode 100644
index 0000000..d39f980
--- /dev/null
+++ b/docs/rules/no-regexp-unicode-property-escapes-2021.md
@@ -0,0 +1,47 @@
+---
+title: "es-x/no-regexp-unicode-property-escapes-2021"
+description: "disallow the new values of RegExp Unicode property escape sequences in ES2021"
+---
+
+# es-x/no-regexp-unicode-property-escapes-2021
+> disallow the new values of RegExp Unicode property escape sequences in ES2021
+
+- ❗ <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: `plugin:es-x/no-new-in-es2021`, `plugin:es-x/restrict-to-es3`, `plugin:es-x/restrict-to-es5`, `plugin:es-x/restrict-to-es2015`, `plugin:es-x/restrict-to-es2016`, `plugin:es-x/restrict-to-es2017`, `plugin:es-x/restrict-to-es2018`, `plugin:es-x/restrict-to-es2019`, and `plugin:es-x/restrict-to-es2020`
+
+This rule reports the new values of ES2018 [RegExp Unicode property escape sequences](https://github.com/tc39/proposal-regexp-unicode-property-escapes#readme) which were added in ES2021.
+
+For example, the following patterns are valid in ES2021, but syntax error in ES2020 environments:
+
+- `\p{EBase}`
+- `\p{EComp}`
+- `\p{EMod}`
+- `\p{EPres}`
+- `\p{ExtPict}`
+- `\p{Script=Chorasmian}`
+- `\p{Script=Chrs}`
+- `\p{Script=Diak}`
+- `\p{Script=Dives_Akuru}`
+- `\p{Script=Khitan_Small_Script}`
+- `\p{Script=Kits}`
+- `\p{Script=Yezi}`
+- `\p{Script=Yezidi}`
+
+## 💡 Examples
+
+⛔ Examples of **incorrect** code for this rule:
+
+<eslint-playground type="bad">
+
+```js
+/*eslint es-x/no-regexp-unicode-property-escapes-2021: error */
+const r1 = /\p{EBase}/u
+const r2 = /\p{Script=Chorasmian}/u
+```
+
+</eslint-playground>
+
+## 📚 References
+
+- [Rule source](https://github.com/ota-meshi/eslint-plugin-es-x/blob/master/lib/rules/no-regexp-unicode-property-escapes-2021.js)
+- [Test source](https://github.com/ota-meshi/eslint-plugin-es-x/blob/master/tests/lib/rules/no-regexp-unicode-property-escapes-2021.js)
diff --git a/docs/rules/no-regexp-unicode-property-escapes-2022.md b/docs/rules/no-regexp-unicode-property-escapes-2022.md
new file mode 100644
index 0000000..63a6846
--- /dev/null
+++ b/docs/rules/no-regexp-unicode-property-escapes-2022.md
@@ -0,0 +1,43 @@
+---
+title: "es-x/no-regexp-unicode-property-escapes-2022"
+description: "disallow the new values of RegExp Unicode property escape sequences in ES2022"
+---
+
+# es-x/no-regexp-unicode-property-escapes-2022
+> disallow the new values of RegExp Unicode property escape sequences in ES2022
+
+- ❗ <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: `plugin:es-x/no-new-in-es2022`, `plugin:es-x/restrict-to-es3`, `plugin:es-x/restrict-to-es5`, `plugin:es-x/restrict-to-es2015`, `plugin:es-x/restrict-to-es2016`, `plugin:es-x/restrict-to-es2017`, `plugin:es-x/restrict-to-es2018`, `plugin:es-x/restrict-to-es2019`, `plugin:es-x/restrict-to-es2020`, and `plugin:es-x/restrict-to-es2021`
+
+This rule reports the new values of ES2018 [RegExp Unicode property escape sequences](https://github.com/tc39/proposal-regexp-unicode-property-escapes#readme) which were added in ES2022.
+
+For example, the following patterns are valid in ES2022, but syntax error in ES2020 environments:
+
+- `\p{Script=Cpmn}`
+- `\p{Script=Cypro_Minoan}`
+- `\p{Script=Old_Uyghur}`
+- `\p{Script=Ougr}`
+- `\p{Script=Tangsa}`
+- `\p{Script=Tnsa}`
+- `\p{Script=Toto}`
+- `\p{Script=Vith}`
+- `\p{Script=Vithkuqi}`
+
+## 💡 Examples
+
+⛔ Examples of **incorrect** code for this rule:
+
+<eslint-playground type="bad">
+
+```js
+/*eslint es-x/no-regexp-unicode-property-escapes-2022: error */
+const r1 = /\p{Script=Cpmn}/u
+const r2 = /\p{Script=Cypro_Minoan}/u
+```
+
+</eslint-playground>
+
+## 📚 References
+
+- [Rule source](https://github.com/ota-meshi/eslint-plugin-es-x/blob/master/lib/rules/no-regexp-unicode-property-escapes-2022.js)
+- [Test source](https://github.com/ota-meshi/eslint-plugin-es-x/blob/master/tests/lib/rules/no-regexp-unicode-property-escapes-2022.js)
diff --git a/lib/configs/no-new-in-es2020.js b/lib/configs/no-new-in-es2020.js
index cf56127..b00c0c9 100644
--- a/lib/configs/no-new-in-es2020.js
+++ b/lib/configs/no-new-in-es2020.js
@@ -15,6 +15,7 @@ module.exports = {
         "es-x/no-nullish-coalescing-operators": "error",
         "es-x/no-optional-chaining": "error",
         "es-x/no-promise-all-settled": "error",
+        "es-x/no-regexp-unicode-property-escapes-2020": "error",
         "es-x/no-string-prototype-matchall": "error",
     },
 }
diff --git a/lib/configs/no-new-in-es2021.js b/lib/configs/no-new-in-es2021.js
index 88cbcac..99b34a2 100644
--- a/lib/configs/no-new-in-es2021.js
+++ b/lib/configs/no-new-in-es2021.js
@@ -10,6 +10,7 @@ module.exports = {
         "es-x/no-logical-assignment-operators": "error",
         "es-x/no-numeric-separators": "error",
         "es-x/no-promise-any": "error",
+        "es-x/no-regexp-unicode-property-escapes-2021": "error",
         "es-x/no-string-prototype-replaceall": "error",
         "es-x/no-weakrefs": "error",
     },
diff --git a/lib/configs/no-new-in-es2022.js b/lib/configs/no-new-in-es2022.js
index 27d020e..791ef63 100644
--- a/lib/configs/no-new-in-es2022.js
+++ b/lib/configs/no-new-in-es2022.js
@@ -15,6 +15,7 @@ module.exports = {
         "es-x/no-object-hasown": "error",
         "es-x/no-private-in": "error",
         "es-x/no-regexp-d-flag": "error",
+        "es-x/no-regexp-unicode-property-escapes-2022": "error",
         "es-x/no-top-level-await": "error",
     },
 }
diff --git a/lib/index.js b/lib/index.js
index 09db08b..7d343ce 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -189,6 +189,9 @@ module.exports = {
         "no-regexp-u-flag": require("./rules/no-regexp-u-flag"),
         "no-regexp-unicode-property-escapes": require("./rules/no-regexp-unicode-property-escapes"),
         "no-regexp-unicode-property-escapes-2019": require("./rules/no-regexp-unicode-property-escapes-2019"),
+        "no-regexp-unicode-property-escapes-2020": require("./rules/no-regexp-unicode-property-escapes-2020"),
+        "no-regexp-unicode-property-escapes-2021": require("./rules/no-regexp-unicode-property-escapes-2021"),
+        "no-regexp-unicode-property-escapes-2022": require("./rules/no-regexp-unicode-property-escapes-2022"),
         "no-regexp-y-flag": require("./rules/no-regexp-y-flag"),
         "no-rest-parameters": require("./rules/no-rest-parameters"),
         "no-rest-spread-properties": require("./rules/no-rest-spread-properties"),
diff --git a/lib/rules/no-regexp-lookbehind-assertions.js b/lib/rules/no-regexp-lookbehind-assertions.js
index cf806aa..7b48435 100644
--- a/lib/rules/no-regexp-lookbehind-assertions.js
+++ b/lib/rules/no-regexp-lookbehind-assertions.js
@@ -4,41 +4,7 @@
  */
 "use strict"
 
-const { RegExpValidator } = require("@eslint-community/regexpp")
-const { getRegExpCalls } = require("../utils")
-
-/**
- * Verify a given regular expression.
- * @param {RuleContext} context The rule context to report.
- * @param {Node} node The AST node to report.
- * @param {string} pattern The pattern part of a RegExp.
- * @param {string} flags The flags part of a RegExp.
- * @returns {void}
- */
-function verify(context, node, pattern, flags) {
-    try {
-        let found = false
-
-        new RegExpValidator({
-            onLookaroundAssertionEnter(_start, kind) {
-                if (kind === "lookbehind") {
-                    found = true
-                }
-            },
-        }).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
-
-        if (found) {
-            context.report({ node, messageId: "forbidden" })
-        }
-    } catch (error) {
-        //istanbul ignore else
-        if (error.message.startsWith("Invalid regular expression:")) {
-            return
-        }
-        //istanbul ignore next
-        throw error
-    }
-}
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
 
 module.exports = {
     meta: {
@@ -56,18 +22,20 @@ module.exports = {
         type: "problem",
     },
     create(context) {
-        return {
-            "Literal[regex]"(node) {
-                const { pattern, flags } = node.regex
-                verify(context, node, pattern || "", flags || "")
-            },
-
-            "Program:exit"() {
-                const scope = context.getScope()
-                for (const { node, pattern, flags } of getRegExpCalls(scope)) {
-                    verify(context, node, pattern || "", flags || "")
-                }
-            },
-        }
+        return defineRegExpHandler(context, (node) => {
+            let found = false
+            return {
+                onLookaroundAssertionEnter(_start, kind) {
+                    if (kind === "lookbehind") {
+                        found = true
+                    }
+                },
+                onExit() {
+                    if (found) {
+                        context.report({ node, messageId: "forbidden" })
+                    }
+                },
+            }
+        })
     },
 }
diff --git a/lib/rules/no-regexp-named-capture-groups.js b/lib/rules/no-regexp-named-capture-groups.js
index 3a29b5d..f87f827 100644
--- a/lib/rules/no-regexp-named-capture-groups.js
+++ b/lib/rules/no-regexp-named-capture-groups.js
@@ -4,46 +4,7 @@
  */
 "use strict"
 
-const { RegExpValidator } = require("@eslint-community/regexpp")
-const { getRegExpCalls } = require("../utils")
-
-/**
- * Verify a given regular expression.
- * @param {RuleContext} context The rule context to report.
- * @param {Node} node The AST node to report.
- * @param {string} pattern The pattern part of a RegExp.
- * @param {string} flags The flags part of a RegExp.
- * @returns {void}
- */
-function verify(context, node, pattern, flags) {
-    try {
-        let found = false
-
-        new RegExpValidator({
-            onCapturingGroupEnter(_start, name) {
-                if (name) {
-                    found = true
-                }
-            },
-            onBackreference(_start, _end, ref) {
-                if (typeof ref === "string") {
-                    found = true
-                }
-            },
-        }).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
-
-        if (found) {
-            context.report({ node, messageId: "forbidden" })
-        }
-    } catch (error) {
-        //istanbul ignore else
-        if (error.message.startsWith("Invalid regular expression:")) {
-            return
-        }
-        //istanbul ignore next
-        throw error
-    }
-}
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
 
 module.exports = {
     meta: {
@@ -61,18 +22,25 @@ module.exports = {
         type: "problem",
     },
     create(context) {
-        return {
-            "Literal[regex]"(node) {
-                const { pattern, flags } = node.regex
-                verify(context, node, pattern || "", flags || "")
-            },
-
-            "Program:exit"() {
-                const scope = context.getScope()
-                for (const { node, pattern, flags } of getRegExpCalls(scope)) {
-                    verify(context, node, pattern || "", flags || "")
-                }
-            },
-        }
+        return defineRegExpHandler(context, (node) => {
+            let found = false
+            return {
+                onCapturingGroupEnter(_start, name) {
+                    if (name) {
+                        found = true
+                    }
+                },
+                onBackreference(_start, _end, ref) {
+                    if (typeof ref === "string") {
+                        found = true
+                    }
+                },
+                onExit() {
+                    if (found) {
+                        context.report({ node, messageId: "forbidden" })
+                    }
+                },
+            }
+        })
     },
 }
diff --git a/lib/rules/no-regexp-unicode-property-escapes-2019.js b/lib/rules/no-regexp-unicode-property-escapes-2019.js
index d3ae93a..7251f72 100644
--- a/lib/rules/no-regexp-unicode-property-escapes-2019.js
+++ b/lib/rules/no-regexp-unicode-property-escapes-2019.js
@@ -4,63 +4,19 @@
  */
 "use strict"
 
-const { RegExpValidator } = require("@eslint-community/regexpp")
-const { getRegExpCalls } = require("../utils")
-
-const scNamePattern = /^(?:Script(?:_Extensions)?|scx?)$/u
-const scValuePattern =
-    /^(?:Dogr|Dogra|Gong|Gunjala_Gondi|Hanifi_Rohingya|Maka|Makasar|Medefaidrin|Medf|Old_Sogdian|Rohg|Sogd|Sogdian|Sogo)$/u
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
+const {
+    scNameSet,
+    scValueSets,
+    binPropertySets,
+} = require("../util/unicode-properties")
 
 function isNewUnicodePropertyKeyValuePair(key, value) {
-    return scNamePattern.test(key) && scValuePattern.test(value)
+    return scNameSet.has(key) && scValueSets.es2019.has(value)
 }
 
 function isNewBinaryUnicodeProperty(key) {
-    return key === "Extended_Pictographic"
-}
-
-/**
- * Verify a given regular expression.
- * @param {RuleContext} context The rule context to report.
- * @param {Node} node The AST node to report.
- * @param {string} pattern The pattern part of a RegExp.
- * @param {string} flags The flags part of a RegExp.
- * @returns {void}
- */
-function verify(context, node, pattern, flags) {
-    try {
-        let foundValue = ""
-
-        new RegExpValidator({
-            onUnicodePropertyCharacterSet(start, end, _kind, key, value) {
-                if (foundValue) {
-                    return
-                }
-                if (
-                    value
-                        ? isNewUnicodePropertyKeyValuePair(key, value)
-                        : isNewBinaryUnicodeProperty(key)
-                ) {
-                    foundValue = pattern.slice(start, end)
-                }
-            },
-        }).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
-
-        if (foundValue) {
-            context.report({
-                node,
-                messageId: "forbidden",
-                data: { value: foundValue },
-            })
-        }
-    } catch (error) {
-        //istanbul ignore else
-        if (error.message.startsWith("Invalid regular expression:")) {
-            return
-        }
-        //istanbul ignore next
-        throw error
-    }
+    return binPropertySets.es2019.has(key)
 }
 
 module.exports = {
@@ -80,18 +36,31 @@ module.exports = {
         type: "problem",
     },
     create(context) {
-        return {
-            "Literal[regex]"(node) {
-                const { pattern, flags } = node.regex
-                verify(context, node, pattern || "", flags || "")
-            },
-
-            "Program:exit"() {
-                const scope = context.getScope()
-                for (const { node, pattern, flags } of getRegExpCalls(scope)) {
-                    verify(context, node, pattern || "", flags || "")
-                }
-            },
-        }
+        return defineRegExpHandler(context, (node, { pattern }) => {
+            let foundValue = ""
+            return {
+                onUnicodePropertyCharacterSet(start, end, _kind, key, value) {
+                    if (foundValue) {
+                        return
+                    }
+                    if (
+                        value
+                            ? isNewUnicodePropertyKeyValuePair(key, value)
+                            : isNewBinaryUnicodeProperty(key)
+                    ) {
+                        foundValue = pattern.slice(start, end)
+                    }
+                },
+                onExit() {
+                    if (foundValue) {
+                        context.report({
+                            node,
+                            messageId: "forbidden",
+                            data: { value: foundValue },
+                        })
+                    }
+                },
+            }
+        })
     },
 }
diff --git a/lib/rules/no-regexp-unicode-property-escapes-2020.js b/lib/rules/no-regexp-unicode-property-escapes-2020.js
new file mode 100644
index 0000000..d9db40c
--- /dev/null
+++ b/lib/rules/no-regexp-unicode-property-escapes-2020.js
@@ -0,0 +1,66 @@
+/**
+ * @author Yosuke Ota
+ * See LICENSE file in root directory for full license.
+ */
+"use strict"
+
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
+const {
+    scNameSet,
+    scValueSets,
+    binPropertySets,
+} = require("../util/unicode-properties")
+
+function isNewUnicodePropertyKeyValuePair(key, value) {
+    return scNameSet.has(key) && scValueSets.es2020.has(value)
+}
+
+function isNewBinaryUnicodeProperty(key) {
+    return binPropertySets.es2020.has(key)
+}
+
+module.exports = {
+    meta: {
+        docs: {
+            description:
+                "disallow the new values of RegExp Unicode property escape sequences in ES2020",
+            category: "ES2020",
+            recommended: false,
+            url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-regexp-unicode-property-escapes-2020.html",
+        },
+        fixable: null,
+        messages: {
+            forbidden: "ES2020 '{{value}}' is forbidden.",
+        },
+        schema: [],
+        type: "problem",
+    },
+    create(context) {
+        return defineRegExpHandler(context, (node, { pattern }) => {
+            let foundValue = ""
+            return {
+                onUnicodePropertyCharacterSet(start, end, _kind, key, value) {
+                    if (foundValue) {
+                        return
+                    }
+                    if (
+                        value
+                            ? isNewUnicodePropertyKeyValuePair(key, value)
+                            : isNewBinaryUnicodeProperty(key)
+                    ) {
+                        foundValue = pattern.slice(start, end)
+                    }
+                },
+                onExit() {
+                    if (foundValue) {
+                        context.report({
+                            node,
+                            messageId: "forbidden",
+                            data: { value: foundValue },
+                        })
+                    }
+                },
+            }
+        })
+    },
+}
diff --git a/lib/rules/no-regexp-unicode-property-escapes-2021.js b/lib/rules/no-regexp-unicode-property-escapes-2021.js
new file mode 100644
index 0000000..be5b2c7
--- /dev/null
+++ b/lib/rules/no-regexp-unicode-property-escapes-2021.js
@@ -0,0 +1,66 @@
+/**
+ * @author Yosuke Ota
+ * See LICENSE file in root directory for full license.
+ */
+"use strict"
+
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
+const {
+    scNameSet,
+    scValueSets,
+    binPropertySets,
+} = require("../util/unicode-properties")
+
+function isNewUnicodePropertyKeyValuePair(key, value) {
+    return scNameSet.has(key) && scValueSets.es2021.has(value)
+}
+
+function isNewBinaryUnicodeProperty(key) {
+    return binPropertySets.es2021.has(key)
+}
+
+module.exports = {
+    meta: {
+        docs: {
+            description:
+                "disallow the new values of RegExp Unicode property escape sequences in ES2021",
+            category: "ES2021",
+            recommended: false,
+            url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-regexp-unicode-property-escapes-2021.html",
+        },
+        fixable: null,
+        messages: {
+            forbidden: "ES2021 '{{value}}' is forbidden.",
+        },
+        schema: [],
+        type: "problem",
+    },
+    create(context) {
+        return defineRegExpHandler(context, (node, { pattern }) => {
+            let foundValue = ""
+            return {
+                onUnicodePropertyCharacterSet(start, end, _kind, key, value) {
+                    if (foundValue) {
+                        return
+                    }
+                    if (
+                        value
+                            ? isNewUnicodePropertyKeyValuePair(key, value)
+                            : isNewBinaryUnicodeProperty(key)
+                    ) {
+                        foundValue = pattern.slice(start, end)
+                    }
+                },
+                onExit() {
+                    if (foundValue) {
+                        context.report({
+                            node,
+                            messageId: "forbidden",
+                            data: { value: foundValue },
+                        })
+                    }
+                },
+            }
+        })
+    },
+}
diff --git a/lib/rules/no-regexp-unicode-property-escapes-2022.js b/lib/rules/no-regexp-unicode-property-escapes-2022.js
new file mode 100644
index 0000000..ddc939b
--- /dev/null
+++ b/lib/rules/no-regexp-unicode-property-escapes-2022.js
@@ -0,0 +1,66 @@
+/**
+ * @author Yosuke Ota
+ * See LICENSE file in root directory for full license.
+ */
+"use strict"
+
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
+const {
+    scNameSet,
+    scValueSets,
+    binPropertySets,
+} = require("../util/unicode-properties")
+
+function isNewUnicodePropertyKeyValuePair(key, value) {
+    return scNameSet.has(key) && scValueSets.es2022.has(value)
+}
+
+function isNewBinaryUnicodeProperty(key) {
+    return binPropertySets.es2022.has(key)
+}
+
+module.exports = {
+    meta: {
+        docs: {
+            description:
+                "disallow the new values of RegExp Unicode property escape sequences in ES2022",
+            category: "ES2022",
+            recommended: false,
+            url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-regexp-unicode-property-escapes-2022.html",
+        },
+        fixable: null,
+        messages: {
+            forbidden: "ES2022 '{{value}}' is forbidden.",
+        },
+        schema: [],
+        type: "problem",
+    },
+    create(context) {
+        return defineRegExpHandler(context, (node, { pattern }) => {
+            let foundValue = ""
+            return {
+                onUnicodePropertyCharacterSet(start, end, _kind, key, value) {
+                    if (foundValue) {
+                        return
+                    }
+                    if (
+                        value
+                            ? isNewUnicodePropertyKeyValuePair(key, value)
+                            : isNewBinaryUnicodeProperty(key)
+                    ) {
+                        foundValue = pattern.slice(start, end)
+                    }
+                },
+                onExit() {
+                    if (foundValue) {
+                        context.report({
+                            node,
+                            messageId: "forbidden",
+                            data: { value: foundValue },
+                        })
+                    }
+                },
+            }
+        })
+    },
+}
diff --git a/lib/rules/no-regexp-unicode-property-escapes.js b/lib/rules/no-regexp-unicode-property-escapes.js
index 6f98feb..a794c75 100644
--- a/lib/rules/no-regexp-unicode-property-escapes.js
+++ b/lib/rules/no-regexp-unicode-property-escapes.js
@@ -4,39 +4,7 @@
  */
 "use strict"
 
-const { RegExpValidator } = require("@eslint-community/regexpp")
-const { getRegExpCalls } = require("../utils")
-
-/**
- * Verify a given regular expression.
- * @param {RuleContext} context The rule context to report.
- * @param {Node} node The AST node to report.
- * @param {string} pattern The pattern part of a RegExp.
- * @param {string} flags The flags part of a RegExp.
- * @returns {void}
- */
-function verify(context, node, pattern, flags) {
-    try {
-        let found = false
-
-        new RegExpValidator({
-            onUnicodePropertyCharacterSet() {
-                found = true
-            },
-        }).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
-
-        if (found) {
-            context.report({ node, messageId: "forbidden" })
-        }
-    } catch (error) {
-        //istanbul ignore else
-        if (error.message.startsWith("Invalid regular expression:")) {
-            return
-        }
-        //istanbul ignore next
-        throw error
-    }
-}
+const { defineRegExpHandler } = require("../util/define-regexp-handler")
 
 module.exports = {
     meta: {
@@ -55,18 +23,18 @@ module.exports = {
         type: "problem",
     },
     create(context) {
-        return {
-            "Literal[regex]"(node) {
-                const { pattern, flags } = node.regex
-                verify(context, node, pattern || "", flags || "")
-            },
-
-            "Program:exit"() {
-                const scope = context.getScope()
-                for (const { node, pattern, flags } of getRegExpCalls(scope)) {
-                    verify(context, node, pattern || "", flags || "")
-                }
-            },
-        }
+        return defineRegExpHandler(context, (node) => {
+            let found = false
+            return {
+                onUnicodePropertyCharacterSet() {
+                    found = true
+                },
+                onExit() {
+                    if (found) {
+                        context.report({ node, messageId: "forbidden" })
+                    }
+                },
+            }
+        })
     },
 }
diff --git a/lib/util/define-regexp-handler.js b/lib/util/define-regexp-handler.js
new file mode 100644
index 0000000..77d6bb8
--- /dev/null
+++ b/lib/util/define-regexp-handler.js
@@ -0,0 +1,107 @@
+"use strict"
+
+const { RegExpValidator } = require("@eslint-community/regexpp")
+const { getRegExpCalls } = require("../utils")
+
+const allVisitorBuilder = new WeakMap()
+
+/**
+ * @typedef {RegExpValidator.Options & {onExit:()=>void}} RuleValidator
+ */
+/**
+ * Define handlers to regexp nodes.
+ * @param {RuleContext} context The rule context.
+ * @param {(node: Node) => RuleValidator} visitorBuilder The regexp node visitor builder.
+ * @returns {Record<string, (node: ASTNode) => void>} The defined handlers.
+ */
+function defineRegExpHandler(context, visitorBuilder) {
+    const programNode = context.getSourceCode().ast
+
+    let handler = {}
+    let builders = allVisitorBuilder.get(programNode)
+    if (!builders) {
+        builders = []
+        allVisitorBuilder.set(programNode, builders)
+        handler = {
+            "Literal[regex]"(node) {
+                const { pattern, flags } = node.regex
+                visitRegExp(builders, node, pattern || "", flags || "")
+            },
+
+            "Program:exit"() {
+                allVisitorBuilder.delete(programNode)
+
+                const scope = context.getScope()
+                for (const { node, pattern, flags } of getRegExpCalls(scope)) {
+                    visitRegExp(builders, node, pattern || "", flags || "")
+                }
+            },
+        }
+    }
+
+    builders.push(visitorBuilder)
+
+    return handler
+}
+
+module.exports = { defineRegExpHandler }
+
+/**
+ * Visit a given regular expression.
+ * @param {((node: Node) => RuleValidator)[]} visitorBuilders The array of validator options builders.
+ * @param {Node} node The AST node to report.
+ * @param {string} pattern The pattern part of a RegExp.
+ * @param {string} flags The flags part of a RegExp.
+ * @returns {void}
+ */
+function visitRegExp(visitorBuilders, node, pattern, flags) {
+    try {
+        const visitors = visitorBuilders.map((r) => r(node, { pattern, flags }))
+        const composedVisitor = composeRegExpVisitors(visitors)
+
+        new RegExpValidator(composedVisitor).validatePattern(
+            pattern,
+            0,
+            pattern.length,
+            flags.includes("u"),
+        )
+
+        if (typeof composedVisitor.onExit === "function") {
+            composedVisitor.onExit()
+        }
+    } catch (error) {
+        //istanbul ignore else
+        if (error.message.startsWith("Invalid regular expression:")) {
+            return
+        }
+        //istanbul ignore next
+        throw error
+    }
+}
+
+/**
+ * Returns a single visitor handler that executes all the given visitors.
+ * @param {RuleValidator[]} visitors
+ * @returns {RuleValidator}
+ */
+function composeRegExpVisitors(visitors) {
+    const result = {}
+
+    for (const visitor of visitors) {
+        const entries = Object.entries(visitor)
+
+        for (const [key, fn] of entries) {
+            const orig = result[key]
+            if (orig) {
+                result[key] = (...args) => {
+                    orig(...args)
+                    fn(...args)
+                }
+            } else {
+                result[key] = fn
+            }
+        }
+    }
+
+    return result
+}
diff --git a/lib/util/unicode-properties.js b/lib/util/unicode-properties.js
new file mode 100644
index 0000000..4bfd838
--- /dev/null
+++ b/lib/util/unicode-properties.js
@@ -0,0 +1,83 @@
+/* This file was generated with ECMAScript specifications. */
+"use strict"
+
+class DataSet {
+    constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023) {
+        this._raw2018 = raw2018
+        this._raw2019 = raw2019
+        this._raw2020 = raw2020
+        this._raw2021 = raw2021
+        this._raw2022 = raw2022
+        this._raw2023 = raw2023
+    }
+
+    get es2018() {
+        return (
+            this._set2018 || (this._set2018 = new Set(this._raw2018.split(" ")))
+        )
+    }
+
+    get es2019() {
+        return (
+            this._set2019 || (this._set2019 = new Set(this._raw2019.split(" ")))
+        )
+    }
+
+    get es2020() {
+        return (
+            this._set2020 || (this._set2020 = new Set(this._raw2020.split(" ")))
+        )
+    }
+
+    get es2021() {
+        return (
+            this._set2021 || (this._set2021 = new Set(this._raw2021.split(" ")))
+        )
+    }
+
+    get es2022() {
+        return (
+            this._set2022 || (this._set2022 = new Set(this._raw2022.split(" ")))
+        )
+    }
+
+    get es2023() {
+        return (
+            this._set2023 || (this._set2023 = new Set(this._raw2023.split(" ")))
+        )
+    }
+}
+
+const gcNameSet = new Set(["General_Category", "gc"])
+const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"])
+const gcValueSets = new DataSet(
+    "C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct",
+    "",
+    "",
+    "",
+    "",
+    "",
+)
+const scValueSets = new DataSet(
+    "Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy",
+    "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo",
+    "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho",
+    "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",
+    "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi",
+    "",
+)
+const binPropertySets = new DataSet(
+    "AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space",
+    "Extended_Pictographic",
+    "",
+    "EBase EComp EMod EPres ExtPict",
+    "",
+    "",
+)
+module.exports = {
+    gcNameSet,
+    scNameSet,
+    gcValueSets,
+    scValueSets,
+    binPropertySets,
+}
diff --git a/package.json b/package.json
index 7717727..c6782c1 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
     "eslint-plugin-vue": "^9.0.0",
     "espree": "^9.3.1",
     "globals": "^13.0.0",
+    "jsdom": "^19.0.0",
     "mocha": "^10.0.0",
     "monaco-editor": "^0.34.1",
     "npm-run-all": "^4.1.5",
@@ -57,6 +58,7 @@
     "update:index": "node scripts/update-lib-index",
     "update:doc": "node scripts/update-docs-readme",
     "update:ruledocs": "node scripts/update-docs-rules",
+    "resource-update:unicode-properties": "node scripts/update-unicode-properties",
     "preversion": "npm test",
     "version": "env-cmd -e version run-s update:* && git add .",
     "postversion": "git push && git push --tags",
diff --git a/scripts/new-rule.js b/scripts/new-rule.js
index 398daa1..856063e 100644
--- a/scripts/new-rule.js
+++ b/scripts/new-rule.js
@@ -95,4 +95,14 @@ This rule reports ??? as errors.
     cp.execSync(`code "${ruleFile}"`)
     cp.execSync(`code "${testFile}"`)
     cp.execSync(`code "${docFile}"`)
+
+    const yellow = "\u001b[33m"
+
+    const reset = "\u001b[0m"
+
+    console.log(`Test Command:
+
+${yellow}npx mocha "tests/**/${ruleId}.js" --reporter dot --timeout 60000${reset}
+
+`)
 })(process.argv[2])
diff --git a/scripts/update-unicode-properties.js b/scripts/update-unicode-properties.js
new file mode 100644
index 0000000..0de64ee
--- /dev/null
+++ b/scripts/update-unicode-properties.js
@@ -0,0 +1,195 @@
+"use strict"
+
+const fs = require("fs")
+const path = require("path")
+const { JSDOM } = require("jsdom")
+const { ESLint } = require("eslint")
+
+const DATA_SOURCES = [
+    {
+        url: "https://262.ecma-international.org/9.0/",
+        version: 2018,
+        binProperties: "#table-binary-unicode-properties",
+        gcValues: "#table-unicode-general-category-values",
+        scValues: "#table-unicode-script-values",
+    },
+    {
+        url: "https://262.ecma-international.org/10.0/",
+        version: 2019,
+        binProperties: "#table-binary-unicode-properties",
+        gcValues: "#table-unicode-general-category-values",
+        scValues: "#table-unicode-script-values",
+    },
+    {
+        url: "https://262.ecma-international.org/11.0/",
+        version: 2020,
+        binProperties: "#table-binary-unicode-properties",
+        gcValues: "#table-unicode-general-category-values",
+        scValues: "#table-unicode-script-values",
+    },
+    {
+        url: "https://262.ecma-international.org/12.0/",
+        version: 2021,
+        binProperties: "#table-binary-unicode-properties",
+        gcValues: "#table-unicode-general-category-values",
+        scValues: "#table-unicode-script-values",
+    },
+    {
+        url: "https://tc39.es/ecma262/2022/multipage/text-processing.html",
+        version: 2022,
+        binProperties: "#table-binary-unicode-properties",
+        gcValues: "#table-unicode-general-category-values",
+        scValues: "#table-unicode-script-values",
+    },
+    {
+        url: "https://tc39.es/ecma262/multipage/text-processing.html",
+        version: 2023,
+        binProperties: "#table-binary-unicode-properties",
+        gcValues: "#table-unicode-general-category-values",
+        scValues: "#table-unicode-script-values",
+    },
+]
+const FILE_PATH = path.resolve(__dirname, "../lib/util/unicode-properties.js")
+const logger = console
+
+// Main
+;(async () => {
+    const data = Object.create(null)
+    const existing = {
+        binProperties: new Set(),
+        gcValues: new Set(),
+        scValues: new Set(),
+    }
+
+    for (const {
+        binProperties,
+        gcValues,
+        scValues,
+        url,
+        version,
+    } of DATA_SOURCES) {
+        logger.log("---- ECMAScript %d ----", version)
+        const datum = {
+            binProperties: [],
+            gcValues: [],
+            scValues: [],
+        }
+        data[version] = datum
+
+        let window = null
+        do {
+            try {
+                logger.log("Fetching data from %o", url)
+                ;({ window } = await JSDOM.fromURL(url))
+            } catch (error) {
+                if (!error || error.message !== "Error: socket hang up") {
+                    throw error
+                }
+                logger.log(error.message, "then retry.")
+                await new Promise((resolve) => setTimeout(resolve, 2000))
+            }
+        } while (window == null)
+
+        logger.log("Parsing tables")
+        datum.binProperties = collectValues(
+            window,
+            binProperties,
+            existing.binProperties,
+        )
+        datum.gcValues = collectValues(window, gcValues, existing.gcValues)
+        datum.scValues = collectValues(window, scValues, existing.scValues)
+
+        logger.log("Done")
+    }
+
+    logger.log("Generating code...")
+    let code = `/* This file was generated with ECMAScript specifications. */
+"use strict"
+${makeClassDeclarationCode(Object.keys(data))}
+const gcNameSet = new Set(["General_Category", "gc"])
+const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"])
+const gcValueSets = new DataSet(${Object.values(data)
+        .map((d) => makeDataCode(d.gcValues))
+        .join(",")})
+const scValueSets = new DataSet(${Object.values(data)
+        .map((d) => makeDataCode(d.scValues))
+        .join(",")})
+const binPropertySets = new DataSet(${Object.values(data)
+        .map((d) => makeDataCode(d.binProperties))
+        .join(",")})
+module.exports = {gcNameSet, scNameSet, gcValueSets, scValueSets, binPropertySets}
+`
+
+    logger.log("Formatting code...")
+
+    const result = await new ESLint({ fix: true }).lintText(code, {
+        filePath: FILE_PATH,
+    })
+    code = result[0].output || code
+
+    logger.log("Writing '%s'...", FILE_PATH)
+    await save(code)
+
+    logger.log("Completed!")
+})().catch((error) => {
+    logger.error(error.stack)
+    process.exitCode = 1
+})
+
+function collectValues(window, id, existingSet) {
+    const selector = `${id} td:nth-child(1) code`
+    const nodes = window.document.querySelectorAll(selector)
+    const values = Array.from(nodes, (node) => node.textContent || "")
+        .filter((value) => {
+            if (existingSet.has(value)) {
+                return false
+            }
+            existingSet.add(value)
+            return true
+        })
+        .sort(undefined)
+
+    logger.log(
+        "%o nodes of %o were found, then %o adopted and %o ignored as duplication.",
+        nodes.length,
+        selector,
+        values.length,
+        nodes.length - values.length,
+    )
+
+    return values
+}
+
+function makeClassDeclarationCode(versions) {
+    const parameters = versions.map((v) => `raw${v}`).join(", ")
+    const init = versions.map((v) => `this._raw${v} = raw${v}`).join("\n")
+    const getters = versions
+        .map(
+            (v) =>
+                `get es${v}() { return this._set${v} || (this._set${v} = new Set(this._raw${v}.split(" "))) }`,
+        )
+        .join("\n")
+
+    return `
+        class DataSet {
+            constructor(${parameters}) {
+                ${init}
+            }
+            ${getters}
+        }
+    `
+}
+
+function makeDataCode(values) {
+    return `"${values
+        .map((value) => JSON.stringify(value).slice(1, -1))
+        .join(" ")}"`
+}
+
+function save(content) {
+    return new Promise((resolve, reject) => {
+        fs.writeFile(FILE_PATH, content, (error) =>
+            error ? reject(error) : resolve(),
+        )
+    })
+}


Test patch:
diff --git a/tests/lib/rules/no-regexp-unicode-property-escapes-2020.js b/tests/lib/rules/no-regexp-unicode-property-escapes-2020.js
new file mode 100644
index 0000000..eeb4eca
--- /dev/null
+++ b/tests/lib/rules/no-regexp-unicode-property-escapes-2020.js
@@ -0,0 +1,67 @@
+/**
+ * @author Yosuke Ota
+ * See LICENSE file in root directory for full license.
+ */
+"use strict"
+
+const RuleTester = require("../../tester")
+const rule = require("../../../lib/rules/no-regexp-unicode-property-escapes-2020.js")
+
+if (!RuleTester.isSupported(2020)) {
+    //eslint-disable-next-line no-console
+    console.log("Skip the tests of no-regexp-unicode-property-escapes-2020.")
+    return
+}
+
+new RuleTester().run("no-regexp-unicode-property-escapes-2020", rule, {
+    valid: [
+        String.raw`/\p{Letter}/u`,
+        String.raw`/\P{Letter}/u`,
+        String.raw`/\p{Script=Hiragana}/u`,
+        String.raw`/\P{Script=Hiragana}/u`,
+        String.raw`/\p{Extended_Pictographic}/`,
+        String.raw`/\P{Extended_Pictographic}/`,
+        String.raw`/\p{Script=Dogr}/`,
+        String.raw`/\P{Script=Dogr}/`,
+        String.raw`new RegExp('\\p{Extended_Pictographic}')`,
+        String.raw`new RegExp('\\\\p{Extended_Pictographic}', 'u')`,
+        String.raw`/\p{Extended_Pictographic}/u`,
+        String.raw`/\p{Script=Dogr}/u`,
+    ],
+    invalid: [
+        {
+            code: String.raw`/\p{Script=Elym}/u`,
+            errors: ["ES2020 '\\p{Script=Elym}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Elymaic}/u`,
+            errors: ["ES2020 '\\p{Script=Elymaic}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Hmnp}/u`,
+            errors: ["ES2020 '\\p{Script=Hmnp}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Nand}/u`,
+            errors: ["ES2020 '\\p{Script=Nand}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Nandinagari}/u`,
+            errors: ["ES2020 '\\p{Script=Nandinagari}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Nyiakeng_Puachue_Hmong}/u`,
+            errors: [
+                "ES2020 '\\p{Script=Nyiakeng_Puachue_Hmong}' is forbidden.",
+            ],
+        },
+        {
+            code: String.raw`/\p{Script=Wancho}/u`,
+            errors: ["ES2020 '\\p{Script=Wancho}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Wcho}/u`,
+            errors: ["ES2020 '\\p{Script=Wcho}' is forbidden."],
+        },
+    ],
+})
diff --git a/tests/lib/rules/no-regexp-unicode-property-escapes-2021.js b/tests/lib/rules/no-regexp-unicode-property-escapes-2021.js
new file mode 100644
index 0000000..7a349e9
--- /dev/null
+++ b/tests/lib/rules/no-regexp-unicode-property-escapes-2021.js
@@ -0,0 +1,92 @@
+/**
+ * @author Yosuke Ota
+ * See LICENSE file in root directory for full license.
+ */
+"use strict"
+
+const semver = require("semver")
+const RuleTester = require("../../tester")
+const rule = require("../../../lib/rules/no-regexp-unicode-property-escapes-2021.js")
+
+if (semver.lt(RuleTester.eslintVersion, "8.0.0")) {
+    //eslint-disable-next-line no-console
+    console.log("Skip the tests of no-regexp-unicode-property-escapes-2021.")
+    return
+}
+if (!RuleTester.isSupported(2021)) {
+    //eslint-disable-next-line no-console
+    console.log("Skip the tests of no-regexp-unicode-property-escapes-2021.")
+    return
+}
+
+new RuleTester().run("no-regexp-unicode-property-escapes-2021", rule, {
+    valid: [
+        String.raw`/\p{Letter}/u`,
+        String.raw`/\P{Letter}/u`,
+        String.raw`/\p{Script=Hiragana}/u`,
+        String.raw`/\P{Script=Hiragana}/u`,
+        String.raw`/\p{Extended_Pictographic}/`,
+        String.raw`/\P{Extended_Pictographic}/`,
+        String.raw`/\p{Script=Dogr}/`,
+        String.raw`/\P{Script=Dogr}/`,
+        String.raw`new RegExp('\\p{Extended_Pictographic}')`,
+        String.raw`new RegExp('\\\\p{Extended_Pictographic}', 'u')`,
+        String.raw`/\p{Extended_Pictographic}/u`,
+        String.raw`/\p{Script=Dogr}/u`,
+        String.raw`/\p{Script=Elym}/u`,
+    ],
+    invalid: [
+        {
+            code: String.raw`/\p{EBase}/u`,
+            errors: ["ES2021 '\\p{EBase}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{EComp}/u`,
+            errors: ["ES2021 '\\p{EComp}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{EMod}/u`,
+            errors: ["ES2021 '\\p{EMod}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{EPres}/u`,
+            errors: ["ES2021 '\\p{EPres}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{ExtPict}/u`,
+            errors: ["ES2021 '\\p{ExtPict}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Chorasmian}/u`,
+            errors: ["ES2021 '\\p{Script=Chorasmian}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Chrs}/u`,
+            errors: ["ES2021 '\\p{Script=Chrs}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Diak}/u`,
+            errors: ["ES2021 '\\p{Script=Diak}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Dives_Akuru}/u`,
+            errors: ["ES2021 '\\p{Script=Dives_Akuru}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Khitan_Small_Script}/u`,
+            errors: ["ES2021 '\\p{Script=Khitan_Small_Script}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Kits}/u`,
+            errors: ["ES2021 '\\p{Script=Kits}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Yezi}/u`,
+            errors: ["ES2021 '\\p{Script=Yezi}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Yezidi}/u`,
+            errors: ["ES2021 '\\p{Script=Yezidi}' is forbidden."],
+        },
+    ],
+})
diff --git a/tests/lib/rules/no-regexp-unicode-property-escapes-2022.js b/tests/lib/rules/no-regexp-unicode-property-escapes-2022.js
new file mode 100644
index 0000000..1d83fc7
--- /dev/null
+++ b/tests/lib/rules/no-regexp-unicode-property-escapes-2022.js
@@ -0,0 +1,72 @@
+/**
+ * @author Yosuke Ota
+ * See LICENSE file in root directory for full license.
+ */
+"use strict"
+
+const RuleTester = require("../../tester")
+const rule = require("../../../lib/rules/no-regexp-unicode-property-escapes-2022.js")
+
+if (!RuleTester.isSupported(2022)) {
+    //eslint-disable-next-line no-console
+    console.log("Skip the tests of no-regexp-unicode-property-escapes-2022.")
+    return
+}
+
+new RuleTester().run("no-regexp-unicode-property-escapes-2022", rule, {
+    valid: [
+        String.raw`/\p{Letter}/u`,
+        String.raw`/\P{Letter}/u`,
+        String.raw`/\p{Script=Hiragana}/u`,
+        String.raw`/\P{Script=Hiragana}/u`,
+        String.raw`/\p{Extended_Pictographic}/`,
+        String.raw`/\P{Extended_Pictographic}/`,
+        String.raw`/\p{Script=Dogr}/`,
+        String.raw`/\P{Script=Dogr}/`,
+        String.raw`new RegExp('\\p{Extended_Pictographic}')`,
+        String.raw`new RegExp('\\\\p{Extended_Pictographic}', 'u')`,
+        String.raw`/\p{Extended_Pictographic}/u`,
+        String.raw`/\p{Script=Dogr}/u`,
+        String.raw`/\p{Script=Elym}/u`,
+        String.raw`/\p{EBase}/u`,
+        String.raw`/\p{Script=Chorasmian}/u`,
+    ],
+    invalid: [
+        {
+            code: String.raw`/\p{Script=Cpmn}/u`,
+            errors: ["ES2022 '\\p{Script=Cpmn}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Cypro_Minoan}/u`,
+            errors: ["ES2022 '\\p{Script=Cypro_Minoan}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Old_Uyghur}/u`,
+            errors: ["ES2022 '\\p{Script=Old_Uyghur}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Ougr}/u`,
+            errors: ["ES2022 '\\p{Script=Ougr}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Tangsa}/u`,
+            errors: ["ES2022 '\\p{Script=Tangsa}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Tnsa}/u`,
+            errors: ["ES2022 '\\p{Script=Tnsa}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Toto}/u`,
+            errors: ["ES2022 '\\p{Script=Toto}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Vith}/u`,
+            errors: ["ES2022 '\\p{Script=Vith}' is forbidden."],
+        },
+        {
+            code: String.raw`/\p{Script=Vithkuqi}/u`,
+            errors: ["ES2022 '\\p{Script=Vithkuqi}' is forbidden."],
+        },
+    ],
+})
diff --git a/tests/lib/util/define-regexp-handler.js b/tests/lib/util/define-regexp-handler.js
new file mode 100644
index 0000000..c960863
--- /dev/null
+++ b/tests/lib/util/define-regexp-handler.js
@@ -0,0 +1,53 @@
+"use strict"
+
+const RuleTester = require("../../tester")
+const path = require("path")
+const assert = require("assert")
+const { ESLint } = require("eslint")
+const plugin = require("../../..")
+
+// -----------------------------------------------------------------------------
+// Tests
+// -----------------------------------------------------------------------------
+
+if (!RuleTester.isSupported(2019)) {
+    //eslint-disable-next-line no-console
+    console.log("Skip the tests of define-regexp-handler.")
+    return
+}
+
+const TEST_CWD = path.join(__dirname, "../fixtures/integrations/eslint-plugin")
+
+describe("define-regexp-handler", () => {
+    it("should lint with errors", () =>
+        lint(String.raw`
+        /* eslint es-x/no-regexp-unicode-property-escapes: error, es-x/no-regexp-unicode-property-escapes-2019: error, */
+        /\p{Extended_Pictographic}/u;
+`).then((result) => {
+            assert.strictEqual(result.messages.length, 2)
+            assert.deepStrictEqual(
+                result.messages.map((m) => m.ruleId),
+                [
+                    "es-x/no-regexp-unicode-property-escapes",
+                    "es-x/no-regexp-unicode-property-escapes-2019",
+                ],
+            )
+        }))
+})
+
+function lint(text) {
+    const eslint = new ESLint({
+        cwd: TEST_CWD,
+        plugins: { "eslint-plugin-es-x": plugin },
+        useEslintrc: false,
+        overrideConfig: {
+            parserOptions: {
+                ecmaVersion: 2019,
+            },
+            plugins: ["es-x"],
+        },
+    })
+    return eslint
+        .lintText(text, { filePath: "test.js" })
+        .then((results) => results[0])
+}