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

46 lines
1.3 KiB
Plaintext

/**
* @fileoverview Utilities for eslint compatibility.
* @see https://eslint.org/docs/latest/use/migrate-to-9.0.0#removed-context-methods
* @author aladdin-add<weiran.zsd@outlook.com>
*/
"use strict"
/** @import { Rule } from 'eslint' */
/** @typedef {import('estree').Node} Node */
exports.getSourceCode = function (/** @type Rule.RuleContext */ context) {
return context.sourceCode || context.getSourceCode()
}
exports.getScope = function (
/** @type {Rule.RuleContext} */ context,
/** @type {Node} */ node
) {
const sourceCode = exports.getSourceCode(context)
// @ts-ignore
return sourceCode.getScope?.(node || sourceCode.ast) || context.getScope()
}
exports.getAncestors = function (
/** @type {Rule.RuleContext} */ context,
/** @type {Node} */ node
) {
const sourceCode = exports.getSourceCode(context)
// @ts-ignore
return sourceCode.getAncestors?.(node) || context.getAncestors()
}
exports.getCwd = function (/** @type {Rule.RuleContext} */ context) {
return context.cwd || context.getCwd()
}
exports.getPhysicalFilename = function (
/** @type {Rule.RuleContext} */ context
) {
return context.physicalFilename || context.getPhysicalFilename?.()
}
exports.getFilename = function (/** @type {Rule.RuleContext} */ context) {
return context.filename || context.getFilename?.()
}