Repository: eslint-community/eslint-plugin-es-x
Pull request #75 (2023-05-19 16:15:50)

Add new rule `no-atomics-waitasync`
[`Atomics.waitAsync`](https://github.com/tc39/proposal-atomics-wait-async) is now stage 4.

ref: https://github.com/tc39/proposals/commit/a004adf62fbbf66e7845ba08abd1acaaffd28efd


Patch:
diff --git a/docs/rules/index.md b/docs/rules/index.md
index d368150..f951309 100644
--- a/docs/rules/index.md
+++ b/docs/rules/index.md
@@ -10,6 +10,7 @@ There is a config that enables the rules in this category: `plugin:es-x/no-new-i
 
 | Rule ID | Description |    |
 |:--------|:------------|:--:|
+| [es-x/no-atomics-waitasync](./no-atomics-waitasync.md) | disallow the `Atomics.waitAsync` method. |  |
 | [es-x/no-string-prototype-iswellformed-towellformed](./no-string-prototype-iswellformed-towellformed.md) | disallow the `String.prototype.{isWellFormed,toWellFormed}` methods. |  |
 
 ## ES2023
diff --git a/docs/rules/no-atomics-waitasync.md b/docs/rules/no-atomics-waitasync.md
new file mode 100644
index 0000000..d71b3c1
--- /dev/null
+++ b/docs/rules/no-atomics-waitasync.md
@@ -0,0 +1,28 @@
+---
+title: "es-x/no-atomics-waitasync"
+description: "disallow the `Atomics.waitAsync` method"
+---
+
+# es-x/no-atomics-waitasync
+> disallow the `Atomics.waitAsync` method
+
+- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> ***This rule has not been released yet.*** </badge>
+- ✅ The following configurations enable this rule: `plugin:es-x/no-new-in-esnext`
+
+## 💡 Examples
+
+⛔ Examples of **incorrect** code for this rule:
+
+<eslint-playground type="bad">
+
+```js
+/*eslint es-x/no-atomics-waitasync: [error, { aggressive: true }] */
+Atomics.waitAsync(i32a, 0, 0, 1000)
+```
+
+</eslint-playground>
+
+## 📚 References
+
+- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-atomics-waitasync.js)
+- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-atomics-waitasync.js)
diff --git a/lib/configs/no-new-in-esnext.js b/lib/configs/no-new-in-esnext.js
index a3333de..c7c1b33 100644
--- a/lib/configs/no-new-in-esnext.js
+++ b/lib/configs/no-new-in-esnext.js
@@ -6,5 +6,8 @@
 
 module.exports = {
     plugins: ["es-x"],
-    rules: { "es-x/no-string-prototype-iswellformed-towellformed": "error" },
+    rules: {
+        "es-x/no-atomics-waitasync": "error",
+        "es-x/no-string-prototype-iswellformed-towellformed": "error",
+    },
 }
diff --git a/lib/index.js b/lib/index.js
index 7e2d31b..2dbb478 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -107,6 +107,7 @@ module.exports = {
         "no-async-functions": require("./rules/no-async-functions"),
         "no-async-iteration": require("./rules/no-async-iteration"),
         "no-atomics": require("./rules/no-atomics"),
+        "no-atomics-waitasync": require("./rules/no-atomics-waitasync"),
         "no-bigint": require("./rules/no-bigint"),
         "no-binary-numeric-literals": require("./rules/no-binary-numeric-literals"),
         "no-block-scoped-functions": require("./rules/no-block-scoped-functions"),
diff --git a/lib/rules/no-atomics-waitasync.js b/lib/rules/no-atomics-waitasync.js
new file mode 100644
index 0000000..ab6fb2f
--- /dev/null
+++ b/lib/rules/no-atomics-waitasync.js
@@ -0,0 +1,38 @@
+"use strict"
+
+const { READ, ReferenceTracker } = require("@eslint-community/eslint-utils")
+
+module.exports = {
+    meta: {
+        docs: {
+            description: "disallow the `Atomics.waitAsync` method.",
+            category: "ES2024",
+            recommended: false,
+            url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-atomics-waitasync.html",
+        },
+        fixable: null,
+        messages: {
+            forbidden: "ES2024 '{{name}}' method is forbidden.",
+        },
+        schema: [],
+        type: "problem",
+    },
+    create(context) {
+        return {
+            "Program:exit"() {
+                const tracker = new ReferenceTracker(context.getScope())
+                for (const { node, path } of tracker.iterateGlobalReferences({
+                    Atomics: {
+                        waitAsync: { [READ]: true },
+                    },
+                })) {
+                    context.report({
+                        node,
+                        messageId: "forbidden",
+                        data: { name: path.join(".") },
+                    })
+                }
+            },
+        }
+    },
+}


Test patch:
diff --git a/tests/lib/rules/no-atomics-waitasync.js b/tests/lib/rules/no-atomics-waitasync.js
new file mode 100644
index 0000000..4e877a0
--- /dev/null
+++ b/tests/lib/rules/no-atomics-waitasync.js
@@ -0,0 +1,14 @@
+"use strict"
+
+const RuleTester = require("../../tester")
+const rule = require("../../../lib/rules/no-atomics-waitasync.js")
+
+new RuleTester().run("no-atomics-waitasync", rule, {
+    valid: ["Atomics", "Atomics.wait", "let Atomics = 0; Atomics.watiAsync"],
+    invalid: [
+        {
+            code: "Atomics.waitAsync",
+            errors: ["ES2024 'Atomics.waitAsync' method is forbidden."],
+        },
+    ],
+})