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

55 lines
1.3 KiB
Plaintext

/**
* @author Toru Nagashima
* See LICENSE file in root directory for full license.
*/
"use strict"
/**
* @typedef {string[]} ResolvePaths
*/
/** @type {ResolvePaths} */
const DEFAULT_VALUE = []
/**
* Gets `resolvePaths` property from a given option object.
*
* @param {unknown} option - An option object to get.
* @returns {ResolvePaths | undefined} The `allowModules` value, or `null`.
*/
function get(option) {
if (
option != null &&
typeof option === "object" &&
"resolvePaths" in option &&
Array.isArray(option?.resolvePaths)
) {
return option.resolvePaths.map(String)
}
}
/**
* Gets "resolvePaths" setting.
*
* 1. This checks `options` property, then returns it if exists.
* 2. This checks `settings.n` | `settings.node` property, then returns it if exists.
* 3. This returns `[]`.
*
* @param {import('eslint').Rule.RuleContext} context - The rule context.
* @returns {ResolvePaths} A list of extensions.
*/
module.exports = function getResolvePaths(context, optionIndex = 0) {
return (
get(context.options?.[optionIndex]) ??
get(context.settings?.n) ??
get(context.settings?.node) ??
DEFAULT_VALUE
)
}
module.exports.schema = {
type: "array",
items: { type: "string" },
uniqueItems: true,
}