@boundaries/eslint-plugin 5.3.1 → 6.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +9 -9
  2. package/dist/Config/Config.d.ts +6 -3
  3. package/dist/Config/Config.js +18 -7
  4. package/dist/Config/Recommended.d.ts +1 -1
  5. package/dist/Config/Recommended.js +3 -2
  6. package/dist/Config/Strict.d.ts +1 -1
  7. package/dist/Config/Strict.js +2 -2
  8. package/dist/Debug/Debug.d.ts +34 -0
  9. package/dist/Debug/Debug.js +285 -0
  10. package/dist/Debug/index.d.ts +1 -0
  11. package/dist/{Support → Debug}/index.js +0 -1
  12. package/dist/Elements/Elements.d.ts +11 -9
  13. package/dist/Elements/Elements.js +20 -34
  14. package/dist/Elements/Elements.types.d.ts +1 -0
  15. package/dist/Messages/CustomMessages.d.ts +44 -0
  16. package/dist/Messages/CustomMessages.js +156 -0
  17. package/dist/Messages/CustomMessages.types.d.ts +25 -0
  18. package/dist/Messages/CustomMessages.types.js +2 -0
  19. package/dist/Messages/Messages.d.ts +42 -13
  20. package/dist/Messages/Messages.js +400 -177
  21. package/dist/Messages/index.d.ts +2 -0
  22. package/dist/Messages/index.js +2 -0
  23. package/dist/Public/Config.types.d.ts +2 -2
  24. package/dist/Public/Config.types.js +2 -2
  25. package/dist/Public/Rules.types.d.ts +5 -4
  26. package/dist/Public/Rules.types.js +5 -6
  27. package/dist/Public/Settings.types.d.ts +3 -2
  28. package/dist/Public/Settings.types.js +4 -3
  29. package/dist/Public/index.d.ts +1 -0
  30. package/dist/Rules/Dependencies.d.ts +59 -0
  31. package/dist/Rules/Dependencies.js +439 -0
  32. package/dist/Rules/EntryPoint.js +44 -94
  33. package/dist/Rules/External.js +93 -68
  34. package/dist/Rules/NoIgnored.js +4 -4
  35. package/dist/Rules/NoPrivate.js +18 -5
  36. package/dist/Rules/NoUnknown.js +5 -5
  37. package/dist/Rules/NoUnknownFiles.js +4 -3
  38. package/dist/Rules/Support/DependencyRule.d.ts +9 -1
  39. package/dist/Rules/Support/DependencyRule.js +15 -15
  40. package/dist/Rules/Support/DependencyRule.types.d.ts +1 -1
  41. package/dist/Rules/Support/Helpers.d.ts +6 -2
  42. package/dist/Rules/Support/Helpers.js +7 -31
  43. package/dist/Settings/Helpers.d.ts +83 -1
  44. package/dist/Settings/Helpers.js +197 -7
  45. package/dist/Settings/Settings.d.ts +19 -2
  46. package/dist/Settings/Settings.js +20 -10
  47. package/dist/Settings/Validations.d.ts +11958 -45
  48. package/dist/Settings/Validations.js +797 -184
  49. package/dist/Settings/index.d.ts +0 -1
  50. package/dist/Settings/index.js +0 -1
  51. package/dist/{Settings → Shared}/Settings.types.d.ts +143 -37
  52. package/dist/{Settings → Shared}/Settings.types.js +32 -6
  53. package/dist/{Support/Common.d.ts → Shared/TypeHelpers.d.ts} +18 -0
  54. package/dist/{Support/Common.js → Shared/TypeHelpers.js} +28 -1
  55. package/dist/Shared/index.d.ts +2 -0
  56. package/dist/Shared/index.js +18 -0
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +12 -10
  59. package/package.json +9 -8
  60. package/dist/Rules/ElementTypes.d.ts +0 -25
  61. package/dist/Rules/ElementTypes.js +0 -279
  62. package/dist/Support/Debug.d.ts +0 -5
  63. package/dist/Support/Debug.js +0 -54
  64. package/dist/Support/index.d.ts +0 -2
@@ -1,4 +1,3 @@
1
1
  export * from "./Settings";
2
2
  export * from "./Validations";
3
- export * from "./Settings.types";
4
3
  export * from "./Helpers";
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Settings"), exports);
18
18
  __exportStar(require("./Validations"), exports);
19
- __exportStar(require("./Settings.types"), exports);
20
19
  __exportStar(require("./Helpers"), exports);
@@ -1,4 +1,4 @@
1
- import type { DependencyKind, ElementDescriptors, ElementsSelector, CapturedValues, ExternalLibrariesSelector } from "@boundaries/elements";
1
+ import type { DependencyKind, DependencySelector, ElementDescriptors, ElementsSelector, FlagAsExternalOptions, DependencyDataSelector, SimpleElementSelectorByType, BaseElementSelectorWithOptions, MicromatchPatternNullable } from "@boundaries/elements";
2
2
  import type { ESLint, Linter, Rule } from "eslint";
3
3
  export declare const PLUGIN_NAME: "boundaries";
4
4
  export declare const PLUGIN_ENV_VARS_PREFIX: "ESLINT_PLUGIN_BOUNDARIES";
@@ -9,7 +9,9 @@ export declare const DEPENDENCY_NODE_REQUIRE: "require";
9
9
  export declare const DEPENDENCY_NODE_IMPORT: "import";
10
10
  export declare const DEPENDENCY_NODE_DYNAMIC_IMPORT: "dynamic-import";
11
11
  export declare const DEPENDENCY_NODE_EXPORT: "export";
12
+ /** @deprecated Use DEPENDENCIES instead */
12
13
  export declare const ELEMENT_TYPES: "element-types";
14
+ export declare const DEPENDENCIES: "dependencies";
13
15
  export declare const ENTRY_POINT: "entry-point";
14
16
  export declare const EXTERNAL: "external";
15
17
  export declare const NO_IGNORED: "no-ignored";
@@ -20,7 +22,9 @@ export declare const NO_UNKNOWN: "no-unknown";
20
22
  * Map of all rule short names, without the plugin prefix.
21
23
  */
22
24
  export declare const RULE_SHORT_NAMES_MAP: {
25
+ /** @deprecated Use DEPENDENCIES instead */
23
26
  readonly ELEMENT_TYPES: "element-types";
27
+ readonly DEPENDENCIES: "dependencies";
24
28
  readonly ENTRY_POINT: "entry-point";
25
29
  readonly EXTERNAL: "external";
26
30
  readonly NO_IGNORED: "no-ignored";
@@ -32,7 +36,9 @@ export declare const RULE_SHORT_NAMES_MAP: {
32
36
  * Map of all rule names, including the default plugin prefix.
33
37
  */
34
38
  export declare const RULE_NAMES_MAP: {
39
+ /** @deprecated Use DEPENDENCIES instead */
35
40
  readonly ELEMENT_TYPES: "boundaries/element-types";
41
+ readonly DEPENDENCIES: "boundaries/dependencies";
36
42
  readonly ENTRY_POINT: "boundaries/entry-point";
37
43
  readonly EXTERNAL: "boundaries/external";
38
44
  readonly NO_IGNORED: "boundaries/no-ignored";
@@ -43,7 +49,7 @@ export declare const RULE_NAMES_MAP: {
43
49
  /**
44
50
  * List of all rule names
45
51
  */
46
- export declare const RULE_NAMES: readonly ("boundaries/element-types" | "boundaries/entry-point" | "boundaries/external" | "boundaries/no-ignored" | "boundaries/no-private" | "boundaries/no-unknown-files" | "boundaries/no-unknown")[];
52
+ export declare const RULE_NAMES: readonly ("boundaries/element-types" | "boundaries/dependencies" | "boundaries/entry-point" | "boundaries/external" | "boundaries/no-ignored" | "boundaries/no-private" | "boundaries/no-unknown-files" | "boundaries/no-unknown")[];
47
53
  /**
48
54
  * Type representing all valid rule names, including the default plugin prefix.
49
55
  */
@@ -55,7 +61,7 @@ export type RuleNames = typeof RULE_NAMES;
55
61
  /**
56
62
  * List of all rule short names, without the plugin prefix.
57
63
  */
58
- export declare const RULE_SHORT_NAMES: readonly ("external" | "element-types" | "entry-point" | "no-ignored" | "no-private" | "no-unknown-files" | "no-unknown")[];
64
+ export declare const RULE_SHORT_NAMES: readonly ("element-types" | "dependencies" | "entry-point" | "external" | "no-ignored" | "no-private" | "no-unknown-files" | "no-unknown")[];
59
65
  /**
60
66
  * Type representing all valid rule short names, without the plugin prefix.
61
67
  */
@@ -64,10 +70,6 @@ export type RuleShortName = (typeof RULE_SHORT_NAMES)[number];
64
70
  * List of all rule short names, without the plugin prefix.
65
71
  */
66
72
  export type RuleShortNames = typeof RULE_SHORT_NAMES;
67
- /**
68
- * Main key used in rule definitions.
69
- */
70
- export declare const FROM: "from";
71
73
  /**
72
74
  * Different types of dependency nodes supported by the plugin by default.
73
75
  * Each type corresponds to a common way of importing or requiring modules in JavaScript/TypeScript.
@@ -116,9 +118,13 @@ export declare const SETTINGS: {
116
118
  readonly ADDITIONAL_DEPENDENCY_NODES: "boundaries/additional-dependency-nodes";
117
119
  readonly LEGACY_TEMPLATES: "boundaries/legacy-templates";
118
120
  readonly CACHE: "boundaries/cache";
121
+ readonly FLAG_AS_EXTERNAL: "boundaries/flag-as-external";
122
+ readonly DEBUG_SETTING: "boundaries/debug";
119
123
  readonly DEBUG: "ESLINT_PLUGIN_BOUNDARIES_DEBUG";
120
124
  readonly ENV_ROOT_PATH: "ESLINT_PLUGIN_BOUNDARIES_ROOT_PATH";
125
+ /** @deprecated Use RULE_DEPENDENCIES instead */
121
126
  readonly RULE_ELEMENT_TYPES: "boundaries/element-types";
127
+ readonly RULE_DEPENDENCIES: "boundaries/dependencies";
122
128
  readonly RULE_ENTRY_POINT: "boundaries/entry-point";
123
129
  readonly RULE_EXTERNAL: "boundaries/external";
124
130
  readonly RULE_NO_IGNORED: "boundaries/no-ignored";
@@ -133,30 +139,38 @@ export declare const SETTINGS: {
133
139
  readonly require: readonly [{
134
140
  readonly selector: "CallExpression[callee.name=require] > Literal";
135
141
  readonly kind: "value";
142
+ readonly name: "require";
136
143
  }];
137
144
  readonly import: readonly [{
138
145
  readonly selector: "ImportDeclaration:not([importKind=type]) > Literal";
139
146
  readonly kind: "value";
147
+ readonly name: "import";
140
148
  }, {
141
149
  readonly selector: "ImportDeclaration[importKind=type] > Literal";
142
150
  readonly kind: "type";
151
+ readonly name: "import";
143
152
  }];
144
153
  readonly "dynamic-import": readonly [{
145
154
  readonly selector: "ImportExpression > Literal";
146
155
  readonly kind: "value";
156
+ readonly name: "dynamic-import";
147
157
  }];
148
158
  readonly export: readonly [{
149
159
  readonly selector: "ExportAllDeclaration:not([exportKind=type]) > Literal";
150
160
  readonly kind: "value";
161
+ readonly name: "export";
151
162
  }, {
152
163
  readonly selector: "ExportAllDeclaration[exportKind=type] > Literal";
153
164
  readonly kind: "type";
165
+ readonly name: "export";
154
166
  }, {
155
167
  readonly selector: "ExportNamedDeclaration:not([exportKind=type]) > Literal";
156
168
  readonly kind: "value";
169
+ readonly name: "export";
157
170
  }, {
158
171
  readonly selector: "ExportNamedDeclaration[exportKind=type] > Literal";
159
172
  readonly kind: "type";
173
+ readonly name: "export";
160
174
  }];
161
175
  };
162
176
  };
@@ -176,6 +190,8 @@ export declare const SETTINGS_KEYS_MAP: {
176
190
  /** @deprecated Use import/resolver settings instead */
177
191
  readonly ALIAS: "boundaries/alias";
178
192
  readonly CACHE: "boundaries/cache";
193
+ readonly FLAG_AS_EXTERNAL: "boundaries/flag-as-external";
194
+ readonly DEBUG: "boundaries/debug";
179
195
  };
180
196
  /**
181
197
  * Default value for the legacy templates setting.
@@ -185,6 +201,10 @@ export declare const LEGACY_TEMPLATES_DEFAULT: true;
185
201
  * Default value for the cache setting.
186
202
  */
187
203
  export declare const CACHE_DEFAULT: true;
204
+ /**
205
+ * Default value for the check-config setting.
206
+ */
207
+ export declare const CHECK_CONFIG_DEFAULT: false;
188
208
  /**
189
209
  * Valid keys for the plugin settings.
190
210
  */
@@ -210,6 +230,50 @@ export type RootPathSetting = string;
210
230
  * @deprecated Use "import/resolver" settings instead
211
231
  */
212
232
  export type AliasSetting = Record<string, string>;
233
+ export type DebugFilterSetting = {
234
+ /** File selectors used to filter file debug messages */
235
+ files?: ElementsSelector[];
236
+ /** Dependency selectors used to filter dependency debug messages */
237
+ dependencies?: DependencySelector[];
238
+ };
239
+ export type DebugSetting = {
240
+ /** Enables debug output when true */
241
+ enabled?: boolean;
242
+ /** Enables specific debug messages */
243
+ messages?: {
244
+ /** Whether to enable debug messages for files */
245
+ files?: boolean;
246
+ /** Whether to enable debug messages for dependencies */
247
+ dependencies?: boolean;
248
+ /** Whether to enable debug messages for rule violations */
249
+ violations?: boolean;
250
+ };
251
+ /** Optional filters for file and dependency debug messages */
252
+ filter?: DebugFilterSetting;
253
+ };
254
+ /**
255
+ * Normalized debug setting.
256
+ */
257
+ export type DebugSettingNormalized = {
258
+ /** Whether debug mode is enabled */
259
+ enabled: boolean;
260
+ /** Settings to enable/disable specific debug messages */
261
+ messages: {
262
+ /** Whether to enable debug messages for files */
263
+ files: boolean;
264
+ /** Whether to enable debug messages for dependencies */
265
+ dependencies: boolean;
266
+ /** Whether to enable debug messages for rule violations */
267
+ violations: boolean;
268
+ };
269
+ /** Debug filters **/
270
+ filter: {
271
+ /** File selectors used to filter file debug messages */
272
+ files?: ElementsSelector[];
273
+ /** Dependency selectors used to filter dependency debug messages */
274
+ dependencies?: DependencySelector[];
275
+ };
276
+ };
213
277
  /**
214
278
  * Settings for the eslint-plugin-boundaries plugin.
215
279
  */
@@ -259,6 +323,10 @@ export type Settings = {
259
323
  [SETTINGS_KEYS_MAP.ALIAS]?: AliasSetting;
260
324
  /** Whether to enable caching for the plugin analysis */
261
325
  [SETTINGS_KEYS_MAP.CACHE]?: boolean;
326
+ /** Configuration for categorizing dependencies as external or local */
327
+ [SETTINGS_KEYS_MAP.FLAG_AS_EXTERNAL]?: FlagAsExternalOptions;
328
+ /** Debug configuration for tracing files and dependencies */
329
+ [SETTINGS_KEYS_MAP.DEBUG]?: DebugSetting;
262
330
  };
263
331
  /**
264
332
  * Normalized settings for the eslint-plugin-boundaries plugin.
@@ -281,6 +349,10 @@ export type SettingsNormalized = {
281
349
  legacyTemplates: boolean;
282
350
  /** Whether caching is enabled */
283
351
  cache: boolean;
352
+ /** Configuration for categorizing dependencies as external or local */
353
+ flagAsExternal: FlagAsExternalOptions;
354
+ /** Debug configuration */
355
+ debug: DebugSettingNormalized;
284
356
  };
285
357
  /**
286
358
  * Eslint boundaries plugin rules.
@@ -289,8 +361,9 @@ export type SettingsNormalized = {
289
361
  * @template PluginName - The name of the plugin, defaults to "boundaries". It defines the prefix for the rule names.
290
362
  */
291
363
  export type Rules<PluginName extends string = typeof PLUGIN_NAME> = {
292
- [K in `${PluginName}/${typeof ELEMENT_TYPES | typeof ENTRY_POINT | typeof EXTERNAL | typeof NO_IGNORED | typeof NO_PRIVATE | typeof NO_UNKNOWN_FILES | typeof NO_UNKNOWN}`]?: K extends `${PluginName}/${typeof ELEMENT_TYPES}` ? Linter.RuleEntry<ElementTypesRuleOptions[]> : K extends `${PluginName}/${typeof ENTRY_POINT}` ? Linter.RuleEntry<EntryPointRuleOptions[]> : K extends `${PluginName}/${typeof EXTERNAL}` ? Linter.RuleEntry<ExternalRuleOptions[]> : K extends `${PluginName}/${typeof NO_PRIVATE}` ? Linter.RuleEntry<NoPrivateOptions[]> : Linter.RuleEntry<never>;
364
+ [K in `${PluginName}/${typeof ELEMENT_TYPES | typeof DEPENDENCIES | typeof ENTRY_POINT | typeof EXTERNAL | typeof NO_IGNORED | typeof NO_PRIVATE | typeof NO_UNKNOWN_FILES | typeof NO_UNKNOWN}`]?: K extends `${PluginName}/${typeof ELEMENT_TYPES}` ? Linter.RuleEntry<ElementTypesRuleOptions[]> : K extends `${PluginName}/${typeof DEPENDENCIES}` ? Linter.RuleEntry<DependenciesRuleOptions[]> : K extends `${PluginName}/${typeof ENTRY_POINT}` ? Linter.RuleEntry<EntryPointRuleOptions[]> : K extends `${PluginName}/${typeof EXTERNAL}` ? Linter.RuleEntry<ExternalRuleOptions[]> : K extends `${PluginName}/${typeof NO_PRIVATE}` ? Linter.RuleEntry<NoPrivateOptions[]> : Linter.RuleEntry<never>;
293
365
  };
366
+ export type FlagAsExternalBooleanOptionKey = "unresolvableAlias" | "inNodeModules" | "outsideRootPath";
294
367
  /**
295
368
  * ESLint configuration with optional settings and rules specific to the boundaries plugin.
296
369
  */
@@ -349,49 +422,49 @@ export type RuleBaseOptions = {
349
422
  /** Custom message for all rule violations. It can be overridden at the rule level. */
350
423
  message?: string;
351
424
  };
352
- export type RuleReport = {
353
- message?: string;
354
- isDefault?: boolean;
355
- importKind?: DependencyKind;
356
- disallow?: ElementsSelector;
357
- element: ElementsSelector;
358
- index: number;
359
- };
360
- export type RuleResultReport = {
361
- path: string | null;
362
- specifiers?: string[];
363
- };
364
- export type RuleResult = {
365
- result: boolean;
366
- ruleReport: RuleReport | null;
367
- report: RuleResultReport | null;
368
- };
369
- export type RuleMatcherElementsCapturedValues = {
370
- from: CapturedValues;
371
- target: CapturedValues;
372
- };
425
+ export type RulePolicyEntry = SimpleElementSelectorByType | BaseElementSelectorWithOptions | DependencySelector;
373
426
  /**
374
427
  * Rule that defines allowed or disallowed dependencies between different element types.
375
428
  */
376
- export type ElementTypesRule = {
429
+ export type DependenciesRule = {
430
+ dependency?: DependencyDataSelector;
377
431
  /** Selectors of the source elements that the rule applies to (the elements importing) */
378
432
  from?: ElementsSelector;
379
433
  /** Selectors of the target elements that are disallowed to be imported */
380
434
  to?: ElementsSelector;
381
435
  /** Selectors of the elements that are disallowed to be imported */
382
- disallow?: ElementsSelector;
436
+ disallow?: RulePolicyEntry | RulePolicyEntry[];
383
437
  /** Selectors of the elements that are allowed to be imported */
384
- allow?: ElementsSelector;
438
+ allow?: RulePolicyEntry | RulePolicyEntry[];
385
439
  /** Kind of import that the rule applies to (e.g., "type", "value") */
386
440
  importKind?: DependencyKind;
387
441
  /** Custom message for rule violations */
388
442
  message?: string;
389
443
  };
390
444
  /**
391
- * Options for the element-types rule, including default policy and specific rules.
445
+ * Legacy type for the renamed element-types rule, kept for backward compatibility. It has the same shape as the dependencies rule but with "target" instead of "to" and without the "dependency" field.
446
+ * @deprecated Use DependenciesRule instead
392
447
  */
393
- export type ElementTypesRuleOptions = Omit<RuleBaseOptions, "rules"> & {
448
+ export type ElementTypesRule = DependenciesRule;
449
+ /**
450
+ * Options for the dependencies rule, including default policy and specific rules.
451
+ */
452
+ export type DependenciesRuleOptions = Omit<RuleBaseOptions, "rules"> & {
394
453
  /** Specific rules for defining boundaries between elements */
454
+ rules?: DependenciesRule[];
455
+ /** Whether to check dependencies from all origins (including external and core) or only from local elements (default: `false`, only local). */
456
+ checkAllOrigins?: boolean;
457
+ /** Whether to check local dependencies with unknown elements (not matching any element descriptor) or to ignore them. (default: `false`, ignore them) */
458
+ checkUnknownLocals?: boolean;
459
+ /** Whether to check internal dependencies (dependencies within files in the same element) (default: `false`, ignore them) */
460
+ checkInternals?: boolean;
461
+ };
462
+ /**
463
+ * Legacy type for the renamed element-types rule options, kept for backward compatibility.
464
+ * @deprecated Use DependenciesRuleOptions instead
465
+ */
466
+ export type ElementTypesRuleOptions = Omit<DependenciesRuleOptions, "rules"> & {
467
+ /** Specific rules for defining element types */
395
468
  rules?: ElementTypesRule[];
396
469
  };
397
470
  /**
@@ -416,6 +489,38 @@ export type EntryPointRuleOptions = Omit<RuleBaseOptions, "rules"> & {
416
489
  /** Specific rules for defining entry points between elements */
417
490
  rules?: EntryPointRule[];
418
491
  };
492
+ /**
493
+ * Options for selecting external libraries, including path patterns and optional specifiers.
494
+ * If specifiers are provided, they will be used to match specific imports from the external library.
495
+ */
496
+ export type ExternalLibrarySelectorOptions = {
497
+ /**
498
+ * Micromatch pattern(s) to match only one or more specific subpaths of the external library.
499
+ */
500
+ path?: MicromatchPatternNullable;
501
+ /** Micromatch pattern(s) to match only specific imports/exports */
502
+ specifiers?: string[];
503
+ };
504
+ /**
505
+ * External library selector with options, represented as a tuple where the first element is the import path of the external library, and the second element is an object containing options for selecting only specific paths or specifiers from that library.
506
+ */
507
+ export type ExternalLibrarySelectorWithOptions = [
508
+ string,
509
+ ExternalLibrarySelectorOptions
510
+ ];
511
+ /**
512
+ * External library selector, which can be a simple string (the import path) or an external library selector with options.
513
+ */
514
+ export type ExternalLibrarySelector = string | ExternalLibrarySelectorWithOptions;
515
+ /**
516
+ * External library selectors, which can be a single external library selector or an array of external library selectors.
517
+ * @deprecated Use ExternalLibrariesSelector instead.
518
+ */
519
+ export type ExternalLibrarySelectors = ExternalLibrariesSelector;
520
+ /**
521
+ * External libraries selector, which can be a single external library selector or an array of external library selectors.
522
+ */
523
+ export type ExternalLibrariesSelector = ExternalLibrarySelector | ExternalLibrarySelector[];
419
524
  /**
420
525
  * Rule that defines allowed or disallowed external library imports for specific element types.
421
526
  */
@@ -449,10 +554,11 @@ export type NoPrivateOptions = {
449
554
  /** Custom message for rule violations */
450
555
  message?: string;
451
556
  };
452
- export type RuleOptionsWithRules = ExternalRuleOptions | EntryPointRuleOptions | ElementTypesRuleOptions;
557
+ export type RuleOptionsWithRules = ExternalRuleOptions | EntryPointRuleOptions | DependenciesRuleOptions;
453
558
  export type RuleOptions = RuleOptionsWithRules | NoPrivateOptions;
454
- export type RuleOptionsRules = ExternalRule | EntryPointRule | ElementTypesRule;
455
- export type RuleMainKey = "from" | "to" | "target";
559
+ export type RuleOptionsRules = ExternalRule | EntryPointRule | DependenciesRule;
560
+ export declare const FROM: "from";
561
+ export type RuleMainKey = typeof FROM | "to" | "target";
456
562
  export type ValidateRulesOptions = {
457
563
  mainKey?: RuleMainKey;
458
564
  onlyMainKey?: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RULE_POLICIES_MAP = exports.RULE_POLICY_DISALLOW = exports.RULE_POLICY_ALLOW = exports.CACHE_DEFAULT = exports.LEGACY_TEMPLATES_DEFAULT = exports.SETTINGS_KEYS_MAP = exports.SETTINGS = exports.DEPENDENCY_NODE_KEYS_MAP = exports.FROM = exports.RULE_SHORT_NAMES = exports.RULE_NAMES = exports.RULE_NAMES_MAP = exports.RULE_SHORT_NAMES_MAP = exports.NO_UNKNOWN = exports.NO_UNKNOWN_FILES = exports.NO_PRIVATE = exports.NO_IGNORED = exports.EXTERNAL = exports.ENTRY_POINT = exports.ELEMENT_TYPES = exports.DEPENDENCY_NODE_EXPORT = exports.DEPENDENCY_NODE_DYNAMIC_IMPORT = exports.DEPENDENCY_NODE_IMPORT = exports.DEPENDENCY_NODE_REQUIRE = exports.PLUGIN_ISSUES_URL = exports.WEBSITE_URL = exports.REPO_URL = exports.PLUGIN_ENV_VARS_PREFIX = exports.PLUGIN_NAME = void 0;
3
+ exports.FROM = exports.RULE_POLICIES_MAP = exports.RULE_POLICY_DISALLOW = exports.RULE_POLICY_ALLOW = exports.CHECK_CONFIG_DEFAULT = exports.CACHE_DEFAULT = exports.LEGACY_TEMPLATES_DEFAULT = exports.SETTINGS_KEYS_MAP = exports.SETTINGS = exports.DEPENDENCY_NODE_KEYS_MAP = exports.RULE_SHORT_NAMES = exports.RULE_NAMES = exports.RULE_NAMES_MAP = exports.RULE_SHORT_NAMES_MAP = exports.NO_UNKNOWN = exports.NO_UNKNOWN_FILES = exports.NO_PRIVATE = exports.NO_IGNORED = exports.EXTERNAL = exports.ENTRY_POINT = exports.DEPENDENCIES = exports.ELEMENT_TYPES = exports.DEPENDENCY_NODE_EXPORT = exports.DEPENDENCY_NODE_DYNAMIC_IMPORT = exports.DEPENDENCY_NODE_IMPORT = exports.DEPENDENCY_NODE_REQUIRE = exports.PLUGIN_ISSUES_URL = exports.WEBSITE_URL = exports.REPO_URL = exports.PLUGIN_ENV_VARS_PREFIX = exports.PLUGIN_NAME = void 0;
4
4
  // Plugin constants
5
5
  exports.PLUGIN_NAME = "boundaries";
6
6
  exports.PLUGIN_ENV_VARS_PREFIX = "ESLINT_PLUGIN_BOUNDARIES";
@@ -12,7 +12,9 @@ exports.DEPENDENCY_NODE_IMPORT = "import";
12
12
  exports.DEPENDENCY_NODE_DYNAMIC_IMPORT = "dynamic-import";
13
13
  exports.DEPENDENCY_NODE_EXPORT = "export";
14
14
  // Rule short names
15
+ /** @deprecated Use DEPENDENCIES instead */
15
16
  exports.ELEMENT_TYPES = "element-types";
17
+ exports.DEPENDENCIES = "dependencies";
16
18
  exports.ENTRY_POINT = "entry-point";
17
19
  exports.EXTERNAL = "external";
18
20
  exports.NO_IGNORED = "no-ignored";
@@ -23,7 +25,9 @@ exports.NO_UNKNOWN = "no-unknown";
23
25
  * Map of all rule short names, without the plugin prefix.
24
26
  */
25
27
  exports.RULE_SHORT_NAMES_MAP = {
28
+ /** @deprecated Use DEPENDENCIES instead */
26
29
  ELEMENT_TYPES: exports.ELEMENT_TYPES,
30
+ DEPENDENCIES: exports.DEPENDENCIES,
27
31
  ENTRY_POINT: exports.ENTRY_POINT,
28
32
  EXTERNAL: exports.EXTERNAL,
29
33
  NO_IGNORED: exports.NO_IGNORED,
@@ -31,7 +35,9 @@ exports.RULE_SHORT_NAMES_MAP = {
31
35
  NO_UNKNOWN_FILES: exports.NO_UNKNOWN_FILES,
32
36
  NO_UNKNOWN: exports.NO_UNKNOWN,
33
37
  };
38
+ /** @deprecated Use DEPENDENCIES_FULL instead */
34
39
  const ELEMENT_TYPES_FULL = `${exports.PLUGIN_NAME}/${exports.ELEMENT_TYPES}`;
40
+ const DEPENDENCIES_FULL = `${exports.PLUGIN_NAME}/${exports.DEPENDENCIES}`;
35
41
  const ENTRY_POINT_FULL = `${exports.PLUGIN_NAME}/${exports.ENTRY_POINT}`;
36
42
  const EXTERNAL_FULL = `${exports.PLUGIN_NAME}/${exports.EXTERNAL}`;
37
43
  const NO_IGNORED_FULL = `${exports.PLUGIN_NAME}/${exports.NO_IGNORED}`;
@@ -42,7 +48,9 @@ const NO_UNKNOWN_FULL = `${exports.PLUGIN_NAME}/${exports.NO_UNKNOWN}`;
42
48
  * Map of all rule names, including the default plugin prefix.
43
49
  */
44
50
  exports.RULE_NAMES_MAP = {
51
+ /** @deprecated Use DEPENDENCIES instead */
45
52
  ELEMENT_TYPES: ELEMENT_TYPES_FULL,
53
+ DEPENDENCIES: DEPENDENCIES_FULL,
46
54
  ENTRY_POINT: ENTRY_POINT_FULL,
47
55
  EXTERNAL: EXTERNAL_FULL,
48
56
  NO_IGNORED: NO_IGNORED_FULL,
@@ -60,10 +68,6 @@ exports.RULE_NAMES = [...Object.values(exports.RULE_NAMES_MAP)];
60
68
  exports.RULE_SHORT_NAMES = [
61
69
  ...Object.values(exports.RULE_SHORT_NAMES_MAP),
62
70
  ];
63
- /**
64
- * Main key used in rule definitions.
65
- */
66
- exports.FROM = "from";
67
71
  /**
68
72
  * Different types of dependency nodes supported by the plugin by default.
69
73
  * Each type corresponds to a common way of importing or requiring modules in JavaScript/TypeScript.
@@ -96,11 +100,15 @@ exports.SETTINGS = {
96
100
  ADDITIONAL_DEPENDENCY_NODES: `${exports.PLUGIN_NAME}/additional-dependency-nodes`,
97
101
  LEGACY_TEMPLATES: `${exports.PLUGIN_NAME}/legacy-templates`,
98
102
  CACHE: `${exports.PLUGIN_NAME}/cache`,
103
+ FLAG_AS_EXTERNAL: `${exports.PLUGIN_NAME}/flag-as-external`,
104
+ DEBUG_SETTING: `${exports.PLUGIN_NAME}/debug`,
99
105
  // env vars
100
106
  DEBUG: `${exports.PLUGIN_ENV_VARS_PREFIX}_DEBUG`,
101
107
  ENV_ROOT_PATH: `${exports.PLUGIN_ENV_VARS_PREFIX}_ROOT_PATH`,
102
108
  // rules
109
+ /** @deprecated Use RULE_DEPENDENCIES instead */
103
110
  RULE_ELEMENT_TYPES: `${exports.PLUGIN_NAME}/${exports.ELEMENT_TYPES}`,
111
+ RULE_DEPENDENCIES: `${exports.PLUGIN_NAME}/${exports.DEPENDENCIES}`,
104
112
  RULE_ENTRY_POINT: `${exports.PLUGIN_NAME}/${exports.ENTRY_POINT}`,
105
113
  RULE_EXTERNAL: `${exports.PLUGIN_NAME}/${exports.EXTERNAL}`,
106
114
  RULE_NO_IGNORED: `${exports.PLUGIN_NAME}/${exports.NO_IGNORED}`,
@@ -119,6 +127,7 @@ exports.SETTINGS = {
119
127
  {
120
128
  selector: "CallExpression[callee.name=require] > Literal",
121
129
  kind: "value",
130
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.REQUIRE,
122
131
  },
123
132
  ],
124
133
  [exports.DEPENDENCY_NODE_KEYS_MAP.IMPORT]: [
@@ -126,37 +135,47 @@ exports.SETTINGS = {
126
135
  {
127
136
  selector: "ImportDeclaration:not([importKind=type]) > Literal",
128
137
  kind: "value",
138
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.IMPORT,
129
139
  },
130
140
  // Note: detects "import type x from 'source'"
131
141
  {
132
142
  selector: "ImportDeclaration[importKind=type] > Literal",
133
143
  kind: "type",
144
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.IMPORT,
134
145
  },
135
146
  ],
136
147
  [exports.DEPENDENCY_NODE_KEYS_MAP.DYNAMIC_IMPORT]: [
137
148
  // Note: detects "import('source')"
138
- { selector: "ImportExpression > Literal", kind: "value" },
149
+ {
150
+ selector: "ImportExpression > Literal",
151
+ kind: "value",
152
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.DYNAMIC_IMPORT,
153
+ },
139
154
  ],
140
155
  [exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT]: [
141
156
  // Note: detects "export * from 'source'";
142
157
  {
143
158
  selector: "ExportAllDeclaration:not([exportKind=type]) > Literal",
144
159
  kind: "value",
160
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
145
161
  },
146
162
  // Note: detects "export type * from 'source'";
147
163
  {
148
164
  selector: "ExportAllDeclaration[exportKind=type] > Literal",
149
165
  kind: "type",
166
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
150
167
  },
151
168
  // Note: detects "export { x } from 'source'";
152
169
  {
153
170
  selector: "ExportNamedDeclaration:not([exportKind=type]) > Literal",
154
171
  kind: "value",
172
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
155
173
  },
156
174
  // Note: detects "export type { x } from 'source'";
157
175
  {
158
176
  selector: "ExportNamedDeclaration[exportKind=type] > Literal",
159
177
  kind: "type",
178
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
160
179
  },
161
180
  ],
162
181
  },
@@ -177,6 +196,8 @@ exports.SETTINGS_KEYS_MAP = {
177
196
  /** @deprecated Use import/resolver settings instead */
178
197
  ALIAS: exports.SETTINGS.ALIAS,
179
198
  CACHE: exports.SETTINGS.CACHE,
199
+ FLAG_AS_EXTERNAL: exports.SETTINGS.FLAG_AS_EXTERNAL,
200
+ DEBUG: exports.SETTINGS.DEBUG_SETTING,
180
201
  };
181
202
  /**
182
203
  * Default value for the legacy templates setting.
@@ -186,6 +207,10 @@ exports.LEGACY_TEMPLATES_DEFAULT = true;
186
207
  * Default value for the cache setting.
187
208
  */
188
209
  exports.CACHE_DEFAULT = true;
210
+ /**
211
+ * Default value for the check-config setting.
212
+ */
213
+ exports.CHECK_CONFIG_DEFAULT = false;
189
214
  exports.RULE_POLICY_ALLOW = "allow";
190
215
  exports.RULE_POLICY_DISALLOW = "disallow";
191
216
  /**
@@ -195,3 +220,4 @@ exports.RULE_POLICIES_MAP = {
195
220
  ALLOW: exports.RULE_POLICY_ALLOW,
196
221
  DISALLOW: exports.RULE_POLICY_DISALLOW,
197
222
  };
223
+ exports.FROM = "from";
@@ -16,12 +16,30 @@ export declare function isString(object: unknown): object is string;
16
16
  * @returns True if the object is a boolean, false otherwise.
17
17
  */
18
18
  export declare function isBoolean(object: unknown): object is boolean;
19
+ /**
20
+ * Determines if the provided object is null.
21
+ * @param object The object to check.
22
+ * @returns True if the object is null, false otherwise.
23
+ */
24
+ export declare function isNull(object: unknown): object is null;
19
25
  /**
20
26
  * Determines if the provided object is a non-null object (but not an array).
21
27
  * @param object The object to check.
22
28
  * @returns True if the object is a non-null object, false otherwise.
23
29
  */
24
30
  export declare function isObject(object: unknown): object is Record<string, unknown>;
31
+ /**
32
+ * Determines if the provided object is undefined.
33
+ * @param object The object to check.
34
+ * @returns True if the object is undefined, false otherwise.
35
+ */
36
+ export declare function isUndefined(object: unknown): object is undefined;
37
+ /**
38
+ * Determines if the provided object is null or undefined.
39
+ * @param object The object to check.
40
+ * @returns True if the object is null or undefined, false otherwise.
41
+ */
42
+ export declare function isNullish(object: unknown): object is null | undefined;
25
43
  /**
26
44
  * Returns the value as an array if it is an array, or null otherwise.
27
45
  * @param value The value to check.
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isArray = isArray;
4
4
  exports.isString = isString;
5
5
  exports.isBoolean = isBoolean;
6
+ exports.isNull = isNull;
6
7
  exports.isObject = isObject;
8
+ exports.isUndefined = isUndefined;
9
+ exports.isNullish = isNullish;
7
10
  exports.getArrayOrNull = getArrayOrNull;
8
11
  /**
9
12
  * Determines if the provided object is an array.
@@ -29,13 +32,37 @@ function isString(object) {
29
32
  function isBoolean(object) {
30
33
  return typeof object === "boolean";
31
34
  }
35
+ /**
36
+ * Determines if the provided object is null.
37
+ * @param object The object to check.
38
+ * @returns True if the object is null, false otherwise.
39
+ */
40
+ function isNull(object) {
41
+ return object === null;
42
+ }
32
43
  /**
33
44
  * Determines if the provided object is a non-null object (but not an array).
34
45
  * @param object The object to check.
35
46
  * @returns True if the object is a non-null object, false otherwise.
36
47
  */
37
48
  function isObject(object) {
38
- return typeof object === "object" && object !== null && !isArray(object);
49
+ return typeof object === "object" && !isNull(object) && !isArray(object);
50
+ }
51
+ /**
52
+ * Determines if the provided object is undefined.
53
+ * @param object The object to check.
54
+ * @returns True if the object is undefined, false otherwise.
55
+ */
56
+ function isUndefined(object) {
57
+ return object === undefined;
58
+ }
59
+ /**
60
+ * Determines if the provided object is null or undefined.
61
+ * @param object The object to check.
62
+ * @returns True if the object is null or undefined, false otherwise.
63
+ */
64
+ function isNullish(object) {
65
+ return isNull(object) || isUndefined(object);
39
66
  }
40
67
  /**
41
68
  * Returns the value as an array if it is an array, or null otherwise.
@@ -0,0 +1,2 @@
1
+ export * from "./TypeHelpers";
2
+ export * from "./Settings.types";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./TypeHelpers"), exports);
18
+ __exportStar(require("./Settings.types"), exports);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PluginBoundaries } from "./Settings";
1
+ import type { PluginBoundaries } from "./Shared";
2
2
  export * from "./Public";
3
3
  /**
4
4
  * Eslint plugin ensuring that architecture boundaries are respected by the elements in a project