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

47 lines
1.4 KiB
Plaintext

/**
* @author Yosuke Ota
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("@eslint-community/eslint-utils")
const { getSourceCode } = require("eslint-compat-utils")
module.exports = {
meta: {
docs: {
description:
"disallow the `WeakRef` and `FinalizationRegistry` class.",
category: "ES2021",
recommended: false,
url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-weakrefs.html",
},
fixable: null,
messages: {
forbidden: "ES2021 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"(program) {
const sourceCode = getSourceCode(context)
const tracker = new ReferenceTracker(
sourceCode.getScope(program),
)
for (const { node, path } of tracker.iterateGlobalReferences({
FinalizationRegistry: { [READ]: true },
WeakRef: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}