Files
NapCatQQ/.pnpm-store/v3/files/73/57a1f3bc0ccf5056e8b185a9d7fcdd2350fe9597aaf845ed6801ac01b83b805f523609911089042e1ccf3dec97c172e32bb14af4a9c38e939e8718fd6b91b7
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

41 lines
1.0 KiB
Plaintext

/**
* @author Yosuke Ota
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow top-level `await`.",
category: "ES2022",
recommended: false,
url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-top-level-await.html",
},
fixable: null,
messages: {
forbidden: "ES2022 top-level 'await' is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
let functionDepth = 0
return {
":function"() {
functionDepth++
},
":function:exit"() {
functionDepth--
},
"AwaitExpression, ForOfStatement[await=true]"(node) {
if (functionDepth > 0) {
// not top-level
return
}
context.report({ node, messageId: "forbidden" })
},
}
},
}