@boundaries/config

中文文档
1.0.1发布于 2026/11/05MITTypeScriptESM + CJS近 30 天下载 9.5万

@ 边界工具的设置和规则选项的规范化和验证

中文使用文档
文档目录27 节
  1. 目录
  2. 导言
  3. 特征
  4. 安装
  5. 浏览器支持
  6. 快速启动
  7. 核心概念
  8. 诊断
  9. 诊断路径
  10. 正常化值
  11. 使用量
  12. 规范配置
  13. 规范设置
  14. 验证规则选项
  15. 规范依赖规则选项
  16. 获取规则选项的外观
  17. API 参考
  18. 职能
  19. 类型警卫
  20. Docs 链接
  21. 常数
  22. 类型参考
  23. 结果类型
  24. 普通类型
  25. 设置和规则选项类型
  26. 捐款
  27. 许可证

License Build status Coverage Status Quality Gate Mutation testing badge

NPM downloads Last commit Last release

@ 边界/ 配置

设置和规则选项的规范化和验证 @boundaries/eslint-plugin没有ESLint.

目录

导言

@boundaries/config 阅读用户在 boundaries/* 设置和规则选项 @boundaries/eslint-plugin: 它应用他们的默认值,转换其遗留表单, 保留无效的条目, 并返回每个问题作为 诊断,与导致它的入道.

ESLint插件使用并打印出诊断作为警告. 没有ESLint的工具,如编辑器或游乐场,可以使用它来显示自己界面中相同的问题.

[注] 此软件包不运行ESLint,不读取文件或打印任何东西. 它接收配置对象为值并返回已归正的值及其问题;显示问题取决于主机.

特征

  • 设置正常化 ——适用默认,转换遗留设置并保留无效条目
  • 规则选项验证 由于ESLint验证了规则中的JSON计划
  • 政策检查 ——规则政策中未确认的选取者形状和被贬损的语法
  • 诊断 有关卡的,ESLint插件打印的文本和每个受影响的条目的路径
  • 纯函数 ——每一次通话都计算结果,输入从未变异
  • 在节点.js和浏览器中运行,不包含 ESLint

安装

通过 npm 安装软件包 :

npm install @boundaries/config

浏览器支持

该软件包不依赖于ESLint或Node.js,因此它也在浏览器中运行. 为浏览器所构建的 Bundlers, 如 Webpack, Vite 或 esbuild , 选择它的浏览器通过 browser 其状况 exports 字段,且该构建不需要多填充节点.js模块或像 Globals 这样的 process。 。 。 .

软件包从不读取环境变量或工作目录: 主机解决了工程的根路径, 并按 rootPath 选项.

快速启动

将 ESLint 配置中的边界部分正常化并获得其问题:

import { normalizeConfig } from "@boundaries/config";

const { value, diagnostics } = normalizeConfig({
  settings: {
    "boundaries/elements": [
      { type: "helper", pattern: "helpers/*" },
      { pattern: "components/*" },
    ],
  },
  rules: {
    "boundaries/dependencies": [
      2,
      {
        default: "disallow",
        policies: [
          {
            from: { element: { type: "component" } },
            allow: { to: { element: { type: "helper" } } },
          },
        ],
      },
    ],
  },
});

// value.settings.elementDescriptors: the valid element descriptors, without the second one
// value.rules.dependencies.severity: "error"
// value.rules.dependencies.options.policies: the policies with their selectors normalized
// diagnostics:
// [
//   {
//     level: "warning",
//     title: "Some element descriptors are invalid and will be ignored.",
//     detail: 'Invalid descriptors:\n[{"match":"folder","pattern":"components/*"}].\nMore info: https://www.jsboundaries.dev/docs/settings/',
//     paths: [["settings", "boundaries/elements", 1]],
//   },
// ]

核心概念

诊断

函数因其输入中出现问题而永远不会打印或抛出. 他们把每个问题都当作 Diagnostic数字 :

{
  level: "warning",
  title: "Please provide a valid value in 'boundaries/cache' setting.",
  detail: "The value should be a boolean. More info: https://www.jsboundaries.dev/docs/settings/",
  paths: [["boundaries/cache"]],
}
  • level:如何处理输入.
    • "error":输入被拒绝,因为ESLint拒绝失败规则计划选项.
    • "warning":输入被忽略或没有效果.
    • "deprecation":输入使用仍然有效的遗留语法.
  • title 财务报告和审定财务报表 detail:ESLint插件所打印的文本. detail 是可选的,它通常以链接到文件结尾.
  • paths页:1 路径 每个受影响的条目.

在多个条目中发现的一个问题被一次返回,其中所有条目的路径,诊断结果以ESLint插件打印的顺序来.

诊断路径

一个路径是导致受影响的条目的对象密钥和数组索引的列表,从返回它的函数输入的根起. 一条空道, [],表示整个输入.

函数路径的根示例
normalizeConfig配置对象["rules", "boundaries/dependencies", 1, "default"]
normalizeSettings设置对象["boundaries/elements", 1]
validateRuleOptions规则条目的选项对象["policies", 0]

主机可以使用路径在自己的界面中指向条目,比如在编辑器中突出显示.

正常化值

normalizeConfig 财务报告和审定财务报表 normalizeSettings 返回 a ConfigResult, (中文(简体) ), { value, diagnostics }编辑 value 总是设置的,不管输入: 缺失的设置得到它们的默认值,遗留的表单被转换,无效的条目被忽略,所以即使有诊断,一个主机也可以使用.

使用量

规范配置

normalizeConfig 取ESLint配置对象的边界部分, { settings, rules }。它使设置与 normalizeSettings,并验证插件的每个规则条目,作为ESLint验证,然后作为插件验证:

规则条目诊断单位 value.rules
没有插件前缀的密钥, 例如 import/no-cycle无没有
严重性 0, (中文(简体) ), 1, (中文(简体) ), 2, (中文(简体) ), "off", (中文(简体) ), "warn" 或者说 "error"错误没有
插件的未知规则错误,除非规则被取消没有
规则关闭无,因为ESLint没有验证是的,但当它失败时, 它的选项被视作没有设定
规则方案失败的选项错误, 唯一一个条目没有
有效选项警告和贬值 validateRuleOptions对

严重程度可以单写, "warn",或作为数组的第一个项, ["warn", { ... }]。规则以短名键入 value.rules选项 dependencies 规则,以及被掠夺者 element-types 规则,与 normalizeDependenciesRuleOptions。 。 。 .

import { normalizeConfig } from "@boundaries/config";

const { value, diagnostics } = normalizeConfig({
  rules: {
    "boundaries/dependencies": ["error", { default: "maybe" }],
    "boundaries/unknown-rule": "warn",
    "boundaries/no-private": "on",
    "import/no-cycle": 2,
  },
});

// value.rules: {}
// diagnostics:
// [
//   {
//     level: "warning",
//     title: "Please provide element descriptors using the 'boundaries/elements' setting, or file descriptors using the 'boundaries/files' setting.",
//     detail: "More info: https://www.jsboundaries.dev/docs/settings/",
//     paths: [["settings"]],
//   },
//   {
//     level: "error",
//     title: "[boundaries/dependencies] Invalid rule options.",
//     detail: 'Value "maybe" should be equal to one of the allowed values.\nMore info: https://www.jsboundaries.dev/docs/rules/dependencies/',
//     paths: [["rules", "boundaries/dependencies", 1, "default"]],
//   },
//   {
//     level: "error",
//     title: 'Key "rules": Key "boundaries/unknown-rule": Could not find "unknown-rule" in plugin "boundaries".',
//     paths: [["rules", "boundaries/unknown-rule"]],
//   },
//   {
//     level: "error",
//     title: 'Key "rules": Key "boundaries/no-private": Expected severity of "off", 0, "warn", 1, "error", or 2.',
//     paths: [["rules", "boundaries/no-private"]],
//   },
// ]

当插件在 ESLint 配置中以另一个名称注册时, 将其传递为 pluginName。只读取前缀的规则:

const { value } = normalizeConfig(
  {
    settings: { "boundaries/elements": [{ type: "app", pattern: "app/*" }] },
    rules: { "arch/no-private": 1 },
  },
  { pluginName: "arch" }
);

// value.rules: { "no-private": { severity: "warn", options: undefined } }

[注] 设置保留 boundaries/ 前缀,无论插件名称是什么,因为ESLint插件读取它们.

规范设置

normalizeSettings 拿着 settings 仅读取其 boundaries/* 键。 它应用每个缺失设置的默认值,转换遗留设置,例如 boundaries/types 或者说 boundaries/elements-single-type,将无效的条目删除。 这个 设置 : 列出每个属性及其默认值.

import { normalizeSettings } from "@boundaries/config";

const { value, diagnostics } = normalizeSettings(
  {
    "boundaries/elements": [{ type: "component", pattern: "components/*" }],
    "boundaries/ignore": "**/*.spec.js",
    "boundaries/cache": "yes",
  },
  { rootPath: "/project" }
);

// value.ignorePaths: ["**/*.spec.js"]
// value.cache: true
// value.rootPath: "/project"
// diagnostics:
// [
//   {
//     level: "warning",
//     title: "Please provide a valid value in 'boundaries/cache' setting.",
//     detail: "The value should be a boolean. More info: https://www.jsboundaries.dev/docs/settings/",
//     paths: [["boundaries/cache"]],
//   },
// ]

这个 rootPath 选项是工程的根路径,由主机解决。 ESLint 插件从 boundaries/root-path 设置 ESLINT_PLUGIN_BOUNDARIES_ROOT_PATH 环境变量和工作目录。 没有选择,正常化 rootPath 这是 boundaries/root-path 设置为正文.

[注] 当 boundaries/legacy-warnings 设置是 false中,不报告遗留语法:在设置中,也不通过 normalizeConfig,在规则选项中.

验证规则选项

validateRuleOptions 验证单个规则条目的选项对象,紧后的项目。 正如ESLint所做的那样,它根据规则的策略来验证它,然后,对于有政策的规则,它检查其选择者的形状,当 legacyWarnings 实值 true,他们的被贬损的语法.

import { validateRuleOptions } from "@boundaries/config";

const diagnostics = validateRuleOptions(
  "boundaries/dependencies",
  {
    default: "disallow",
    policies: [{ from: "component", allow: "helper" }],
  },
  { legacyWarnings: true }
);

// [
//   {
//     level: "deprecation",
//     title: "[boundaries/dependencies] Detected legacy string element selectors in 1 policy at indices: 0.",
//     detail: 'Replace "your-type" with an entity selector, e.g. { element: { type: "your-type" } }. More info: https://www.jsboundaries.dev/docs/releases/migration-guides/v5-to-v6/#object-based-elements-selector-syntax',
//     paths: [["policies", 0]],
//   },
//   {
//     level: "deprecation",
//     title: '[boundaries/dependencies] Detected "allow"/"disallow" entries without a "from"/"to" wrapper in 1 policy at indices: 0.',
//     detail: 'Use allow: [{ to: { element: { type: "your-type" } } }] or [{ from: ... }] instead of a bare element selector. More info: https://www.jsboundaries.dev/docs/releases/migration-guides/v5-to-v6/#to-property-in-allowdisallow-rules-is-now-required',
//     paths: [["policies", 0]],
//   },
// ]

当选项失败规则计划时,计划错误是唯一的诊断,因为ESLint从未运行一个选项失败的规则. 已经运行了 ESLint 的宿主, 它验证了计划本身, 通过了 schema: false 跳过它:

validateRuleOptions("boundaries/dependencies", { default: "maybe" }, { legacyWarnings: true });
// [{ level: "error", title: "[boundaries/dependencies] Invalid rule options.", ... paths: [["default"]] }]

validateRuleOptions("boundaries/dependencies", { default: "maybe" }, { legacyWarnings: true, schema: false });
// []

[注] 规则名称总是有 boundaries/ 前缀,无论插件在 ESLint 配置中注册的名称.

规范依赖规则选项

normalizeDependenciesRuleOptions 应用选项的默认值 dependencies 统治和规范其政策的选择者,所以一个主机可以和它们匹配 @boundaries/elements。它假设通过规则方案,并报告没有问题:首先通过 validateRuleOptions。 。 。 .

import { normalizeDependenciesRuleOptions } from "@boundaries/config";

const options = normalizeDependenciesRuleOptions({
  policies: [
    {
      from: { element: { type: "component" } },
      allow: { to: { element: { type: "helper" } } },
    },
  ],
});

// {
//   default: "disallow",
//   message: undefined,
//   policies: [
//     {
//       from: [{ element: [{ type: "component" }] }],
//       allow: [{ to: [{ element: [{ type: "helper" }] }] }],
//       ...
//     },
//   ],
//   checkAllOrigins: false,
//   checkUnknownLocals: false,
//   checkInternals: false,
// }

[尖叫声] 常态化的选取者与纪念 @boundaries/elements不要改变它们.

获取规则选项的外观

getRuleOptionsSchema 返回规则选项的 JSON 方案, 如 ESLint 插件在规则中声明 meta.schema: 包含每个选项的图案的数组, 当规则没有选项时为空 .

import { getRuleOptionsSchema } from "@boundaries/config";

getRuleOptionsSchema("boundaries/no-private");
// [
//   {
//     type: "object",
//     properties: {
//       allowUncles: { type: "boolean" },
//       message: { type: "string" },
//     },
//     additionalProperties: false,
//   },
// ]

getRuleOptionsSchema("boundaries/no-unknown-files");
// []

[尖叫声] 返回的策略在呼叫之间共享. 不要改变他们.

API 参考

职能

normalizeConfig

将ESLint配置的边界部分正常化, { settings, rules }。见 规范配置。 。 。 .

  • 参数数字 :
    • config数字 : unknown ——配置对象. 内容 settings 财务报告和审定财务报表 rules 是可选的; 任何其它密钥都会被忽略.
    • options数字 : NormalizeConfigOptions - 可选的.
      • pluginName数字 : string - 可选的。 规则名称在 rules默认 "boundaries"。 。 。 .
      • rootPath数字 : string - 可选的。 项目的根道,已经由主机解决了. 没有它,正常化的 rootPath 这是 boundaries/root-path 设置为正文.
  • 回返数字 : ConfigResult<ConfigNormalized> —— 规范化的配置和所发现的问题, 有来自配置对象根的路径.
const { value, diagnostics } = normalizeConfig(config, { rootPath: "/project" });

normalizeSettings

规范化 boundaries/* 设置。 见 规范设置。 。 。 .

  • 参数数字 :
    • settings数字 : Record<string, unknown> | undefined - 电话 settings 一个 ESLint 配置的对象。 仅限其 boundaries/* 键被读取.
    • options数字 : NormalizeSettingsOptions - 可选的.
      • rootPath数字 : string - 可选的。 项目的根道,已经由主机解决了. 没有它,正常化的 rootPath 这是 boundaries/root-path 设置为正文.
  • 回返数字 : ConfigResult<SettingsNormalized> —— 常规设置和发现的问题, 以及设置对象根的路径 .
const { value, diagnostics } = normalizeSettings(config.settings, { rootPath: "/project" });

validateRuleOptions

验证规则条目的选项。 见 验证规则选项。 。 。 .

  • 参数数字 :
    • ruleName数字 : RuleName - 规则的名称,加上 boundaries/ 前缀, 如 "boundaries/dependencies"。 。 。 .
    • options数字 : unknown - 规则条目的选项对象,或 undefined 当条目没有选项时.
    • validation数字 : RuleOptionsValidation - 什么来验证.
      • legacyWarnings数字 : boolean ——是否将政策贬值的语法报告为: boundaries/legacy-warnings 设置是.
      • schema数字 : boolean - 可选的。 是否按照 ESLint 对规则的规则验证选项 meta.schema默认 true; 已经运行 ESLint 通道的主机 false。 。 。 .
  • 回返数字 : Diagnostic[] ——发现的问题,从选项对象的根出出路径. 当计划验证失败时, 只有错误 .
const diagnostics = validateRuleOptions("boundaries/dependencies", options, {
  legacyWarnings: true,
});

normalizeDependenciesRuleOptions

应用选项的默认值 dependencies 统治政策的选择者并使其正常化。 见 规范依赖规则选项。 。 。 .

  • 参数数字 :
    • options数字 : DependenciesRuleOptions | undefined - 备选案文 dependencies 规则,或 element-types 规则,已经验证 与规则的策略.
  • 回返数字 : DependenciesRuleOptionsNormalized ——适用其缺省选项. 这些政策来自 policies,或从被贬值的 rules 何时 policies 未设定,每个都保留其索引.
const options = normalizeDependenciesRuleOptions({ default: "allow", policies: [] });

getRuleOptionsSchema

返回规则选项的 JSON 方案。 见 获取规则选项的外观。 。 。 .

  • 参数数字 :
    • ruleName数字 : RuleName - 规则的名称,加上 boundaries/ 前缀.
  • 回返数字 : JsonSchema[] ——规则的每个选项的图案,当规则没有选项时为空.
const schema = getRuleOptionsSchema("boundaries/dependencies");

类型警卫

每人收到一张 value 类型 unknown 返回时 true 当值为类型时.

函数缩到回返 true 页:1
isSettingsKeySettingsKey插件设置的密钥, 如 "boundaries/elements"。 。 。 .
isDependencyNodeKeyDependencyNodeKey内置依赖节点 : "import", (中文(简体) ), "export", (中文(简体) ), "require" 或者说 "dynamic-import"。 。 。 .
isRuleNameRuleName规则名称 boundaries/ 前缀, 如 "boundaries/dependencies"。 。 。 .
isRuleShortNameRuleShortName没有前缀的规则名称, 如 "dependencies"。 。 。 .
isRuleEffectRuleEffect"allow" 或者说 "disallow"。 。 。 .
isRulePolicyRuleEffect(已过期) 别名 isRuleEffect。 。 。 .
isRuleName("boundaries/dependencies"); // true
isRuleName("dependencies"); // false
isRuleShortName("dependencies"); // true

链接的构建者 jsbounders.dev (英语) 诊断带。 每个 anchor 参数是可选的 string,以 #<anchor>,每个函数返回 a string。 。 。 .

函数回返
docsUrl(path, anchor?)文件页的 URL : https://www.jsboundaries.dev/docs/<path>/。 。 。 .
getRuleDocsPath(ruleName)规则文件页的路径, rules/<short name>. 被贬损的规则获得替换规则的一页.
ruleDocsUrl(ruleName, anchor?)规则文件页的 URL .
moreInfoLink(path, anchor?)More info: <url>,带有文件页的 URL.
moreInfoSettingsLink(anchor?)moreInfoLink 设置页面.
moreInfoElementsLink(anchor?)moreInfoLink 中.
moreInfoLegacySettingsLink(anchor?)moreInfoLink 后继设置页面.
moreInfoSelectorsLink(anchor?)moreInfoLink 中选择.
migrationGuideLink(versionFrom, versionTo, anchor?)moreInfoLink 两种主要版本之间的移徙指南.
migrationToV2GuideLink(anchor?)migrationGuideLink 从版本 1 到 2 .
migrationToV6GuideLink(anchor?)migrationGuideLink 从第五版到第六版.
migrationToV7GuideLink(anchor?)migrationGuideLink 从第6至7版.

path, (中文(简体) ), versionFrom 财务报告和审定财务报表 versionTo 为: strings,和 ruleName 是一个 RuleName。 。 。 .

ruleDocsUrl("boundaries/no-unknown"); // "https://www.jsboundaries.dev/docs/rules/no-unknown-dependencies/"
moreInfoSettingsLink(); // "More info: https://www.jsboundaries.dev/docs/settings/"

常数

常数数值
DIAGNOSTIC_LEVELS_MAP诊断水平: { ERROR: "error", WARNING: "warning", DEPRECATION: "deprecation" }。 。 。 .
RULE_SEVERITIES_MAP规则正常化条目的断层: { OFF: "off", WARN: "warn", ERROR: "error" }。 。 。 .
RULE_NAMES_MAP, (中文(简体) ), RULE_NAMES规则名称与 boundaries/ 前缀,作为地图和数组.
RULE_SHORT_NAMES_MAP, (中文(简体) ), RULE_SHORT_NAMES没有前缀的规则名称,作为地图和数组.
SETTINGS_KEYS_MAP设置的密钥, 如 ELEMENTS: "boundaries/elements"。 。 。 .
SETTINGS设置和规则的密钥, 有效的元素描述符模式和依赖节点类型, 以及内置依赖节点的选择器, DEFAULT_DEPENDENCY_NODES。 。 。 .
DEPENDENCY_NODE_KEYS_MAP内置依赖节点 : { REQUIRE: "require", IMPORT: "import", DYNAMIC_IMPORT: "dynamic-import", EXPORT: "export" }。 。 。 .
RULE_EFFECTS_MAP政策的效果: { ALLOW: "allow", DISALLOW: "disallow" }。 。 。 . RULE_POLICIES_MAP 是其被贬损的别名.
NO_UNKNOWN_DEPENDENCIES_REQUIRE_MAP联合国 require 选项 no-unknown-dependencies 规则: { ALL: "all", ELEMENT: "element", FILE: "file", ANY: "any" }。 。 。 .
LEGACY_TEMPLATES_DEFAULT, (中文(简体) ), LEGACY_WARNINGS_DEFAULT, (中文(简体) ), ELEMENTS_SINGLE_TYPE_DEFAULT, (中文(简体) ), CACHE_DEFAULT默认值 boundaries/legacy-templates, (中文(简体) ), boundaries/legacy-warnings, (中文(简体) ), boundaries/elements-single-match 财务报告和审定财务报表 boundaries/cache 设置 : true。 。 。 .
FILES_SINGLE_MATCH_DEFAULT默认 boundaries/files-single-match 设置 : false。 。 。 .
PLUGIN_NAME"boundaries"。 。 。 .
WEBSITE_URL, (中文(简体) ), REPO_URL, (中文(简体) ), PLUGIN_ISSUES_URL网站的URL,存储器及其问题.

地图的值也逐一导出, 例如 DEPENDENCIES, (中文(简体) ), DEPENDENCY_NODE_IMPORT, (中文(简体) ), RULE_EFFECT_ALLOW 或者说 NO_UNKNOWN_DEPENDENCIES_REQUIRE_ANY。 。 。 .

类型参考

结果类型

ConfigResult

归来 normalizeConfig 财务报告和审定财务报表 normalizeSettings,作为 ConfigResult<T>。 。 。 .

财产类型说明
valueT正常值 。 总是设置: 无效的条目被忽略 .
diagnosticsDiagnostic[]发现的问题,按照ESLint插件打印的顺序,每出一次.

Diagnostic

输入中发现的问题 。 见 诊断。 。 。 .

财产类型说明
levelDiagnosticLevel"error", (中文(简体) ), "warning" 或者说 "deprecation"。 。 。 .
titlestringESLint插件所打印的标题 .
detailstring | undefinedESLint插件在标题下打印的细节和文件链接.
pathsDiagnosticPath[]每个受影响的条目一条路径. DiagnosticPath 实值 (string | number)[]。 。 。 .

普通类型

ConfigNormalized

这个 value 返回时间 normalizeConfig。 。 。 .

财产类型说明
settingsSettingsNormalized常规设置 .
rules{ [Name in RuleShortName]?: RuleEntryNormalized<Name> }插件的规则 rules,简称. 因出错而遗漏的条目缺失 .

RuleEntryNormalized

规则条目 ConfigNormalized,作为 RuleEntryNormalized<Name>。 。 。 .

财产类型说明
severityRuleSeverity"off", (中文(简体) ), "warn" 或者说 "error",无论是写成数字还是字符串.
optionsDependenciesRuleOptionsNormalized 页:1 dependencies 财务报告和审定财务报表 element-types, (中文(简体) ), unknown 对其他人规则的备选方案:规则与 dependencies 政策,为其他人写.

SettingsNormalized

这个 value 返回时间 normalizeSettings,则 settings 联 合 国 ConfigNormalized。 。 。 .

财产类型说明
elementDescriptorsElementDescriptors有效的描述 boundaries/elements,或堕落者 boundaries/types 何时 boundaries/elements 未设置。 遗留字符串描述符被转换成对象. 默认 []。 。 。 .
elementsSingleMatchbooleanboundaries/elements-single-match,或贬值的 boundaries/elements-single-type 当它没有设置的时候。 默认 true。 。 。 .
fileDescriptorsFileDescriptors有效的描述 boundaries/files默认 []。 。 。 .
filesSingleMatchbooleanboundaries/files-single-match默认 false。 。 。 .
ignorePathsstring[] | undefinedboundaries/ignore,总是作为一个阵列。 默认 undefined。 。 。 .
includePathsstring[] | undefinedboundaries/include,总是作为一个阵列。 默认 undefined。 。 。 .
rootPathstring | undefined这个 rootPath 选项,或 boundaries/root-path 当选项未被通过时写入.
dependencyNodesDependencyNodeSelector[]节点的选择器 boundaries/dependency-nodes,然后是有效的 boundaries/additional-dependency-nodes。默认情况下,选择 import, (中文(简体) ), export, (中文(简体) ), require 财务报告和审定财务报表 dynamic-import。 。 。 .
legacyTemplatesbooleanboundaries/legacy-templates默认 true。 。 。 .
cachebooleanboundaries/cache默认 true。 。 。 .
legacyWarningsbooleanboundaries/legacy-warnings默认 true。 。 。 .
flagAsExternalFlagAsExternalOptionsboundaries/flag-as-external,在默认情况下,每个有效选项: { unresolvableAlias: true, inNodeModules: true, outsideRootPath: false, customSourcePatterns: [] }。 。 。 .
debugDebugSettingNormalizedboundaries/debug,带有默认值.

ElementDescriptors, (中文(简体) ), FileDescriptors 财务报告和审定财务报表 FlagAsExternalOptions 属于类型 @boundaries/elements。 。 。 .

DebugSettingNormalized

财产类型说明
enabledboolean是否启用调试模式 。 默认 false。 。 。 .
messages{ files: boolean; dependencies: boolean; violations: boolean }是否打印文件的调试消息、 依赖性和规则违反 。 每个都是 true 默认.
filter.filesFileSelectorNormalized | EntitySelectorNormalized | undefined在文件的调试信件有效时, 过滤这些信件的常态选择器 .
filter.dependenciesDependencySelectorNormalized | undefined用于过滤依赖关系的调试消息的常态选择器, 当有效时 .

DependenciesRuleOptionsNormalized

归来 normalizeDependenciesRuleOptions,则 options 会 议 日 程 和 议 程 dependencies 财务报告和审定财务报表 element-types 条目 ConfigNormalized。 。 。 .

财产类型说明
defaultRuleEffect当没有政策匹配时的效果 : "allow",或 "disallow" 对于任何其他价值.
messagestring | undefined所有规则被违反的自定义消息, 当设定时 .
policiesDependenciesPolicyNormalized[]policies,或贬值的 rules 何时 policies 未设置, 其选择者已正常化。 每个人的指数都保留在选项中.
checkAllOriginsboolean是否检查每个来源的依赖性,而不仅仅是本地的依赖性. 默认 false。 。 。 .
checkUnknownLocalsboolean是否检查本地对未知元素的依赖性 。 默认 false。 。 。 .
checkInternalsboolean是否检查同一元素的文件之间的依赖性 。 默认 false。 。 。 .

DependenciesPolicyNormalized

财产类型说明
fromEntitySelectorNormalized | undefined所依赖的实体的选择者.
toEntitySelectorNormalized | undefined依赖对象实体的选择者.
dependencyDependencyInfoSelectorNormalized | undefined依赖元数据选择器 .
allowDependencySelectorNormalized | EntitySelectorNormalized | undefined允许的依赖的选取者 .
disallowDependencySelectorNormalized | EntitySelectorNormalized | undefined不允许依赖的选定者.
importKindDependencyKind | undefined(已过期) 政策适用于何种进口,如书面.
messagestring | undefined政策违规的风俗信息,如上所记.

选择者类型是类型 @boundaries/elements,在它选取的参考文献中描述它们.

设置和规则选项类型

软件包会导出用户写作的种类,所以一个主机可以输入自己的配置对象. 主要有:

类型说明
Settings这个 boundaries/* 设置,按键排列.
IgnoreSetting, (中文(简体) ), IncludeSetting, (中文(简体) ), RootPathSetting, (中文(简体) ), DebugSetting联合国 boundaries/ignore, (中文(简体) ), boundaries/include, (中文(简体) ), boundaries/root-path 财务报告和审定财务报表 boundaries/debug 设置.
DependencyNodeSelector一项 boundaries/additional-dependency-nodes数字 : { selector: string; kind: DependencyKind; name?: string }。 。 。 .
RuleBaseOptions这个 default 财务报告和审定财务报表 message 与政策规则共享的选项.
DependenciesRuleOptions, (中文(简体) ), DependenciesPolicy备选案文 dependencies 财务报告和审定财务报表 element-types 规则和他们的政策.
EntryPointRuleOptions, (中文(简体) ), EntryPointPolicy备选案文 entry-point 规则及其政策.
ExternalRuleOptions, (中文(简体) ), ExternalPolicy, (中文(简体) ), ExternalLibrariesSelector备选案文 external 规则、政策和图书馆选择器.
NoPrivateOptions备选案文 no-private 规则.
NoUnknownDependenciesOptions备选案文 no-unknown-dependencies 财务报告和审定财务报表 no-unknown 规则.
RuleOptions任何规则的选择.
RuleName, (中文(简体) ), RuleShortName, (中文(简体) ), SettingsKey, (中文(简体) ), RuleEffect, (中文(简体) ), DependencyNodeKey匹配值的结合 常数。 。 。 .
NormalizeConfigOptions, (中文(简体) ), NormalizeSettingsOptions, (中文(简体) ), RuleOptionsValidation备选案文 函数。 。 。 .
JsonSchema一个JSON schema对象,例如规则选项的 schema.

这个 no-ignored-dependencies, (中文(简体) ), no-ignored 财务报告和审定财务报表 no-unknown-files 规则没有选择. DependenciesRule, (中文(简体) ), DependenciesRuleNormalized, (中文(简体) ), EntryPointRule, (中文(简体) ), ExternalRule, (中文(简体) ), ExternalLibrarySelectors, (中文(简体) ), RulePolicy 财务报告和审定财务报表 AliasSetting 已贬值.

捐款

欢迎贡献者. 请读一下 提供指南 财务报告和审定财务报表 行为守则。 。 。 .

许可证

麻省理工学院,看 自由主义 详细情况.

版本与发布记录

@boundaries/config 共发布 3 个版本,首次发布于 2026/11/02;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.0.1latest2026/11/053 天前
1.0.02026/11/026 天前
0.0.0-stage2026/11/026 天前

关于 @boundaries/config 的常见问题

@boundaries/config 是什么?

@ 边界工具的设置和规则选项的规范化和验证

如何安装 @boundaries/config?

在项目目录运行 npm install @boundaries/config,或使用 pnpm add / yarn add / bun add。

@boundaries/config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@boundaries/config 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@boundaries/config 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@boundaries/config 可以商用吗?

@boundaries/config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@boundaries/config 的下载量有多少?

根据 npm 官方下载统计,@boundaries/config 在 2026/10/09 – 2026/11/07 这 30 天内被下载 94,639 次,日均约 3,155 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@boundaries/config 还在维护吗?

最新版本 1.0.1 发布于 2026/11/05(3 天前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。