@boundaries/eslint-plugin 5.4.0 → 6.0.0-beta.2

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 +4 -8
  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 +9 -7
  13. package/dist/Elements/Elements.js +12 -7
  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 -6
  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 -11
  47. package/dist/Settings/Validations.d.ts +11958 -43
  48. package/dist/Settings/Validations.js +783 -157
  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 +137 -37
  52. package/dist/{Settings → Shared}/Settings.types.js +30 -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 +16 -14
  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, FlagAsExternalOptions } 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.
@@ -117,9 +119,12 @@ export declare const SETTINGS: {
117
119
  readonly LEGACY_TEMPLATES: "boundaries/legacy-templates";
118
120
  readonly CACHE: "boundaries/cache";
119
121
  readonly FLAG_AS_EXTERNAL: "boundaries/flag-as-external";
122
+ readonly DEBUG_SETTING: "boundaries/debug";
120
123
  readonly DEBUG: "ESLINT_PLUGIN_BOUNDARIES_DEBUG";
121
124
  readonly ENV_ROOT_PATH: "ESLINT_PLUGIN_BOUNDARIES_ROOT_PATH";
125
+ /** @deprecated Use RULE_DEPENDENCIES instead */
122
126
  readonly RULE_ELEMENT_TYPES: "boundaries/element-types";
127
+ readonly RULE_DEPENDENCIES: "boundaries/dependencies";
123
128
  readonly RULE_ENTRY_POINT: "boundaries/entry-point";
124
129
  readonly RULE_EXTERNAL: "boundaries/external";
125
130
  readonly RULE_NO_IGNORED: "boundaries/no-ignored";
@@ -134,30 +139,38 @@ export declare const SETTINGS: {
134
139
  readonly require: readonly [{
135
140
  readonly selector: "CallExpression[callee.name=require] > Literal";
136
141
  readonly kind: "value";
142
+ readonly name: "require";
137
143
  }];
138
144
  readonly import: readonly [{
139
145
  readonly selector: "ImportDeclaration:not([importKind=type]) > Literal";
140
146
  readonly kind: "value";
147
+ readonly name: "import";
141
148
  }, {
142
149
  readonly selector: "ImportDeclaration[importKind=type] > Literal";
143
150
  readonly kind: "type";
151
+ readonly name: "import";
144
152
  }];
145
153
  readonly "dynamic-import": readonly [{
146
154
  readonly selector: "ImportExpression > Literal";
147
155
  readonly kind: "value";
156
+ readonly name: "dynamic-import";
148
157
  }];
149
158
  readonly export: readonly [{
150
159
  readonly selector: "ExportAllDeclaration:not([exportKind=type]) > Literal";
151
160
  readonly kind: "value";
161
+ readonly name: "export";
152
162
  }, {
153
163
  readonly selector: "ExportAllDeclaration[exportKind=type] > Literal";
154
164
  readonly kind: "type";
165
+ readonly name: "export";
155
166
  }, {
156
167
  readonly selector: "ExportNamedDeclaration:not([exportKind=type]) > Literal";
157
168
  readonly kind: "value";
169
+ readonly name: "export";
158
170
  }, {
159
171
  readonly selector: "ExportNamedDeclaration[exportKind=type] > Literal";
160
172
  readonly kind: "type";
173
+ readonly name: "export";
161
174
  }];
162
175
  };
163
176
  };
@@ -178,6 +191,7 @@ export declare const SETTINGS_KEYS_MAP: {
178
191
  readonly ALIAS: "boundaries/alias";
179
192
  readonly CACHE: "boundaries/cache";
180
193
  readonly FLAG_AS_EXTERNAL: "boundaries/flag-as-external";
194
+ readonly DEBUG: "boundaries/debug";
181
195
  };
182
196
  /**
183
197
  * Default value for the legacy templates setting.
@@ -187,6 +201,10 @@ export declare const LEGACY_TEMPLATES_DEFAULT: true;
187
201
  * Default value for the cache setting.
188
202
  */
189
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;
190
208
  /**
191
209
  * Valid keys for the plugin settings.
192
210
  */
@@ -212,6 +230,50 @@ export type RootPathSetting = string;
212
230
  * @deprecated Use "import/resolver" settings instead
213
231
  */
214
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
+ };
215
277
  /**
216
278
  * Settings for the eslint-plugin-boundaries plugin.
217
279
  */
@@ -263,6 +325,8 @@ export type Settings = {
263
325
  [SETTINGS_KEYS_MAP.CACHE]?: boolean;
264
326
  /** Configuration for categorizing dependencies as external or local */
265
327
  [SETTINGS_KEYS_MAP.FLAG_AS_EXTERNAL]?: FlagAsExternalOptions;
328
+ /** Debug configuration for tracing files and dependencies */
329
+ [SETTINGS_KEYS_MAP.DEBUG]?: DebugSetting;
266
330
  };
267
331
  /**
268
332
  * Normalized settings for the eslint-plugin-boundaries plugin.
@@ -287,6 +351,8 @@ export type SettingsNormalized = {
287
351
  cache: boolean;
288
352
  /** Configuration for categorizing dependencies as external or local */
289
353
  flagAsExternal: FlagAsExternalOptions;
354
+ /** Debug configuration */
355
+ debug: DebugSettingNormalized;
290
356
  };
291
357
  /**
292
358
  * Eslint boundaries plugin rules.
@@ -295,8 +361,9 @@ export type SettingsNormalized = {
295
361
  * @template PluginName - The name of the plugin, defaults to "boundaries". It defines the prefix for the rule names.
296
362
  */
297
363
  export type Rules<PluginName extends string = typeof PLUGIN_NAME> = {
298
- [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>;
299
365
  };
366
+ export type FlagAsExternalBooleanOptionKey = "unresolvableAlias" | "inNodeModules" | "outsideRootPath";
300
367
  /**
301
368
  * ESLint configuration with optional settings and rules specific to the boundaries plugin.
302
369
  */
@@ -355,49 +422,49 @@ export type RuleBaseOptions = {
355
422
  /** Custom message for all rule violations. It can be overridden at the rule level. */
356
423
  message?: string;
357
424
  };
358
- export type RuleReport = {
359
- message?: string;
360
- isDefault?: boolean;
361
- importKind?: DependencyKind;
362
- disallow?: ElementsSelector;
363
- element: ElementsSelector;
364
- index: number;
365
- };
366
- export type RuleResultReport = {
367
- path: string | null;
368
- specifiers?: string[];
369
- };
370
- export type RuleResult = {
371
- result: boolean;
372
- ruleReport: RuleReport | null;
373
- report: RuleResultReport | null;
374
- };
375
- export type RuleMatcherElementsCapturedValues = {
376
- from: CapturedValues;
377
- target: CapturedValues;
378
- };
425
+ export type RulePolicyEntry = SimpleElementSelectorByType | BaseElementSelectorWithOptions | DependencySelector;
379
426
  /**
380
427
  * Rule that defines allowed or disallowed dependencies between different element types.
381
428
  */
382
- export type ElementTypesRule = {
429
+ export type DependenciesRule = {
430
+ dependency?: DependencyDataSelector;
383
431
  /** Selectors of the source elements that the rule applies to (the elements importing) */
384
432
  from?: ElementsSelector;
385
433
  /** Selectors of the target elements that are disallowed to be imported */
386
434
  to?: ElementsSelector;
387
435
  /** Selectors of the elements that are disallowed to be imported */
388
- disallow?: ElementsSelector;
436
+ disallow?: RulePolicyEntry | RulePolicyEntry[];
389
437
  /** Selectors of the elements that are allowed to be imported */
390
- allow?: ElementsSelector;
438
+ allow?: RulePolicyEntry | RulePolicyEntry[];
391
439
  /** Kind of import that the rule applies to (e.g., "type", "value") */
392
440
  importKind?: DependencyKind;
393
441
  /** Custom message for rule violations */
394
442
  message?: string;
395
443
  };
396
444
  /**
397
- * 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
398
447
  */
399
- 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"> & {
400
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 */
401
468
  rules?: ElementTypesRule[];
402
469
  };
403
470
  /**
@@ -422,6 +489,38 @@ export type EntryPointRuleOptions = Omit<RuleBaseOptions, "rules"> & {
422
489
  /** Specific rules for defining entry points between elements */
423
490
  rules?: EntryPointRule[];
424
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[];
425
524
  /**
426
525
  * Rule that defines allowed or disallowed external library imports for specific element types.
427
526
  */
@@ -455,10 +554,11 @@ export type NoPrivateOptions = {
455
554
  /** Custom message for rule violations */
456
555
  message?: string;
457
556
  };
458
- export type RuleOptionsWithRules = ExternalRuleOptions | EntryPointRuleOptions | ElementTypesRuleOptions;
557
+ export type RuleOptionsWithRules = ExternalRuleOptions | EntryPointRuleOptions | DependenciesRuleOptions;
459
558
  export type RuleOptions = RuleOptionsWithRules | NoPrivateOptions;
460
- export type RuleOptionsRules = ExternalRule | EntryPointRule | ElementTypesRule;
461
- 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";
462
562
  export type ValidateRulesOptions = {
463
563
  mainKey?: RuleMainKey;
464
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.
@@ -97,11 +101,14 @@ exports.SETTINGS = {
97
101
  LEGACY_TEMPLATES: `${exports.PLUGIN_NAME}/legacy-templates`,
98
102
  CACHE: `${exports.PLUGIN_NAME}/cache`,
99
103
  FLAG_AS_EXTERNAL: `${exports.PLUGIN_NAME}/flag-as-external`,
104
+ DEBUG_SETTING: `${exports.PLUGIN_NAME}/debug`,
100
105
  // env vars
101
106
  DEBUG: `${exports.PLUGIN_ENV_VARS_PREFIX}_DEBUG`,
102
107
  ENV_ROOT_PATH: `${exports.PLUGIN_ENV_VARS_PREFIX}_ROOT_PATH`,
103
108
  // rules
109
+ /** @deprecated Use RULE_DEPENDENCIES instead */
104
110
  RULE_ELEMENT_TYPES: `${exports.PLUGIN_NAME}/${exports.ELEMENT_TYPES}`,
111
+ RULE_DEPENDENCIES: `${exports.PLUGIN_NAME}/${exports.DEPENDENCIES}`,
105
112
  RULE_ENTRY_POINT: `${exports.PLUGIN_NAME}/${exports.ENTRY_POINT}`,
106
113
  RULE_EXTERNAL: `${exports.PLUGIN_NAME}/${exports.EXTERNAL}`,
107
114
  RULE_NO_IGNORED: `${exports.PLUGIN_NAME}/${exports.NO_IGNORED}`,
@@ -120,6 +127,7 @@ exports.SETTINGS = {
120
127
  {
121
128
  selector: "CallExpression[callee.name=require] > Literal",
122
129
  kind: "value",
130
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.REQUIRE,
123
131
  },
124
132
  ],
125
133
  [exports.DEPENDENCY_NODE_KEYS_MAP.IMPORT]: [
@@ -127,37 +135,47 @@ exports.SETTINGS = {
127
135
  {
128
136
  selector: "ImportDeclaration:not([importKind=type]) > Literal",
129
137
  kind: "value",
138
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.IMPORT,
130
139
  },
131
140
  // Note: detects "import type x from 'source'"
132
141
  {
133
142
  selector: "ImportDeclaration[importKind=type] > Literal",
134
143
  kind: "type",
144
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.IMPORT,
135
145
  },
136
146
  ],
137
147
  [exports.DEPENDENCY_NODE_KEYS_MAP.DYNAMIC_IMPORT]: [
138
148
  // Note: detects "import('source')"
139
- { selector: "ImportExpression > Literal", kind: "value" },
149
+ {
150
+ selector: "ImportExpression > Literal",
151
+ kind: "value",
152
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.DYNAMIC_IMPORT,
153
+ },
140
154
  ],
141
155
  [exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT]: [
142
156
  // Note: detects "export * from 'source'";
143
157
  {
144
158
  selector: "ExportAllDeclaration:not([exportKind=type]) > Literal",
145
159
  kind: "value",
160
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
146
161
  },
147
162
  // Note: detects "export type * from 'source'";
148
163
  {
149
164
  selector: "ExportAllDeclaration[exportKind=type] > Literal",
150
165
  kind: "type",
166
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
151
167
  },
152
168
  // Note: detects "export { x } from 'source'";
153
169
  {
154
170
  selector: "ExportNamedDeclaration:not([exportKind=type]) > Literal",
155
171
  kind: "value",
172
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
156
173
  },
157
174
  // Note: detects "export type { x } from 'source'";
158
175
  {
159
176
  selector: "ExportNamedDeclaration[exportKind=type] > Literal",
160
177
  kind: "type",
178
+ name: exports.DEPENDENCY_NODE_KEYS_MAP.EXPORT,
161
179
  },
162
180
  ],
163
181
  },
@@ -179,6 +197,7 @@ exports.SETTINGS_KEYS_MAP = {
179
197
  ALIAS: exports.SETTINGS.ALIAS,
180
198
  CACHE: exports.SETTINGS.CACHE,
181
199
  FLAG_AS_EXTERNAL: exports.SETTINGS.FLAG_AS_EXTERNAL,
200
+ DEBUG: exports.SETTINGS.DEBUG_SETTING,
182
201
  };
183
202
  /**
184
203
  * Default value for the legacy templates setting.
@@ -188,6 +207,10 @@ exports.LEGACY_TEMPLATES_DEFAULT = true;
188
207
  * Default value for the cache setting.
189
208
  */
190
209
  exports.CACHE_DEFAULT = true;
210
+ /**
211
+ * Default value for the check-config setting.
212
+ */
213
+ exports.CHECK_CONFIG_DEFAULT = false;
191
214
  exports.RULE_POLICY_ALLOW = "allow";
192
215
  exports.RULE_POLICY_DISALLOW = "disallow";
193
216
  /**
@@ -197,3 +220,4 @@ exports.RULE_POLICIES_MAP = {
197
220
  ALLOW: exports.RULE_POLICY_ALLOW,
198
221
  DISALLOW: exports.RULE_POLICY_DISALLOW,
199
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