@boundaries/config

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

Normalization and validation of the settings and rule options of @boundaries tools

原始使用文档
文档目录27 节
  1. Table of Contents
  2. Introduction
  3. Features
  4. Installation
  5. Browser Support
  6. Quick Start
  7. Core Concepts
  8. Diagnostics
  9. Diagnostic Paths
  10. Normalized Values
  11. Usage
  12. Normalizing a Config
  13. Normalizing Settings
  14. Validating Rule Options
  15. Normalizing the Dependencies Rule Options
  16. Getting the Schema of the Rule Options
  17. API Reference
  18. Functions
  19. Type Guards
  20. Docs Links
  21. Constants
  22. Type Reference
  23. Result Types
  24. Normalized Types
  25. Settings and Rule Options Types
  26. Contributing
  27. License

License Build status Coverage Status Quality Gate Mutation testing badge

NPM downloads Last commit Last release

@boundaries/config

Normalization and validation of the settings and rule options of @boundaries/eslint-plugin, without ESLint.

Table of Contents

Introduction

@boundaries/config reads what a user writes in the boundaries/* settings and in the rule options of @boundaries/eslint-plugin: it applies their defaults, converts their legacy forms, leaves out the invalid entries and returns every problem as a diagnostic, with the path of the entry that causes it.

The ESLint plugin uses it and prints the diagnostics as warnings. A tool without ESLint, such as an editor or a playground, can use it to show the same problems in its own interface.

[!NOTE] This package does not run ESLint, read files or print anything. It receives the config objects as values and returns the normalized values and their problems; showing the problems is up to the host.

Features

  • Settings normalization — defaults applied, legacy settings converted and invalid entries left out
  • Rule options validation against the JSON schema of each rule, as ESLint validates them
  • Policy checks — unrecognized selector shapes and deprecated syntax in the policies of the rules
  • Diagnostics with a level, the texts the ESLint plugin prints and the path of each affected entry
  • Pure functions — results are computed on every call and the input is never mutated
  • Runs in Node.js and in browsers, without ESLint

Installation

Install the package via npm:

npm install @boundaries/config

Browser Support

The package does not depend on ESLint or Node.js, so it also runs in browsers. Bundlers that build for browsers, such as webpack, Vite or esbuild, select its browser build through the browser condition of its exports field, and that build needs no polyfills of Node.js modules or globals like process.

The package never reads environment variables or the working directory: the host resolves the root path of the project and passes it as the rootPath option.

Quick Start

Normalize the boundaries part of an ESLint config and get its problems:

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]],
//   },
// ]

Core Concepts

Diagnostics

Functions never print or throw because of a problem in their input. They return each problem as a 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: how the input is treated.
    • "error": the input is rejected, as ESLint rejects options that fail the rule schema.
    • "warning": the input is ignored or has no effect.
    • "deprecation": the input uses a legacy syntax that still works.
  • title and detail: the texts that the ESLint plugin prints. detail is optional, and it usually ends with a link to the docs.
  • paths: one path per affected entry.

A problem found in several entries is returned once, with the paths of all of them, and the diagnostics come in the order the ESLint plugin prints them.

Diagnostic Paths

A path is the list of object keys and array indexes that leads to the affected entry, from the root of the input of the function that returns it. An empty path, [], means the whole input.

FunctionRoot of the pathsExample
normalizeConfigThe config object["rules", "boundaries/dependencies", 1, "default"]
normalizeSettingsThe settings object["boundaries/elements", 1]
validateRuleOptionsThe options object of the rule entry["policies", 0]

A host can use the paths to point at the entry in its own interface, such as highlighting it in an editor.

Normalized Values

normalizeConfig and normalizeSettings return a ConfigResult, { value, diagnostics }. The value is always set, whatever the input: missing settings get their defaults, legacy forms are converted and invalid entries are left out, so a host can use it even when there are diagnostics.

Usage

Normalizing a Config

normalizeConfig takes the boundaries part of an ESLint config object, { settings, rules }. It normalizes the settings with normalizeSettings, and validates each rule entry of the plugin as ESLint validates it, and then as the plugin does:

Rule entryDiagnosticsIn value.rules
Key without the plugin prefix, such as import/no-cycleNoneNo
Severity other than 0, 1, 2, "off", "warn" or "error"An errorNo
Unknown rule of the pluginAn error, unless the rule is offNo
Rule that is offNone, because ESLint does not validate itYes, with its options treated as not set when they fail the rule schema
Options that fail the rule schemaAn error, the only one of the entryNo
Valid optionsThe warnings and deprecations of validateRuleOptionsYes

The severity can be written alone, "warn", or as the first item of an array, ["warn", { ... }]. The rules are keyed by short name in value.rules, and the options of the dependencies rule, and of the deprecated element-types rule, are normalized with 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"]],
//   },
// ]

When the plugin is registered with another name in the ESLint config, pass it as pluginName. Only the rules with that prefix are read:

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 } }

[!NOTE] The settings keep the boundaries/ prefix whatever the plugin name is, as the ESLint plugin reads them.

Normalizing Settings

normalizeSettings takes the settings object of an ESLint config and reads only its boundaries/* keys. It applies the default of each missing setting, converts the legacy settings, such as boundaries/types or boundaries/elements-single-type, into their current form and leaves out the invalid entries. The settings normalized reference lists each property and its default.

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"]],
//   },
// ]

The rootPath option is the root path of the project, already resolved by the host. The ESLint plugin resolves it from the boundaries/root-path setting, the ESLINT_PLUGIN_BOUNDARIES_ROOT_PATH environment variable and the working directory. Without the option, the normalized rootPath is the boundaries/root-path setting as written.

[!NOTE] When the boundaries/legacy-warnings setting is false, the legacy syntax is not reported: neither in the settings nor, through normalizeConfig, in the rule options.

Validating Rule Options

validateRuleOptions validates the options object of a single rule entry, the item after the severity. It validates it against the rule schema, as ESLint does, and then, for the rules with policies, it checks the shape of their selectors and, when legacyWarnings is true, their deprecated syntax.

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]],
//   },
// ]

When the options fail the rule schema, the schema error is the only diagnostic, because ESLint never runs a rule whose options fail it. A host that already runs ESLint, which validates the schema itself, passes schema: false to skip it:

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 });
// []

[!NOTE] The rule name always has the boundaries/ prefix, whatever name the plugin is registered with in the ESLint config.

Normalizing the Dependencies Rule Options

normalizeDependenciesRuleOptions applies the defaults of the options of the dependencies rule and normalizes the selectors of their policies, so a host can match them with @boundaries/elements. It assumes options that passed the rule schema and reports no problem: validate them first with 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,
// }

[!WARNING] The normalized selectors are shared with the memoization of @boundaries/elements. Do not mutate them.

Getting the Schema of the Rule Options

getRuleOptionsSchema returns the JSON schema of the options of a rule, as the ESLint plugin declares it in the rule meta.schema: an array with the schema of each option, empty when the rule takes no options.

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");
// []

[!WARNING] The returned schemas are shared between calls. Do not mutate them.

API Reference

Functions

normalizeConfig

Normalizes the boundaries part of an ESLint config, { settings, rules }. See Normalizing a Config.

  • Parameters:
    • config: unknown — The config object. Its settings and rules are optional; any other key is ignored.
    • options: NormalizeConfigOptions — Optional.
      • pluginName: string — Optional. The prefix of the rule names in rules. Default "boundaries".
      • rootPath: string — Optional. The root path of the project, already resolved by the host. Without it, the normalized rootPath is the boundaries/root-path setting as written.
  • Returns: ConfigResult<ConfigNormalized> — The normalized config and the problems found, with paths from the root of the config object.
const { value, diagnostics } = normalizeConfig(config, { rootPath: "/project" });

normalizeSettings

Normalizes the boundaries/* settings. See Normalizing Settings.

  • Parameters:
    • settings: Record<string, unknown> | undefined — The settings object of an ESLint config. Only its boundaries/* keys are read.
    • options: NormalizeSettingsOptions — Optional.
      • rootPath: string — Optional. The root path of the project, already resolved by the host. Without it, the normalized rootPath is the boundaries/root-path setting as written.
  • Returns: ConfigResult<SettingsNormalized> — The normalized settings and the problems found, with paths from the root of the settings object.
const { value, diagnostics } = normalizeSettings(config.settings, { rootPath: "/project" });

validateRuleOptions

Validates the options of a rule entry. See Validating Rule Options.

  • Parameters:
    • ruleName: RuleName — The name of the rule, with the boundaries/ prefix, such as "boundaries/dependencies".
    • options: unknown — The options object of the rule entry, or undefined when the entry has no options.
    • validation: RuleOptionsValidation — What to validate.
      • legacyWarnings: boolean — Whether to report the deprecated syntax of the policies, as the boundaries/legacy-warnings setting does.
      • schema: boolean — Optional. Whether to validate the options against the rule schema, as ESLint does with the rule meta.schema. Default true; a host that already runs ESLint passes false.
  • Returns: Diagnostic[] — The problems found, with paths from the root of the options object. When the schema validation fails, only its error.
const diagnostics = validateRuleOptions("boundaries/dependencies", options, {
  legacyWarnings: true,
});

normalizeDependenciesRuleOptions

Applies the defaults of the options of the dependencies rule and normalizes the selectors of their policies. See Normalizing the Dependencies Rule Options.

  • Parameters:
    • options: DependenciesRuleOptions | undefined — The options of the dependencies rule, or of the deprecated element-types rule, already validated against the rule schema.
  • Returns: DependenciesRuleOptionsNormalized — The options with their defaults applied. The policies come from policies, or from the deprecated rules when policies is not set, and each one keeps its index.
const options = normalizeDependenciesRuleOptions({ default: "allow", policies: [] });

getRuleOptionsSchema

Returns the JSON schema of the options of a rule. See Getting the Schema of the Rule Options.

  • Parameters:
    • ruleName: RuleName — The name of the rule, with the boundaries/ prefix.
  • Returns: JsonSchema[] — The schema of each option of the rule, empty when the rule takes no options.
const schema = getRuleOptionsSchema("boundaries/dependencies");

Type Guards

Each one receives a value of type unknown and returns true when the value is of the type.

FunctionNarrows toReturns true for
isSettingsKeySettingsKeyA key of the plugin settings, such as "boundaries/elements".
isDependencyNodeKeyDependencyNodeKeyA built-in dependency node: "import", "export", "require" or "dynamic-import".
isRuleNameRuleNameA rule name with the boundaries/ prefix, such as "boundaries/dependencies".
isRuleShortNameRuleShortNameA rule name without the prefix, such as "dependencies".
isRuleEffectRuleEffect"allow" or "disallow".
isRulePolicyRuleEffect(Deprecated) Alias of isRuleEffect.
isRuleName("boundaries/dependencies"); // true
isRuleName("dependencies"); // false
isRuleShortName("dependencies"); // true

Builders of the links to jsboundaries.dev that the diagnostics carry. Every anchor parameter is an optional string, added to the URL as #<anchor>, and every function returns a string.

FunctionReturns
docsUrl(path, anchor?)The URL of a docs page: https://www.jsboundaries.dev/docs/<path>/.
getRuleDocsPath(ruleName)The path of the docs page of a rule, rules/<short name>. Deprecated rules get the page of the rule that replaces them.
ruleDocsUrl(ruleName, anchor?)The URL of the docs page of a rule.
moreInfoLink(path, anchor?)More info: <url>, with the URL of a docs page.
moreInfoSettingsLink(anchor?)moreInfoLink of the settings page.
moreInfoElementsLink(anchor?)moreInfoLink of the element descriptors page.
moreInfoLegacySettingsLink(anchor?)moreInfoLink of the legacy settings page.
moreInfoSelectorsLink(anchor?)moreInfoLink of the element selectors page.
migrationGuideLink(versionFrom, versionTo, anchor?)moreInfoLink of the migration guide between two major versions.
migrationToV2GuideLink(anchor?)migrationGuideLink from version 1 to 2.
migrationToV6GuideLink(anchor?)migrationGuideLink from version 5 to 6.
migrationToV7GuideLink(anchor?)migrationGuideLink from version 6 to 7.

path, versionFrom and versionTo are strings, and ruleName is a RuleName.

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

Constants

ConstantValue
DIAGNOSTIC_LEVELS_MAPThe levels of a diagnostic: { ERROR: "error", WARNING: "warning", DEPRECATION: "deprecation" }.
RULE_SEVERITIES_MAPThe severities of a normalized rule entry: { OFF: "off", WARN: "warn", ERROR: "error" }.
RULE_NAMES_MAP, RULE_NAMESThe rule names with the boundaries/ prefix, as a map and as an array.
RULE_SHORT_NAMES_MAP, RULE_SHORT_NAMESThe rule names without the prefix, as a map and as an array.
SETTINGS_KEYS_MAPThe keys of the settings, such as ELEMENTS: "boundaries/elements".
SETTINGSThe keys of the settings and of the rules, the valid element descriptor modes and dependency node kinds, and the selectors of the built-in dependency nodes, DEFAULT_DEPENDENCY_NODES.
DEPENDENCY_NODE_KEYS_MAPThe built-in dependency nodes: { REQUIRE: "require", IMPORT: "import", DYNAMIC_IMPORT: "dynamic-import", EXPORT: "export" }.
RULE_EFFECTS_MAPThe effects of a policy: { ALLOW: "allow", DISALLOW: "disallow" }. RULE_POLICIES_MAP is its deprecated alias.
NO_UNKNOWN_DEPENDENCIES_REQUIRE_MAPThe values of the require option of the no-unknown-dependencies rule: { ALL: "all", ELEMENT: "element", FILE: "file", ANY: "any" }.
LEGACY_TEMPLATES_DEFAULT, LEGACY_WARNINGS_DEFAULT, ELEMENTS_SINGLE_TYPE_DEFAULT, CACHE_DEFAULTThe defaults of the boundaries/legacy-templates, boundaries/legacy-warnings, boundaries/elements-single-match and boundaries/cache settings: true.
FILES_SINGLE_MATCH_DEFAULTThe default of the boundaries/files-single-match setting: false.
PLUGIN_NAME"boundaries".
WEBSITE_URL, REPO_URL, PLUGIN_ISSUES_URLThe URLs of the website, the repository and its issues.

The values of the maps are also exported one by one, such as DEPENDENCIES, DEPENDENCY_NODE_IMPORT, RULE_EFFECT_ALLOW or NO_UNKNOWN_DEPENDENCIES_REQUIRE_ANY.

Type Reference

Result Types

ConfigResult

Returned by normalizeConfig and normalizeSettings, as ConfigResult<T>.

PropertyTypeDescription
valueTThe normalized value. Always set: invalid entries are left out.
diagnosticsDiagnostic[]The problems found, in the order that the ESLint plugin prints them, each one once.

Diagnostic

A problem found in the input. See Diagnostics.

PropertyTypeDescription
levelDiagnosticLevel"error", "warning" or "deprecation".
titlestringThe title that the ESLint plugin prints.
detailstring | undefinedThe details and the docs link that the ESLint plugin prints under the title.
pathsDiagnosticPath[]One path per affected entry. DiagnosticPath is (string | number)[].

Normalized Types

ConfigNormalized

The value returned by normalizeConfig.

PropertyTypeDescription
settingsSettingsNormalizedThe normalized settings.
rules{ [Name in RuleShortName]?: RuleEntryNormalized<Name> }The rules of the plugin found in rules, by short name. Entries left out by an error are missing.

RuleEntryNormalized

A rule entry of ConfigNormalized, as RuleEntryNormalized<Name>.

PropertyTypeDescription
severityRuleSeverity"off", "warn" or "error", whether it was written as a number or as a string.
optionsDependenciesRuleOptionsNormalized for dependencies and element-types, unknown for the othersThe options of the rule: normalized for the rules with dependencies policies, as written for the others.

SettingsNormalized

The value returned by normalizeSettings, and the settings of ConfigNormalized.

PropertyTypeDescription
elementDescriptorsElementDescriptorsThe valid descriptors of boundaries/elements, or of the deprecated boundaries/types when boundaries/elements is not set. Legacy string descriptors are converted into objects. Default [].
elementsSingleMatchbooleanboundaries/elements-single-match, or the deprecated boundaries/elements-single-type when it is not set. Default true.
fileDescriptorsFileDescriptorsThe valid descriptors of boundaries/files. Default [].
filesSingleMatchbooleanboundaries/files-single-match. Default false.
ignorePathsstring[] | undefinedboundaries/ignore, always as an array. Default undefined.
includePathsstring[] | undefinedboundaries/include, always as an array. Default undefined.
rootPathstring | undefinedThe rootPath option, or boundaries/root-path as written when the option is not passed.
dependencyNodesDependencyNodeSelector[]The selectors of the nodes in boundaries/dependency-nodes, followed by the valid boundaries/additional-dependency-nodes. By default, the selectors of import, export, require and dynamic-import.
legacyTemplatesbooleanboundaries/legacy-templates. Default true.
cachebooleanboundaries/cache. Default true.
legacyWarningsbooleanboundaries/legacy-warnings. Default true.
flagAsExternalFlagAsExternalOptionsboundaries/flag-as-external, each valid option over its default: { unresolvableAlias: true, inNodeModules: true, outsideRootPath: false, customSourcePatterns: [] }.
debugDebugSettingNormalizedboundaries/debug, with its defaults.

ElementDescriptors, FileDescriptors and FlagAsExternalOptions are types of @boundaries/elements.

DebugSettingNormalized

PropertyTypeDescription
enabledbooleanWhether debug mode is enabled. Default false.
messages{ files: boolean; dependencies: boolean; violations: boolean }Whether to print the debug messages of files, dependencies and rule violations. Each one is true by default.
filter.filesFileSelectorNormalized | EntitySelectorNormalized | undefinedThe normalized selector that filters the debug messages of files, when valid.
filter.dependenciesDependencySelectorNormalized | undefinedThe normalized selector that filters the debug messages of dependencies, when valid.

DependenciesRuleOptionsNormalized

Returned by normalizeDependenciesRuleOptions, and the options of the dependencies and element-types entries of ConfigNormalized.

PropertyTypeDescription
defaultRuleEffectThe effect when no policy matches: "allow", or "disallow" for any other value.
messagestring | undefinedThe custom message of all the rule violations, when set.
policiesDependenciesPolicyNormalized[]policies, or the deprecated rules when policies is not set, with their selectors normalized. Each one keeps the index it has in the options.
checkAllOriginsbooleanWhether to check the dependencies of every origin, not only the local ones. Default false.
checkUnknownLocalsbooleanWhether to check the local dependencies to unknown elements. Default false.
checkInternalsbooleanWhether to check the dependencies between files of the same element. Default false.

DependenciesPolicyNormalized

PropertyTypeDescription
fromEntitySelectorNormalized | undefinedThe selector of the entities that the dependency comes from.
toEntitySelectorNormalized | undefinedThe selector of the entities that the dependency goes to.
dependencyDependencyInfoSelectorNormalized | undefinedThe selector of the dependency metadata.
allowDependencySelectorNormalized | EntitySelectorNormalized | undefinedThe selector of the allowed dependencies.
disallowDependencySelectorNormalized | EntitySelectorNormalized | undefinedThe selector of the disallowed dependencies.
importKindDependencyKind | undefined(Deprecated) The kind of import that the policy applies to, as written.
messagestring | undefinedThe custom message of the policy violations, as written.

The selector types are types of @boundaries/elements, which describes them in its selector reference.

Settings and Rule Options Types

The package exports the types of what a user writes, so a host can type its own config objects. The main ones are:

TypeDescribes
SettingsThe boundaries/* settings, by key.
IgnoreSetting, IncludeSetting, RootPathSetting, DebugSettingThe values of the boundaries/ignore, boundaries/include, boundaries/root-path and boundaries/debug settings.
DependencyNodeSelectorAn item of boundaries/additional-dependency-nodes: { selector: string; kind: DependencyKind; name?: string }.
RuleBaseOptionsThe default and message options that the rules with policies share.
DependenciesRuleOptions, DependenciesPolicyThe options of the dependencies and element-types rules, and their policies.
EntryPointRuleOptions, EntryPointPolicyThe options of the entry-point rule, and its policies.
ExternalRuleOptions, ExternalPolicy, ExternalLibrariesSelectorThe options of the external rule, its policies and its library selectors.
NoPrivateOptionsThe options of the no-private rule.
NoUnknownDependenciesOptionsThe options of the no-unknown-dependencies and no-unknown rules.
RuleOptionsThe options of any rule.
RuleName, RuleShortName, SettingsKey, RuleEffect, DependencyNodeKeyThe unions of the values of the matching constants.
NormalizeConfigOptions, NormalizeSettingsOptions, RuleOptionsValidationThe options of the functions.
JsonSchemaA JSON schema object, such as the schema of a rule option.

The no-ignored-dependencies, no-ignored and no-unknown-files rules take no options. DependenciesRule, DependenciesRuleNormalized, EntryPointRule, ExternalRule, ExternalLibrarySelectors, RulePolicy and AliasSetting are deprecated.

Contributing

Contributors are welcome. Please read the contributing guidelines and code of conduct.

License

MIT, see LICENSE for details.

版本与发布记录

@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 是什么?

Normalization and validation of the settings and rule options of @boundaries tools

如何安装 @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 和提交记录判断。