@nielspeter/eess-ts 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +364 -0
- package/dist/builders/call-rule-builder.d.ts +199 -0
- package/dist/builders/call-rule-builder.d.ts.map +1 -0
- package/dist/builders/call-rule-builder.js +254 -0
- package/dist/builders/call-rule-builder.js.map +1 -0
- package/dist/builders/class-rule-builder.d.ts +136 -0
- package/dist/builders/class-rule-builder.d.ts.map +1 -0
- package/dist/builders/class-rule-builder.js +253 -0
- package/dist/builders/class-rule-builder.js.map +1 -0
- package/dist/builders/cross-layer-builder.d.ts +96 -0
- package/dist/builders/cross-layer-builder.d.ts.map +1 -0
- package/dist/builders/cross-layer-builder.js +172 -0
- package/dist/builders/cross-layer-builder.js.map +1 -0
- package/dist/builders/function-rule-builder.d.ts +198 -0
- package/dist/builders/function-rule-builder.d.ts.map +1 -0
- package/dist/builders/function-rule-builder.js +287 -0
- package/dist/builders/function-rule-builder.js.map +1 -0
- package/dist/builders/jsx-rule-builder.d.ts +113 -0
- package/dist/builders/jsx-rule-builder.d.ts.map +1 -0
- package/dist/builders/jsx-rule-builder.js +150 -0
- package/dist/builders/jsx-rule-builder.js.map +1 -0
- package/dist/builders/module-rule-builder.d.ts +159 -0
- package/dist/builders/module-rule-builder.d.ts.map +1 -0
- package/dist/builders/module-rule-builder.js +237 -0
- package/dist/builders/module-rule-builder.js.map +1 -0
- package/dist/builders/scoped-function-rule-builder.d.ts +21 -0
- package/dist/builders/scoped-function-rule-builder.d.ts.map +1 -0
- package/dist/builders/scoped-function-rule-builder.js +26 -0
- package/dist/builders/scoped-function-rule-builder.js.map +1 -0
- package/dist/builders/slice-rule-builder.d.ts +85 -0
- package/dist/builders/slice-rule-builder.d.ts.map +1 -0
- package/dist/builders/slice-rule-builder.js +134 -0
- package/dist/builders/slice-rule-builder.js.map +1 -0
- package/dist/builders/type-rule-builder.d.ts +103 -0
- package/dist/builders/type-rule-builder.d.ts.map +1 -0
- package/dist/builders/type-rule-builder.js +170 -0
- package/dist/builders/type-rule-builder.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +4 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/baseline.d.ts +11 -0
- package/dist/cli/commands/baseline.d.ts.map +1 -0
- package/dist/cli/commands/baseline.js +16 -0
- package/dist/cli/commands/baseline.js.map +1 -0
- package/dist/cli/commands/check.d.ts +21 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +94 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/explain.d.ts +9 -0
- package/dist/cli/commands/explain.d.ts.map +1 -0
- package/dist/cli/commands/explain.js +49 -0
- package/dist/cli/commands/explain.js.map +1 -0
- package/dist/cli/config.d.ts +31 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +20 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +168 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/load-rules.d.ts +20 -0
- package/dist/cli/load-rules.d.ts.map +1 -0
- package/dist/cli/load-rules.js +97 -0
- package/dist/cli/load-rules.js.map +1 -0
- package/dist/cli/resolve-config.d.ts +11 -0
- package/dist/cli/resolve-config.d.ts.map +1 -0
- package/dist/cli/resolve-config.js +61 -0
- package/dist/cli/resolve-config.js.map +1 -0
- package/dist/cli/watch.d.ts +49 -0
- package/dist/cli/watch.d.ts.map +1 -0
- package/dist/cli/watch.js +138 -0
- package/dist/cli/watch.js.map +1 -0
- package/dist/conditions/body-analysis-function.d.ts +23 -0
- package/dist/conditions/body-analysis-function.d.ts.map +1 -0
- package/dist/conditions/body-analysis-function.js +103 -0
- package/dist/conditions/body-analysis-function.js.map +1 -0
- package/dist/conditions/body-analysis-module.d.ts +27 -0
- package/dist/conditions/body-analysis-module.d.ts.map +1 -0
- package/dist/conditions/body-analysis-module.js +99 -0
- package/dist/conditions/body-analysis-module.js.map +1 -0
- package/dist/conditions/body-analysis.d.ts +34 -0
- package/dist/conditions/body-analysis.d.ts.map +1 -0
- package/dist/conditions/body-analysis.js +95 -0
- package/dist/conditions/body-analysis.js.map +1 -0
- package/dist/conditions/call.d.ts +62 -0
- package/dist/conditions/call.d.ts.map +1 -0
- package/dist/conditions/call.js +267 -0
- package/dist/conditions/call.js.map +1 -0
- package/dist/conditions/catch-analysis.d.ts +31 -0
- package/dist/conditions/catch-analysis.d.ts.map +1 -0
- package/dist/conditions/catch-analysis.js +78 -0
- package/dist/conditions/catch-analysis.js.map +1 -0
- package/dist/conditions/class.d.ts +33 -0
- package/dist/conditions/class.d.ts.map +1 -0
- package/dist/conditions/class.js +110 -0
- package/dist/conditions/class.js.map +1 -0
- package/dist/conditions/cross-layer.d.ts +28 -0
- package/dist/conditions/cross-layer.d.ts.map +1 -0
- package/dist/conditions/cross-layer.js +105 -0
- package/dist/conditions/cross-layer.js.map +1 -0
- package/dist/conditions/dependency.d.ts +73 -0
- package/dist/conditions/dependency.d.ts.map +1 -0
- package/dist/conditions/dependency.js +177 -0
- package/dist/conditions/dependency.js.map +1 -0
- package/dist/conditions/exports.d.ts +33 -0
- package/dist/conditions/exports.d.ts.map +1 -0
- package/dist/conditions/exports.js +101 -0
- package/dist/conditions/exports.js.map +1 -0
- package/dist/conditions/function.d.ts +79 -0
- package/dist/conditions/function.d.ts.map +1 -0
- package/dist/conditions/function.js +167 -0
- package/dist/conditions/function.js.map +1 -0
- package/dist/conditions/helpers.d.ts +14 -0
- package/dist/conditions/helpers.d.ts.map +1 -0
- package/dist/conditions/helpers.js +26 -0
- package/dist/conditions/helpers.js.map +1 -0
- package/dist/conditions/jsx.d.ts +40 -0
- package/dist/conditions/jsx.d.ts.map +1 -0
- package/dist/conditions/jsx.js +133 -0
- package/dist/conditions/jsx.js.map +1 -0
- package/dist/conditions/members.d.ts +74 -0
- package/dist/conditions/members.d.ts.map +1 -0
- package/dist/conditions/members.js +224 -0
- package/dist/conditions/members.js.map +1 -0
- package/dist/conditions/pattern.d.ts +20 -0
- package/dist/conditions/pattern.d.ts.map +1 -0
- package/dist/conditions/pattern.js +108 -0
- package/dist/conditions/pattern.js.map +1 -0
- package/dist/conditions/reverse-dependency.d.ts +28 -0
- package/dist/conditions/reverse-dependency.d.ts.map +1 -0
- package/dist/conditions/reverse-dependency.js +275 -0
- package/dist/conditions/reverse-dependency.js.map +1 -0
- package/dist/conditions/slice.d.ts +49 -0
- package/dist/conditions/slice.d.ts.map +1 -0
- package/dist/conditions/slice.js +153 -0
- package/dist/conditions/slice.js.map +1 -0
- package/dist/conditions/structural.d.ts +58 -0
- package/dist/conditions/structural.d.ts.map +1 -0
- package/dist/conditions/structural.js +102 -0
- package/dist/conditions/structural.js.map +1 -0
- package/dist/conditions/type-level.d.ts +29 -0
- package/dist/conditions/type-level.d.ts.map +1 -0
- package/dist/conditions/type-level.js +48 -0
- package/dist/conditions/type-level.js.map +1 -0
- package/dist/core/import-options.d.ts +32 -0
- package/dist/core/import-options.d.ts.map +1 -0
- package/dist/core/import-options.js +29 -0
- package/dist/core/import-options.js.map +1 -0
- package/dist/core/module-dependencies.d.ts +28 -0
- package/dist/core/module-dependencies.d.ts.map +1 -0
- package/dist/core/module-dependencies.js +35 -0
- package/dist/core/module-dependencies.js.map +1 -0
- package/dist/core/pair-condition.d.ts +10 -0
- package/dist/core/pair-condition.d.ts.map +1 -0
- package/dist/core/pair-condition.js +2 -0
- package/dist/core/pair-condition.js.map +1 -0
- package/dist/core/project.d.ts +68 -0
- package/dist/core/project.d.ts.map +1 -0
- package/dist/core/project.js +127 -0
- package/dist/core/project.js.map +1 -0
- package/dist/core/type-matcher.d.ts +10 -0
- package/dist/core/type-matcher.d.ts.map +1 -0
- package/dist/core/type-matcher.js +2 -0
- package/dist/core/type-matcher.js.map +1 -0
- package/dist/core/violation.d.ts +38 -0
- package/dist/core/violation.d.ts.map +1 -0
- package/dist/core/violation.js +130 -0
- package/dist/core/violation.js.map +1 -0
- package/dist/graphql/index.d.ts +76 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +108 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/resolver-rule-builder.d.ts +75 -0
- package/dist/graphql/resolver-rule-builder.d.ts.map +1 -0
- package/dist/graphql/resolver-rule-builder.js +146 -0
- package/dist/graphql/resolver-rule-builder.js.map +1 -0
- package/dist/graphql/schema-conditions.d.ts +31 -0
- package/dist/graphql/schema-conditions.d.ts.map +1 -0
- package/dist/graphql/schema-conditions.js +119 -0
- package/dist/graphql/schema-conditions.js.map +1 -0
- package/dist/graphql/schema-loader.d.ts +75 -0
- package/dist/graphql/schema-loader.d.ts.map +1 -0
- package/dist/graphql/schema-loader.js +113 -0
- package/dist/graphql/schema-loader.js.map +1 -0
- package/dist/graphql/schema-predicates.d.ts +42 -0
- package/dist/graphql/schema-predicates.d.ts.map +1 -0
- package/dist/graphql/schema-predicates.js +74 -0
- package/dist/graphql/schema-predicates.js.map +1 -0
- package/dist/graphql/schema-rule-builder.d.ts +74 -0
- package/dist/graphql/schema-rule-builder.d.ts.map +1 -0
- package/dist/graphql/schema-rule-builder.js +188 -0
- package/dist/graphql/schema-rule-builder.js.map +1 -0
- package/dist/helpers/body-traversal.d.ts +58 -0
- package/dist/helpers/body-traversal.d.ts.map +1 -0
- package/dist/helpers/body-traversal.js +180 -0
- package/dist/helpers/body-traversal.js.map +1 -0
- package/dist/helpers/callback-extractor.d.ts +28 -0
- package/dist/helpers/callback-extractor.d.ts.map +1 -0
- package/dist/helpers/callback-extractor.js +159 -0
- package/dist/helpers/callback-extractor.js.map +1 -0
- package/dist/helpers/complexity.d.ts +26 -0
- package/dist/helpers/complexity.d.ts.map +1 -0
- package/dist/helpers/complexity.js +64 -0
- package/dist/helpers/complexity.js.map +1 -0
- package/dist/helpers/matchers.d.ts +206 -0
- package/dist/helpers/matchers.d.ts.map +1 -0
- package/dist/helpers/matchers.js +470 -0
- package/dist/helpers/matchers.js.map +1 -0
- package/dist/helpers/pattern.d.ts +37 -0
- package/dist/helpers/pattern.d.ts.map +1 -0
- package/dist/helpers/pattern.js +22 -0
- package/dist/helpers/pattern.js.map +1 -0
- package/dist/helpers/slice-graph.d.ts +32 -0
- package/dist/helpers/slice-graph.d.ts.map +1 -0
- package/dist/helpers/slice-graph.js +89 -0
- package/dist/helpers/slice-graph.js.map +1 -0
- package/dist/helpers/tarjan.d.ts +21 -0
- package/dist/helpers/tarjan.d.ts.map +1 -0
- package/dist/helpers/tarjan.js +71 -0
- package/dist/helpers/tarjan.js.map +1 -0
- package/dist/helpers/type-matchers.d.ts +67 -0
- package/dist/helpers/type-matchers.d.ts.map +1 -0
- package/dist/helpers/type-matchers.js +108 -0
- package/dist/helpers/type-matchers.js.map +1 -0
- package/dist/helpers/within.d.ts +41 -0
- package/dist/helpers/within.d.ts.map +1 -0
- package/dist/helpers/within.js +32 -0
- package/dist/helpers/within.js.map +1 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/dist/models/arch-call.d.ts +83 -0
- package/dist/models/arch-call.d.ts.map +1 -0
- package/dist/models/arch-call.js +90 -0
- package/dist/models/arch-call.js.map +1 -0
- package/dist/models/arch-function.d.ts +76 -0
- package/dist/models/arch-function.d.ts.map +1 -0
- package/dist/models/arch-function.js +122 -0
- package/dist/models/arch-function.js.map +1 -0
- package/dist/models/arch-jsx-element.d.ts +75 -0
- package/dist/models/arch-jsx-element.d.ts.map +1 -0
- package/dist/models/arch-jsx-element.js +231 -0
- package/dist/models/arch-jsx-element.js.map +1 -0
- package/dist/models/cross-layer.d.ts +15 -0
- package/dist/models/cross-layer.d.ts.map +1 -0
- package/dist/models/cross-layer.js +2 -0
- package/dist/models/cross-layer.js.map +1 -0
- package/dist/models/slice.d.ts +60 -0
- package/dist/models/slice.d.ts.map +1 -0
- package/dist/models/slice.js +89 -0
- package/dist/models/slice.js.map +1 -0
- package/dist/predicates/call.d.ts +49 -0
- package/dist/predicates/call.d.ts.map +1 -0
- package/dist/predicates/call.js +115 -0
- package/dist/predicates/call.js.map +1 -0
- package/dist/predicates/class.d.ts +42 -0
- package/dist/predicates/class.d.ts.map +1 -0
- package/dist/predicates/class.js +83 -0
- package/dist/predicates/class.js.map +1 -0
- package/dist/predicates/function.d.ts +81 -0
- package/dist/predicates/function.d.ts.map +1 -0
- package/dist/predicates/function.js +157 -0
- package/dist/predicates/function.js.map +1 -0
- package/dist/predicates/identity.d.ts +55 -0
- package/dist/predicates/identity.d.ts.map +1 -0
- package/dist/predicates/identity.js +96 -0
- package/dist/predicates/identity.js.map +1 -0
- package/dist/predicates/index.d.ts +4 -0
- package/dist/predicates/index.d.ts.map +1 -0
- package/dist/predicates/index.js +3 -0
- package/dist/predicates/index.js.map +1 -0
- package/dist/predicates/jsx.d.ts +41 -0
- package/dist/predicates/jsx.d.ts.map +1 -0
- package/dist/predicates/jsx.js +84 -0
- package/dist/predicates/jsx.js.map +1 -0
- package/dist/predicates/metrics.d.ts +30 -0
- package/dist/predicates/metrics.d.ts.map +1 -0
- package/dist/predicates/metrics.js +65 -0
- package/dist/predicates/metrics.js.map +1 -0
- package/dist/predicates/module.d.ts +44 -0
- package/dist/predicates/module.d.ts.map +1 -0
- package/dist/predicates/module.js +70 -0
- package/dist/predicates/module.js.map +1 -0
- package/dist/predicates/type.d.ts +48 -0
- package/dist/predicates/type.d.ts.map +1 -0
- package/dist/predicates/type.js +107 -0
- package/dist/predicates/type.js.map +1 -0
- package/dist/presets/boundaries.d.ts +19 -0
- package/dist/presets/boundaries.d.ts.map +1 -0
- package/dist/presets/boundaries.js +93 -0
- package/dist/presets/boundaries.js.map +1 -0
- package/dist/presets/data-layer.d.ts +20 -0
- package/dist/presets/data-layer.d.ts.map +1 -0
- package/dist/presets/data-layer.js +30 -0
- package/dist/presets/data-layer.js.map +1 -0
- package/dist/presets/index.d.ts +9 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +5 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/layered.d.ts +21 -0
- package/dist/presets/layered.d.ts.map +1 -0
- package/dist/presets/layered.js +103 -0
- package/dist/presets/layered.js.map +1 -0
- package/dist/presets/shared.d.ts +3 -0
- package/dist/presets/shared.d.ts.map +1 -0
- package/dist/presets/shared.js +5 -0
- package/dist/presets/shared.js.map +1 -0
- package/dist/rules/architecture.d.ts +10 -0
- package/dist/rules/architecture.d.ts.map +1 -0
- package/dist/rules/architecture.js +14 -0
- package/dist/rules/architecture.js.map +1 -0
- package/dist/rules/code-quality.d.ts +55 -0
- package/dist/rules/code-quality.d.ts.map +1 -0
- package/dist/rules/code-quality.js +116 -0
- package/dist/rules/code-quality.js.map +1 -0
- package/dist/rules/dependencies.d.ts +32 -0
- package/dist/rules/dependencies.d.ts.map +1 -0
- package/dist/rules/dependencies.js +37 -0
- package/dist/rules/dependencies.js.map +1 -0
- package/dist/rules/errors.d.ts +31 -0
- package/dist/rules/errors.d.ts.map +1 -0
- package/dist/rules/errors.js +97 -0
- package/dist/rules/errors.js.map +1 -0
- package/dist/rules/hygiene.d.ts +54 -0
- package/dist/rules/hygiene.d.ts.map +1 -0
- package/dist/rules/hygiene.js +62 -0
- package/dist/rules/hygiene.js.map +1 -0
- package/dist/rules/metrics-function.d.ts +45 -0
- package/dist/rules/metrics-function.d.ts.map +1 -0
- package/dist/rules/metrics-function.js +87 -0
- package/dist/rules/metrics-function.js.map +1 -0
- package/dist/rules/metrics.d.ts +64 -0
- package/dist/rules/metrics.d.ts.map +1 -0
- package/dist/rules/metrics.js +157 -0
- package/dist/rules/metrics.js.map +1 -0
- package/dist/rules/naming.d.ts +24 -0
- package/dist/rules/naming.d.ts.map +1 -0
- package/dist/rules/naming.js +51 -0
- package/dist/rules/naming.js.map +1 -0
- package/dist/rules/security.d.ts +59 -0
- package/dist/rules/security.d.ts.map +1 -0
- package/dist/rules/security.js +92 -0
- package/dist/rules/security.js.map +1 -0
- package/dist/rules/typescript.d.ts +73 -0
- package/dist/rules/typescript.d.ts.map +1 -0
- package/dist/rules/typescript.js +105 -0
- package/dist/rules/typescript.js.map +1 -0
- package/dist/smells/duplicate-bodies.d.ts +24 -0
- package/dist/smells/duplicate-bodies.d.ts.map +1 -0
- package/dist/smells/duplicate-bodies.js +131 -0
- package/dist/smells/duplicate-bodies.js.map +1 -0
- package/dist/smells/fingerprint.d.ts +27 -0
- package/dist/smells/fingerprint.d.ts.map +1 -0
- package/dist/smells/fingerprint.js +50 -0
- package/dist/smells/fingerprint.js.map +1 -0
- package/dist/smells/inconsistent-siblings.d.ts +21 -0
- package/dist/smells/inconsistent-siblings.d.ts.map +1 -0
- package/dist/smells/inconsistent-siblings.js +135 -0
- package/dist/smells/inconsistent-siblings.js.map +1 -0
- package/dist/smells/index.d.ts +12 -0
- package/dist/smells/index.d.ts.map +1 -0
- package/dist/smells/index.js +15 -0
- package/dist/smells/index.js.map +1 -0
- package/dist/smells/smell-builder.d.ts +37 -0
- package/dist/smells/smell-builder.d.ts.map +1 -0
- package/dist/smells/smell-builder.js +51 -0
- package/dist/smells/smell-builder.js.map +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { SourceFile } from 'ts-morph';
|
|
2
|
+
import { RuleBuilder } from '@nielspeter/eess';
|
|
3
|
+
import type { ArchProject } from '../core/project.js';
|
|
4
|
+
import type { ImportOptions } from '../core/import-options.js';
|
|
5
|
+
import type { ExpressionMatcher } from '../helpers/matchers.js';
|
|
6
|
+
import type { ModuleBodyOptions } from '../helpers/body-traversal.js';
|
|
7
|
+
/**
|
|
8
|
+
* Rule builder for module-level (SourceFile) architecture rules.
|
|
9
|
+
*
|
|
10
|
+
* Each .ts file in the project is treated as a module. Predicates filter
|
|
11
|
+
* which modules to check, conditions assert constraints on their imports.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* modules(project)
|
|
15
|
+
* .that().resideInFolder('** /domain/** ')
|
|
16
|
+
* .should().onlyImportFrom('** /domain/** ', '** /shared/** ')
|
|
17
|
+
* .because('domain must not depend on infrastructure')
|
|
18
|
+
* .check()
|
|
19
|
+
*/
|
|
20
|
+
export declare class ModuleRuleBuilder extends RuleBuilder<SourceFile, ArchProject> {
|
|
21
|
+
protected getElements(): SourceFile[];
|
|
22
|
+
/**
|
|
23
|
+
* Filter modules whose file name matches the given regex.
|
|
24
|
+
* The regex is tested against the base file name (e.g., "user-service.ts").
|
|
25
|
+
*/
|
|
26
|
+
haveNameMatching(pattern: RegExp | string): this;
|
|
27
|
+
/**
|
|
28
|
+
* After `.that()`: filter modules that reside in a file matching the given glob.
|
|
29
|
+
* After `.should()`: assert modules reside in a file matching the given glob.
|
|
30
|
+
* Matched against the absolute file path.
|
|
31
|
+
*/
|
|
32
|
+
resideInFile(glob: string): this;
|
|
33
|
+
/**
|
|
34
|
+
* After `.that()`: filter modules that reside in a folder matching the given glob.
|
|
35
|
+
* After `.should()`: assert modules reside in a folder matching the given glob.
|
|
36
|
+
* Matched against the directory portion of the absolute file path.
|
|
37
|
+
*/
|
|
38
|
+
resideInFolder(glob: string): this;
|
|
39
|
+
/**
|
|
40
|
+
* Filter modules that import from a path matching any of the given globs.
|
|
41
|
+
* Pass `{ ignoreTypeImports: true }` to exclude type-only imports.
|
|
42
|
+
*/
|
|
43
|
+
importFrom(...globs: string[]): this;
|
|
44
|
+
/**
|
|
45
|
+
* Filter modules that import from a path matching any of the given globs,
|
|
46
|
+
* with options to control type-import handling.
|
|
47
|
+
*/
|
|
48
|
+
importFromWithOptions(globs: string[], options: ImportOptions): this;
|
|
49
|
+
/**
|
|
50
|
+
* After `.that()`: filter modules that do NOT import from matching globs.
|
|
51
|
+
* After `.should()`: assert that no import resolves to a matching glob.
|
|
52
|
+
*/
|
|
53
|
+
notImportFrom(...globs: string[]): this;
|
|
54
|
+
/**
|
|
55
|
+
* After `.that()`: filter modules that do NOT import from matching globs.
|
|
56
|
+
* After `.should()`: assert that no import resolves to a matching glob.
|
|
57
|
+
* With options to control type-import handling.
|
|
58
|
+
*/
|
|
59
|
+
notImportFromWithOptions(globs: string[], options: ImportOptions): this;
|
|
60
|
+
/**
|
|
61
|
+
* Filter modules that export a symbol with the given name.
|
|
62
|
+
*/
|
|
63
|
+
exportSymbolNamed(name: string): this;
|
|
64
|
+
/**
|
|
65
|
+
* Filter modules whose file path matches the given glob.
|
|
66
|
+
*/
|
|
67
|
+
havePathMatching(glob: string): this;
|
|
68
|
+
/**
|
|
69
|
+
* Every import must resolve to a path matching at least one of the globs.
|
|
70
|
+
* Pass `{ ignoreTypeImports: true }` to exclude type-only imports.
|
|
71
|
+
*/
|
|
72
|
+
onlyImportFrom(...globs: string[]): this;
|
|
73
|
+
/**
|
|
74
|
+
* Every import must resolve to a path matching at least one of the globs,
|
|
75
|
+
* with options to control type-import handling.
|
|
76
|
+
*/
|
|
77
|
+
onlyImportFromWithOptions(globs: string[], options: ImportOptions): this;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use `notImportFrom()` after `.should()` instead — it now dispatches
|
|
80
|
+
* as a condition automatically in the condition phase.
|
|
81
|
+
*/
|
|
82
|
+
notImportFromCondition(...globs: string[]): this;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use `notImportFromWithOptions()` after `.should()` instead — it now
|
|
85
|
+
* dispatches as a condition automatically in the condition phase.
|
|
86
|
+
*/
|
|
87
|
+
notImportFromConditionWithOptions(globs: string[], options: ImportOptions): this;
|
|
88
|
+
/**
|
|
89
|
+
* No import may use an aliased specifier (`import { x as y }`).
|
|
90
|
+
*/
|
|
91
|
+
notHaveAliasedImports(): this;
|
|
92
|
+
/**
|
|
93
|
+
* Imports from matching paths must use `import type`.
|
|
94
|
+
*/
|
|
95
|
+
onlyHaveTypeImportsFrom(...globs: string[]): this;
|
|
96
|
+
/**
|
|
97
|
+
* The filtered module set must be empty.
|
|
98
|
+
*/
|
|
99
|
+
notExist(): this;
|
|
100
|
+
/**
|
|
101
|
+
* Assert that the module contains at least one match for the matcher.
|
|
102
|
+
* Default: searches the entire file including class/function bodies.
|
|
103
|
+
* With `{ scopeToModule: true }`: only searches top-level module-scope code.
|
|
104
|
+
*/
|
|
105
|
+
contain(matcher: ExpressionMatcher, options?: ModuleBodyOptions): this;
|
|
106
|
+
/**
|
|
107
|
+
* Assert that the module does NOT contain any match for the matcher.
|
|
108
|
+
* Default: searches the entire file including class/function bodies.
|
|
109
|
+
* With `{ scopeToModule: true }`: only searches top-level module-scope code.
|
|
110
|
+
*/
|
|
111
|
+
notContain(matcher: ExpressionMatcher, options?: ModuleBodyOptions): this;
|
|
112
|
+
/**
|
|
113
|
+
* Assert: module must NOT contain 'bad' AND must contain 'good'.
|
|
114
|
+
*/
|
|
115
|
+
useInsteadOf(bad: ExpressionMatcher, good: ExpressionMatcher, options?: ModuleBodyOptions): this;
|
|
116
|
+
/**
|
|
117
|
+
* Assert that matched modules do NOT have a default export.
|
|
118
|
+
*/
|
|
119
|
+
notHaveDefaultExport(): this;
|
|
120
|
+
/**
|
|
121
|
+
* Assert that matched modules have a default export.
|
|
122
|
+
*/
|
|
123
|
+
haveDefaultExport(): this;
|
|
124
|
+
/**
|
|
125
|
+
* Assert that matched modules have at most `max` named exports.
|
|
126
|
+
* Default exports are not counted.
|
|
127
|
+
*/
|
|
128
|
+
haveMaxExports(max: number): this;
|
|
129
|
+
/**
|
|
130
|
+
* Assert that every file importing this module matches at least one glob.
|
|
131
|
+
* Enforces barrel/facade patterns. Modules with zero importers pass vacuously.
|
|
132
|
+
*/
|
|
133
|
+
onlyBeImportedVia(...globs: string[]): this;
|
|
134
|
+
/**
|
|
135
|
+
* Assert that at least one other module in the project imports this module.
|
|
136
|
+
* Detects dead/orphaned files. Use `.excluding()` to skip entry points.
|
|
137
|
+
*/
|
|
138
|
+
beImported(): this;
|
|
139
|
+
/**
|
|
140
|
+
* Assert that every named export is referenced by at least one other file.
|
|
141
|
+
* Detects unused exports. More expensive than file-level checks — scope
|
|
142
|
+
* with `.that().resideInFolder()` to limit the search space.
|
|
143
|
+
*/
|
|
144
|
+
haveNoUnusedExports(): this;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Entry point: create a module-level rule builder.
|
|
148
|
+
*
|
|
149
|
+
* @param p - The loaded ArchProject
|
|
150
|
+
* @returns A ModuleRuleBuilder operating on all source files in the project
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* modules(project)
|
|
154
|
+
* .that().resideInFolder('** /services/** ')
|
|
155
|
+
* .should().onlyImportFrom('** /services/** ', '** /shared/** ')
|
|
156
|
+
* .check()
|
|
157
|
+
*/
|
|
158
|
+
export declare function modules(p: ArchProject): ModuleRuleBuilder;
|
|
159
|
+
//# sourceMappingURL=module-rule-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-rule-builder.d.ts","sourceRoot":"","sources":["../../src/builders/module-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAiBrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAM9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAiBrE;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC;IACzE,SAAS,CAAC,WAAW,IAAI,UAAU,EAAE;IAMrC;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAA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AO,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAIzE;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAMhG;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAIzB;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMjC;;;OAGG;IACH,iBAAiB,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAI3C;;;OAGG;IACH,UAAU,IAAI,IAAI;IAIlB;;;;OAIG;IACH,mBAAmB,IAAI,IAAI;CAG5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAEzD"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { RuleBuilder } from '@nielspeter/eess';
|
|
2
|
+
import { resideInFile as resideInFilePredicate, resideInFolder as resideInFolderPredicate, } from '../predicates/identity.js';
|
|
3
|
+
import { importFrom as importFromPredicate, notImportFrom as notImportFromPredicate, exportSymbolNamed as exportSymbolNamedPredicate, havePathMatching as havePathMatchingPredicate, } from '../predicates/module.js';
|
|
4
|
+
import { onlyImportFrom as onlyImportFromCondition, notImportFrom as notImportFromCondition, onlyHaveTypeImportsFrom as onlyHaveTypeImportsFromCondition, notHaveAliasedImports as notHaveAliasedImportsCondition, } from '../conditions/dependency.js';
|
|
5
|
+
import { notExist, resideInFile as resideInFileCondition, resideInFolder as resideInFolderCondition, } from '../conditions/structural.js';
|
|
6
|
+
import { moduleContain, moduleNotContain, moduleUseInsteadOf, } from '../conditions/body-analysis-module.js';
|
|
7
|
+
import { notHaveDefaultExport as notHaveDefaultExportCondition, haveDefaultExport as haveDefaultExportCondition, haveMaxExports as haveMaxExportsCondition, } from '../conditions/exports.js';
|
|
8
|
+
import { onlyBeImportedVia as onlyBeImportedViaCondition, beImported as beImportedCondition, haveNoUnusedExports as haveNoUnusedExportsCondition, } from '../conditions/reverse-dependency.js';
|
|
9
|
+
/**
|
|
10
|
+
* Rule builder for module-level (SourceFile) architecture rules.
|
|
11
|
+
*
|
|
12
|
+
* Each .ts file in the project is treated as a module. Predicates filter
|
|
13
|
+
* which modules to check, conditions assert constraints on their imports.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* modules(project)
|
|
17
|
+
* .that().resideInFolder('** /domain/** ')
|
|
18
|
+
* .should().onlyImportFrom('** /domain/** ', '** /shared/** ')
|
|
19
|
+
* .because('domain must not depend on infrastructure')
|
|
20
|
+
* .check()
|
|
21
|
+
*/
|
|
22
|
+
export class ModuleRuleBuilder extends RuleBuilder {
|
|
23
|
+
getElements() {
|
|
24
|
+
return this.project.getSourceFiles();
|
|
25
|
+
}
|
|
26
|
+
// --- Identity predicates (from predicates/identity.ts) ---
|
|
27
|
+
/**
|
|
28
|
+
* Filter modules whose file name matches the given regex.
|
|
29
|
+
* The regex is tested against the base file name (e.g., "user-service.ts").
|
|
30
|
+
*/
|
|
31
|
+
haveNameMatching(pattern) {
|
|
32
|
+
const regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
33
|
+
return this.addPredicate({
|
|
34
|
+
description: `have name matching ${String(regex)}`,
|
|
35
|
+
test: (sf) => regex.test(sf.getBaseName()),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* After `.that()`: filter modules that reside in a file matching the given glob.
|
|
40
|
+
* After `.should()`: assert modules reside in a file matching the given glob.
|
|
41
|
+
* Matched against the absolute file path.
|
|
42
|
+
*/
|
|
43
|
+
resideInFile(glob) {
|
|
44
|
+
if (this._phase === 'condition') {
|
|
45
|
+
return this.addCondition(resideInFileCondition(glob));
|
|
46
|
+
}
|
|
47
|
+
return this.addPredicate(resideInFilePredicate(glob));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* After `.that()`: filter modules that reside in a folder matching the given glob.
|
|
51
|
+
* After `.should()`: assert modules reside in a folder matching the given glob.
|
|
52
|
+
* Matched against the directory portion of the absolute file path.
|
|
53
|
+
*/
|
|
54
|
+
resideInFolder(glob) {
|
|
55
|
+
if (this._phase === 'condition') {
|
|
56
|
+
return this.addCondition(resideInFolderCondition(glob));
|
|
57
|
+
}
|
|
58
|
+
return this.addPredicate(resideInFolderPredicate(glob));
|
|
59
|
+
}
|
|
60
|
+
// --- Module-specific predicates (from predicates/module.ts) ---
|
|
61
|
+
/**
|
|
62
|
+
* Filter modules that import from a path matching any of the given globs.
|
|
63
|
+
* Pass `{ ignoreTypeImports: true }` to exclude type-only imports.
|
|
64
|
+
*/
|
|
65
|
+
importFrom(...globs) {
|
|
66
|
+
return this.addPredicate(importFromPredicate(...globs));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Filter modules that import from a path matching any of the given globs,
|
|
70
|
+
* with options to control type-import handling.
|
|
71
|
+
*/
|
|
72
|
+
importFromWithOptions(globs, options) {
|
|
73
|
+
return this.addPredicate(importFromPredicate(globs, options));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* After `.that()`: filter modules that do NOT import from matching globs.
|
|
77
|
+
* After `.should()`: assert that no import resolves to a matching glob.
|
|
78
|
+
*/
|
|
79
|
+
notImportFrom(...globs) {
|
|
80
|
+
if (this._phase === 'condition') {
|
|
81
|
+
return this.addCondition(notImportFromCondition(...globs));
|
|
82
|
+
}
|
|
83
|
+
return this.addPredicate(notImportFromPredicate(...globs));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* After `.that()`: filter modules that do NOT import from matching globs.
|
|
87
|
+
* After `.should()`: assert that no import resolves to a matching glob.
|
|
88
|
+
* With options to control type-import handling.
|
|
89
|
+
*/
|
|
90
|
+
notImportFromWithOptions(globs, options) {
|
|
91
|
+
if (this._phase === 'condition') {
|
|
92
|
+
return this.addCondition(notImportFromCondition(globs, options));
|
|
93
|
+
}
|
|
94
|
+
return this.addPredicate(notImportFromPredicate(globs, options));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Filter modules that export a symbol with the given name.
|
|
98
|
+
*/
|
|
99
|
+
exportSymbolNamed(name) {
|
|
100
|
+
return this.addPredicate(exportSymbolNamedPredicate(name));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Filter modules whose file path matches the given glob.
|
|
104
|
+
*/
|
|
105
|
+
havePathMatching(glob) {
|
|
106
|
+
return this.addPredicate(havePathMatchingPredicate(glob));
|
|
107
|
+
}
|
|
108
|
+
// --- Dependency conditions (from conditions/dependency.ts) ---
|
|
109
|
+
/**
|
|
110
|
+
* Every import must resolve to a path matching at least one of the globs.
|
|
111
|
+
* Pass `{ ignoreTypeImports: true }` to exclude type-only imports.
|
|
112
|
+
*/
|
|
113
|
+
onlyImportFrom(...globs) {
|
|
114
|
+
return this.addCondition(onlyImportFromCondition(...globs));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Every import must resolve to a path matching at least one of the globs,
|
|
118
|
+
* with options to control type-import handling.
|
|
119
|
+
*/
|
|
120
|
+
onlyImportFromWithOptions(globs, options) {
|
|
121
|
+
return this.addCondition(onlyImportFromCondition(globs, options));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated Use `notImportFrom()` after `.should()` instead — it now dispatches
|
|
125
|
+
* as a condition automatically in the condition phase.
|
|
126
|
+
*/
|
|
127
|
+
notImportFromCondition(...globs) {
|
|
128
|
+
return this.addCondition(notImportFromCondition(...globs));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated Use `notImportFromWithOptions()` after `.should()` instead — it now
|
|
132
|
+
* dispatches as a condition automatically in the condition phase.
|
|
133
|
+
*/
|
|
134
|
+
notImportFromConditionWithOptions(globs, options) {
|
|
135
|
+
return this.addCondition(notImportFromCondition(globs, options));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* No import may use an aliased specifier (`import { x as y }`).
|
|
139
|
+
*/
|
|
140
|
+
notHaveAliasedImports() {
|
|
141
|
+
return this.addCondition(notHaveAliasedImportsCondition());
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Imports from matching paths must use `import type`.
|
|
145
|
+
*/
|
|
146
|
+
onlyHaveTypeImportsFrom(...globs) {
|
|
147
|
+
return this.addCondition(onlyHaveTypeImportsFromCondition(...globs));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The filtered module set must be empty.
|
|
151
|
+
*/
|
|
152
|
+
notExist() {
|
|
153
|
+
return this.addCondition(notExist());
|
|
154
|
+
}
|
|
155
|
+
// --- Body analysis conditions (plan 0041 phase 2) ---
|
|
156
|
+
/**
|
|
157
|
+
* Assert that the module contains at least one match for the matcher.
|
|
158
|
+
* Default: searches the entire file including class/function bodies.
|
|
159
|
+
* With `{ scopeToModule: true }`: only searches top-level module-scope code.
|
|
160
|
+
*/
|
|
161
|
+
contain(matcher, options) {
|
|
162
|
+
return this.addCondition(moduleContain(matcher, options));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Assert that the module does NOT contain any match for the matcher.
|
|
166
|
+
* Default: searches the entire file including class/function bodies.
|
|
167
|
+
* With `{ scopeToModule: true }`: only searches top-level module-scope code.
|
|
168
|
+
*/
|
|
169
|
+
notContain(matcher, options) {
|
|
170
|
+
return this.addCondition(moduleNotContain(matcher, options));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Assert: module must NOT contain 'bad' AND must contain 'good'.
|
|
174
|
+
*/
|
|
175
|
+
useInsteadOf(bad, good, options) {
|
|
176
|
+
return this.addCondition(moduleUseInsteadOf(bad, good, options));
|
|
177
|
+
}
|
|
178
|
+
// --- Export conditions (plan 0041 phase 3) ---
|
|
179
|
+
/**
|
|
180
|
+
* Assert that matched modules do NOT have a default export.
|
|
181
|
+
*/
|
|
182
|
+
notHaveDefaultExport() {
|
|
183
|
+
return this.addCondition(notHaveDefaultExportCondition());
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Assert that matched modules have a default export.
|
|
187
|
+
*/
|
|
188
|
+
haveDefaultExport() {
|
|
189
|
+
return this.addCondition(haveDefaultExportCondition());
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Assert that matched modules have at most `max` named exports.
|
|
193
|
+
* Default exports are not counted.
|
|
194
|
+
*/
|
|
195
|
+
haveMaxExports(max) {
|
|
196
|
+
return this.addCondition(haveMaxExportsCondition(max));
|
|
197
|
+
}
|
|
198
|
+
// --- Reverse dependency conditions (plan 0041 phase 4) ---
|
|
199
|
+
/**
|
|
200
|
+
* Assert that every file importing this module matches at least one glob.
|
|
201
|
+
* Enforces barrel/facade patterns. Modules with zero importers pass vacuously.
|
|
202
|
+
*/
|
|
203
|
+
onlyBeImportedVia(...globs) {
|
|
204
|
+
return this.addCondition(onlyBeImportedViaCondition(...globs));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Assert that at least one other module in the project imports this module.
|
|
208
|
+
* Detects dead/orphaned files. Use `.excluding()` to skip entry points.
|
|
209
|
+
*/
|
|
210
|
+
beImported() {
|
|
211
|
+
return this.addCondition(beImportedCondition());
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Assert that every named export is referenced by at least one other file.
|
|
215
|
+
* Detects unused exports. More expensive than file-level checks — scope
|
|
216
|
+
* with `.that().resideInFolder()` to limit the search space.
|
|
217
|
+
*/
|
|
218
|
+
haveNoUnusedExports() {
|
|
219
|
+
return this.addCondition(haveNoUnusedExportsCondition());
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Entry point: create a module-level rule builder.
|
|
224
|
+
*
|
|
225
|
+
* @param p - The loaded ArchProject
|
|
226
|
+
* @returns A ModuleRuleBuilder operating on all source files in the project
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* modules(project)
|
|
230
|
+
* .that().resideInFolder('** /services/** ')
|
|
231
|
+
* .should().onlyImportFrom('** /services/** ', '** /shared/** ')
|
|
232
|
+
* .check()
|
|
233
|
+
*/
|
|
234
|
+
export function modules(p) {
|
|
235
|
+
return new ModuleRuleBuilder(p);
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=module-rule-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-rule-builder.js","sourceRoot":"","sources":["../../src/builders/module-rule-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EACL,YAAY,IAAI,qBAAqB,EACrC,cAAc,IAAI,uBAAuB,GAC1C,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,UAAU,IAAI,mBAAmB,EACjC,aAAa,IAAI,sBAAsB,EACvC,iBAAiB,IAAI,0BAA0B,EAC/C,gBAAgB,IAAI,yBAAyB,GAC9C,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,cAAc,IAAI,uBAAuB,EACzC,aAAa,IAAI,sBAAsB,EACvC,uBAAuB,IAAI,gCAAgC,EAC3D,qBAAqB,IAAI,8BAA8B,GACxD,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,QAAQ,EACR,YAAY,IAAI,qBAAqB,EACrC,cAAc,IAAI,uBAAuB,GAC1C,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,oBAAoB,IAAI,6BAA6B,EACrD,iBAAiB,IAAI,0BAA0B,EAC/C,cAAc,IAAI,uBAAuB,GAC1C,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,iBAAiB,IAAI,0BAA0B,EAC/C,UAAU,IAAI,mBAAmB,EACjC,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,qCAAqC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B,OAAO,IAAI,CAAC,YAAY,CAAC,6BAA6B,EAAE,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,YAAY,CAAC,0BAA0B,EAAE,CAAC,CAAA;IACxD,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAA;IACxD,CAAC;IAED,4DAA4D;IAE5D;;;OAGG;IACH,iBAAiB,CAAC,GAAG,KAAe;QAClC,OAAO,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,GAAG,KAAK,CAAC,CAAC,CAAA;IAChE,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAC,CAAA;IAC1D,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO,CAAC,CAAc;IACpC,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FunctionRuleBuilder } from './function-rule-builder.js';
|
|
2
|
+
import type { CallRuleBuilder } from './call-rule-builder.js';
|
|
3
|
+
import type { ArchFunction } from '../models/arch-function.js';
|
|
4
|
+
/**
|
|
5
|
+
* A FunctionRuleBuilder that only examines callback functions
|
|
6
|
+
* inside matched call expressions.
|
|
7
|
+
*
|
|
8
|
+
* Created by `within(selection).functions()`. Inherits all predicates,
|
|
9
|
+
* conditions, and chain methods from FunctionRuleBuilder --- the only
|
|
10
|
+
* difference is the element source.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ScopedFunctionRuleBuilder extends FunctionRuleBuilder {
|
|
13
|
+
private readonly callSelection;
|
|
14
|
+
constructor(callSelection: CallRuleBuilder);
|
|
15
|
+
/**
|
|
16
|
+
* Override: instead of scanning all source files, extract callbacks
|
|
17
|
+
* from the matched call expressions.
|
|
18
|
+
*/
|
|
19
|
+
protected getElements(): ArchFunction[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=scoped-function-rule-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-function-rule-builder.d.ts","sourceRoot":"","sources":["../../src/builders/scoped-function-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAG9D;;;;;;;GAOG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB;IAChE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;gBAEnC,aAAa,EAAE,eAAe;IAK1C;;;OAGG;cACgB,WAAW,IAAI,YAAY,EAAE;CAMjD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FunctionRuleBuilder } from './function-rule-builder.js';
|
|
2
|
+
import { extractCallbacks } from '../helpers/callback-extractor.js';
|
|
3
|
+
/**
|
|
4
|
+
* A FunctionRuleBuilder that only examines callback functions
|
|
5
|
+
* inside matched call expressions.
|
|
6
|
+
*
|
|
7
|
+
* Created by `within(selection).functions()`. Inherits all predicates,
|
|
8
|
+
* conditions, and chain methods from FunctionRuleBuilder --- the only
|
|
9
|
+
* difference is the element source.
|
|
10
|
+
*/
|
|
11
|
+
export class ScopedFunctionRuleBuilder extends FunctionRuleBuilder {
|
|
12
|
+
callSelection;
|
|
13
|
+
constructor(callSelection) {
|
|
14
|
+
super(callSelection.getProject());
|
|
15
|
+
this.callSelection = callSelection;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Override: instead of scanning all source files, extract callbacks
|
|
19
|
+
* from the matched call expressions.
|
|
20
|
+
*/
|
|
21
|
+
getElements() {
|
|
22
|
+
const matchedCalls = this.callSelection.getMatchedCalls();
|
|
23
|
+
return matchedCalls.flatMap((archCall) => extractCallbacks(archCall.getNode()).map((ec) => ec.fn));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=scoped-function-rule-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-function-rule-builder.js","sourceRoot":"","sources":["../../src/builders/scoped-function-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAEnE;;;;;;;GAOG;AACH,MAAM,OAAO,yBAA0B,SAAQ,mBAAmB;IAC/C,aAAa,CAAiB;IAE/C,YAAY,aAA8B;QACxC,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAA;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED;;;OAGG;IACgB,WAAW;QAC5B,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;QACzD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CACvC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CACxD,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ArchProject } from '../core/project.js';
|
|
2
|
+
import type { ArchViolation } from '../core/violation.js';
|
|
3
|
+
import { TerminalBuilder } from '@nielspeter/eess';
|
|
4
|
+
import type { SliceDefinition } from '../models/slice.js';
|
|
5
|
+
/**
|
|
6
|
+
* Rule builder for slice-level architecture rules.
|
|
7
|
+
*
|
|
8
|
+
* Unlike other builders that extend RuleBuilder<T>, SliceRuleBuilder
|
|
9
|
+
* has its own chain because the grouping step (matching/assignedFrom)
|
|
10
|
+
* replaces the predicate phase entirely.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* slices(project).matching(glob).should().beFreeOfCycles().check()
|
|
14
|
+
* slices(project).assignedFrom(def).should().respectLayerOrder(...).check()
|
|
15
|
+
*/
|
|
16
|
+
export declare class SliceRuleBuilder extends TerminalBuilder {
|
|
17
|
+
private readonly project;
|
|
18
|
+
private _slices;
|
|
19
|
+
private readonly _conditions;
|
|
20
|
+
constructor(project: ArchProject);
|
|
21
|
+
/**
|
|
22
|
+
* Define slices by glob matching. Each directory matching the glob
|
|
23
|
+
* becomes a slice named after that directory.
|
|
24
|
+
*
|
|
25
|
+
* @param glob - A glob pattern where the wildcard segment identifies slices
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* slices(project).matching('src/features/*\/')
|
|
29
|
+
* // Slices: auth, billing, orders, etc.
|
|
30
|
+
*/
|
|
31
|
+
matching(glob: string): this;
|
|
32
|
+
/**
|
|
33
|
+
* Define slices from an explicit name-to-glob mapping.
|
|
34
|
+
*
|
|
35
|
+
* @param definition - Map of slice names to glob patterns
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* slices(project).assignedFrom({
|
|
39
|
+
* presentation: 'src/controllers/**',
|
|
40
|
+
* domain: 'src/domain/**',
|
|
41
|
+
* })
|
|
42
|
+
*/
|
|
43
|
+
assignedFrom(definition: SliceDefinition): this;
|
|
44
|
+
/**
|
|
45
|
+
* Begin the condition phase. Returns `this` for chaining.
|
|
46
|
+
*/
|
|
47
|
+
should(): this;
|
|
48
|
+
/**
|
|
49
|
+
* Add another condition (AND).
|
|
50
|
+
*/
|
|
51
|
+
andShould(): this;
|
|
52
|
+
/**
|
|
53
|
+
* Assert that no circular dependencies exist between slices.
|
|
54
|
+
*/
|
|
55
|
+
beFreeOfCycles(): this;
|
|
56
|
+
/**
|
|
57
|
+
* Assert that slices respect a layered dependency order.
|
|
58
|
+
* Layer N may depend on layers N+1, N+2, ... but NOT on layers with lower index.
|
|
59
|
+
*
|
|
60
|
+
* @param layers - Ordered layer names from highest to lowest
|
|
61
|
+
*/
|
|
62
|
+
respectLayerOrder(...layers: string[]): this;
|
|
63
|
+
/**
|
|
64
|
+
* Assert that no slice depends on any of the listed slices.
|
|
65
|
+
*
|
|
66
|
+
* @param sliceNames - Names of forbidden dependency targets
|
|
67
|
+
*/
|
|
68
|
+
notDependOn(...sliceNames: string[]): this;
|
|
69
|
+
protected collectViolations(): ArchViolation[];
|
|
70
|
+
private buildRuleDescription;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Entry point: create a slice-level rule builder.
|
|
74
|
+
*
|
|
75
|
+
* @param p - The loaded ArchProject
|
|
76
|
+
* @returns A SliceRuleBuilder — call `.matching()` or `.assignedFrom()` next
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* slices(project)
|
|
80
|
+
* .matching('src/features/*\/')
|
|
81
|
+
* .should().beFreeOfCycles()
|
|
82
|
+
* .check()
|
|
83
|
+
*/
|
|
84
|
+
export declare function slices(p: ArchProject): SliceRuleBuilder;
|
|
85
|
+
//# sourceMappingURL=slice-rule-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slice-rule-builder.d.ts","sourceRoot":"","sources":["../../src/builders/slice-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAS,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAQhE;;;;;;;;;;GAUG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;IAIvC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;gBAExB,OAAO,EAAE,WAAW;IAIjD;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK5B;;;;;;;;;;OAUG;IACH,YAAY,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAK/C;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;OAEG;IACH,cAAc,IAAI,IAAI;IAKtB;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAK5C;;;;OAIG;IACH,WAAW,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI;IAK1C,SAAS,CAAC,iBAAiB,IAAI,aAAa,EAAE;IA8B9C,OAAO,CAAC,oBAAoB;CAK7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAEvD"}
|