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

45 lines
1.3 KiB
Plaintext

/**
* @author Toru Nagashima <https://github.com/mysticatea>
* 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 `globalThis` variable",
category: "ES2020",
recommended: false,
url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-global-this.html",
},
fixable: null,
messages: {
forbidden: "ES2020 '{{name}}' variable 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({
globalThis: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}