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

54 lines
1.5 KiB
Plaintext

/**
* @author Toru Nagashima
* See LICENSE file in root directory for full license.
*/
"use strict"
const getAllowModules = require("./get-allow-modules")
/**
* Reports a missing file from ImportTarget
* @param {import('eslint').Rule.RuleContext} context - A context to report.
* @param {import('../util/import-target.js')} target - A list of target information to check.
* @returns {void}
*/
function markMissing(context, target) {
// This should never happen... this is just a fallback for typescript
target.resolveError ??= `"${target.name}" is not found`
context.report({
node: target.node,
messageId: "notFound",
data: { resolveError: target.resolveError },
})
}
/**
* Checks whether or not each requirement target exists.
*
* It looks up the target according to the logic of Node.js.
* See Also: https://nodejs.org/api/modules.html
*
* @param {import('eslint').Rule.RuleContext} context - A context to report.
* @param {import('../util/import-target.js')[]} targets - A list of target information to check.
* @returns {void}
*/
exports.checkExistence = function checkExistence(context, targets) {
/** @type {Set<string | undefined>} */
const allowed = new Set(getAllowModules(context))
for (const target of targets) {
if (allowed.has(target.moduleName)) {
continue
}
if (target.resolveError != null) {
markMissing(context, target)
}
}
}
exports.messages = {
notFound: "{{resolveError}}",
}