@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,134 @@
|
|
|
1
|
+
import { TerminalBuilder } from '@nielspeter/eess';
|
|
2
|
+
import { resolveByMatching, resolveByDefinition } from '../models/slice.js';
|
|
3
|
+
import { beFreeOfCycles as beFreeOfCyclesCondition, respectLayerOrder as respectLayerOrderCondition, notDependOn as notDependOnCondition, } from '../conditions/slice.js';
|
|
4
|
+
/**
|
|
5
|
+
* Rule builder for slice-level architecture rules.
|
|
6
|
+
*
|
|
7
|
+
* Unlike other builders that extend RuleBuilder<T>, SliceRuleBuilder
|
|
8
|
+
* has its own chain because the grouping step (matching/assignedFrom)
|
|
9
|
+
* replaces the predicate phase entirely.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* slices(project).matching(glob).should().beFreeOfCycles().check()
|
|
13
|
+
* slices(project).assignedFrom(def).should().respectLayerOrder(...).check()
|
|
14
|
+
*/
|
|
15
|
+
export class SliceRuleBuilder extends TerminalBuilder {
|
|
16
|
+
project;
|
|
17
|
+
_slices = [];
|
|
18
|
+
_conditions = [];
|
|
19
|
+
constructor(project) {
|
|
20
|
+
super();
|
|
21
|
+
this.project = project;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Define slices by glob matching. Each directory matching the glob
|
|
25
|
+
* becomes a slice named after that directory.
|
|
26
|
+
*
|
|
27
|
+
* @param glob - A glob pattern where the wildcard segment identifies slices
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* slices(project).matching('src/features/*\/')
|
|
31
|
+
* // Slices: auth, billing, orders, etc.
|
|
32
|
+
*/
|
|
33
|
+
matching(glob) {
|
|
34
|
+
this._slices = resolveByMatching(this.project, glob);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Define slices from an explicit name-to-glob mapping.
|
|
39
|
+
*
|
|
40
|
+
* @param definition - Map of slice names to glob patterns
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* slices(project).assignedFrom({
|
|
44
|
+
* presentation: 'src/controllers/**',
|
|
45
|
+
* domain: 'src/domain/**',
|
|
46
|
+
* })
|
|
47
|
+
*/
|
|
48
|
+
assignedFrom(definition) {
|
|
49
|
+
this._slices = resolveByDefinition(this.project, definition);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Begin the condition phase. Returns `this` for chaining.
|
|
54
|
+
*/
|
|
55
|
+
should() {
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Add another condition (AND).
|
|
60
|
+
*/
|
|
61
|
+
andShould() {
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Assert that no circular dependencies exist between slices.
|
|
66
|
+
*/
|
|
67
|
+
beFreeOfCycles() {
|
|
68
|
+
this._conditions.push(beFreeOfCyclesCondition());
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Assert that slices respect a layered dependency order.
|
|
73
|
+
* Layer N may depend on layers N+1, N+2, ... but NOT on layers with lower index.
|
|
74
|
+
*
|
|
75
|
+
* @param layers - Ordered layer names from highest to lowest
|
|
76
|
+
*/
|
|
77
|
+
respectLayerOrder(...layers) {
|
|
78
|
+
this._conditions.push(respectLayerOrderCondition(...layers));
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Assert that no slice depends on any of the listed slices.
|
|
83
|
+
*
|
|
84
|
+
* @param sliceNames - Names of forbidden dependency targets
|
|
85
|
+
*/
|
|
86
|
+
notDependOn(...sliceNames) {
|
|
87
|
+
this._conditions.push(notDependOnCondition(...sliceNames));
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
collectViolations() {
|
|
91
|
+
if (this._slices.length === 0) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
if (this._conditions.length === 0) {
|
|
95
|
+
const ruleId = this._metadata?.id ?? 'unnamed';
|
|
96
|
+
console.warn(`[eess] Slice rule '${ruleId}' has no conditions. ` +
|
|
97
|
+
`Did you forget to add a condition like beFreeOfCycles()?`);
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const context = {
|
|
101
|
+
rule: this.buildRuleDescription(),
|
|
102
|
+
because: this._reason,
|
|
103
|
+
ruleId: this._metadata?.id,
|
|
104
|
+
suggestion: this._metadata?.suggestion,
|
|
105
|
+
docs: this._metadata?.docs,
|
|
106
|
+
};
|
|
107
|
+
const violations = [];
|
|
108
|
+
for (const condition of this._conditions) {
|
|
109
|
+
violations.push(...condition.evaluate(this._slices, context));
|
|
110
|
+
}
|
|
111
|
+
return violations;
|
|
112
|
+
}
|
|
113
|
+
buildRuleDescription() {
|
|
114
|
+
const sliceDesc = this._slices.map((s) => s.name).join(', ');
|
|
115
|
+
const conditionDesc = this._conditions.map((c) => c.description).join(' and ');
|
|
116
|
+
return `slices [${sliceDesc}] should ${conditionDesc}`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Entry point: create a slice-level rule builder.
|
|
121
|
+
*
|
|
122
|
+
* @param p - The loaded ArchProject
|
|
123
|
+
* @returns A SliceRuleBuilder — call `.matching()` or `.assignedFrom()` next
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* slices(project)
|
|
127
|
+
* .matching('src/features/*\/')
|
|
128
|
+
* .should().beFreeOfCycles()
|
|
129
|
+
* .check()
|
|
130
|
+
*/
|
|
131
|
+
export function slices(p) {
|
|
132
|
+
return new SliceRuleBuilder(p);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=slice-rule-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slice-rule-builder.js","sourceRoot":"","sources":["../../src/builders/slice-rule-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,EACL,cAAc,IAAI,uBAAuB,EACzC,iBAAiB,IAAI,0BAA0B,EAC/C,WAAW,IAAI,oBAAoB,GACpC,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IAItB;IAHrB,OAAO,GAAY,EAAE,CAAA;IACZ,WAAW,GAAuB,EAAE,CAAA;IAErD,YAA6B,OAAoB;QAC/C,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAa;IAEjD,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAY;QACn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;QAED,MAAM,OAAO,GAAqB;YAChC,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU;YACtC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI;SAC3B,CAAA;QAED,MAAM,UAAU,GAAoB,EAAE,CAAA;QACtC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACzC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QAC/D,CAAC;QAED,OAAO,UAAU,CAAA;IACnB,CAAC;IAEO,oBAAoB;QAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5D,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9E,OAAO,WAAW,SAAS,YAAY,aAAa,EAAE,CAAA;IACxD,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,CAAc;IACnC,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ArchProject } from '../core/project.js';
|
|
2
|
+
import { RuleBuilder } from '@nielspeter/eess';
|
|
3
|
+
import type { TypeMatcher } from '../helpers/type-matchers.js';
|
|
4
|
+
import { type TypeDeclaration } from '../predicates/type.js';
|
|
5
|
+
/**
|
|
6
|
+
* Rule builder for interface and type alias declarations.
|
|
7
|
+
*
|
|
8
|
+
* Returned by the `types()` entry point. Provides type-specific
|
|
9
|
+
* predicates and conditions on top of the base RuleBuilder chain.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* types(project)
|
|
13
|
+
* .that().haveProperty('sortBy')
|
|
14
|
+
* .should().havePropertyType('sortBy', not(isString()))
|
|
15
|
+
* .because('sortBy must be a union of literals, not bare string')
|
|
16
|
+
* .check()
|
|
17
|
+
*/
|
|
18
|
+
export declare class TypeRuleBuilder extends RuleBuilder<TypeDeclaration, ArchProject> {
|
|
19
|
+
constructor(project: ArchProject);
|
|
20
|
+
/**
|
|
21
|
+
* Collect all InterfaceDeclarations and TypeAliasDeclarations
|
|
22
|
+
* from all source files in the project.
|
|
23
|
+
*/
|
|
24
|
+
protected getElements(): TypeDeclaration[];
|
|
25
|
+
/** Filter to interface declarations only (excludes type aliases). */
|
|
26
|
+
areInterfaces(): this;
|
|
27
|
+
/** Filter to type alias declarations only (excludes interfaces). */
|
|
28
|
+
areTypeAliases(): this;
|
|
29
|
+
/**
|
|
30
|
+
* Filter to types that have a property with the given name. Resolves
|
|
31
|
+
* through the type system, so it works for both interfaces and aliases.
|
|
32
|
+
*/
|
|
33
|
+
haveProperty(name: string): this;
|
|
34
|
+
/**
|
|
35
|
+
* Filter to types whose named property has a type satisfying the matcher.
|
|
36
|
+
* Resolves through aliases and mapped types (`Partial<>`, `Pick<>`, ...).
|
|
37
|
+
*/
|
|
38
|
+
havePropertyOfType(name: string, matcher: TypeMatcher): this;
|
|
39
|
+
/**
|
|
40
|
+
* Filter to types that extend/reference the named type. Interfaces are
|
|
41
|
+
* matched by their `extends` clause; type aliases by a reference to the
|
|
42
|
+
* name in the resolved type text.
|
|
43
|
+
*/
|
|
44
|
+
extendType(name: string): this;
|
|
45
|
+
/**
|
|
46
|
+
* Assert that the named property's type satisfies the matcher. Types
|
|
47
|
+
* lacking the property are skipped (no violation) — pair with
|
|
48
|
+
* `haveProperty()` to require it.
|
|
49
|
+
*/
|
|
50
|
+
havePropertyType(name: string, matcher: TypeMatcher): this;
|
|
51
|
+
/** Assert that matched types are exported from their module. */
|
|
52
|
+
beExported(): this;
|
|
53
|
+
/** Assert that the filtered type set is empty (no matched type may exist). */
|
|
54
|
+
notExist(): this;
|
|
55
|
+
/** @deprecated Use `haveNameMatching()` after `.should()` instead. */
|
|
56
|
+
conditionHaveNameMatching(pattern: RegExp): this;
|
|
57
|
+
/** Assert that every matched type has all of the named properties (one violation per missing name). */
|
|
58
|
+
havePropertyNamed(...names: string[]): this;
|
|
59
|
+
/** Assert that no matched type has any of the named properties (one violation per forbidden name found). */
|
|
60
|
+
notHavePropertyNamed(...names: string[]): this;
|
|
61
|
+
/** Assert that every matched type has at least one property whose name matches the regex. */
|
|
62
|
+
havePropertyMatching(pattern: RegExp): this;
|
|
63
|
+
/** Assert that no matched type has a property whose name matches the regex (one violation per match). */
|
|
64
|
+
notHavePropertyMatching(pattern: RegExp): this;
|
|
65
|
+
/** Assert that every property of each matched type is `readonly` (resolves `Readonly<T>` too). */
|
|
66
|
+
haveOnlyReadonlyProperties(): this;
|
|
67
|
+
/** Assert that no matched type has more than `max` properties (guards against oversized DTOs). */
|
|
68
|
+
maxProperties(max: number): this;
|
|
69
|
+
/**
|
|
70
|
+
* After `.that()`: filter types whose name matches the pattern.
|
|
71
|
+
* After `.should()`: assert matched types have names matching the pattern.
|
|
72
|
+
*/
|
|
73
|
+
haveNameMatching(pattern: RegExp | string): this;
|
|
74
|
+
/** Filter to types that are exported from their module. */
|
|
75
|
+
areExported(): this;
|
|
76
|
+
/** Filter to types that are NOT exported from their module. */
|
|
77
|
+
areNotExported(): this;
|
|
78
|
+
/**
|
|
79
|
+
* After `.that()`: filter types in a file matching the glob.
|
|
80
|
+
* After `.should()`: assert types reside in a file matching the glob.
|
|
81
|
+
*/
|
|
82
|
+
resideInFile(glob: string): this;
|
|
83
|
+
/**
|
|
84
|
+
* After `.that()`: filter types in a folder matching the glob.
|
|
85
|
+
* After `.should()`: assert types reside in a folder matching the glob.
|
|
86
|
+
*/
|
|
87
|
+
resideInFolder(glob: string): this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Entry point for rules on interface and type alias declarations.
|
|
91
|
+
*
|
|
92
|
+
* Returns a TypeRuleBuilder that can filter and assert on all
|
|
93
|
+
* InterfaceDeclaration and TypeAliasDeclaration nodes in the project.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* // All types with a sortBy property must not use bare string
|
|
97
|
+
* types(project)
|
|
98
|
+
* .that().haveProperty('sortBy')
|
|
99
|
+
* .should().havePropertyType('sortBy', not(isString()))
|
|
100
|
+
* .check()
|
|
101
|
+
*/
|
|
102
|
+
export declare function types(p: ArchProject): TypeRuleBuilder;
|
|
103
|
+
//# sourceMappingURL=type-rule-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-rule-builder.d.ts","sourceRoot":"","sources":["../../src/builders/type-rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAA;AAyB9B;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAgB,SAAQ,WAAW,CAAC,eAAe,EAAE,WAAW,CAAC;gBAChE,OAAO,EAAE,WAAW;IAIhC;;;OAGG;IACH,SAAS,CAAC,WAAW,IAAI,eAAe,EAAE;IAW1C,qEAAqE;IACrE,aAAa,IAAI,IAAI;IAIrB,oEAAoE;IACpE,cAAc,IAAI,IAAI;IAItB;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIhC;;;OAGG;IACH,kBAAkB,C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, haveProperty, havePropertyOfType, extendType, } from '../predicates/type.js';
|
|
3
|
+
import { havePropertyType } from '../conditions/type-level.js';
|
|
4
|
+
import { havePropertyNamed as memberHavePropertyNamed, notHavePropertyNamed as memberNotHavePropertyNamed, havePropertyMatching as memberHavePropertyMatching, notHavePropertyMatching as memberNotHavePropertyMatching, haveOnlyReadonlyProperties as memberHaveOnlyReadonlyProperties, maxProperties as memberMaxProperties, } from '../conditions/members.js';
|
|
5
|
+
import { beExported as conditionBeExported, notExist as conditionNotExist, haveNameMatching as conditionHaveNameMatching, resideInFile as conditionResideInFile, resideInFolder as conditionResideInFolder, } from '../conditions/structural.js';
|
|
6
|
+
import { haveNameMatching as identityHaveNameMatching, resideInFile as identityResideInFile, resideInFolder as identityResideInFolder, areExported as identityAreExported, areNotExported as identityAreNotExported, } from '../predicates/identity.js';
|
|
7
|
+
/**
|
|
8
|
+
* Rule builder for interface and type alias declarations.
|
|
9
|
+
*
|
|
10
|
+
* Returned by the `types()` entry point. Provides type-specific
|
|
11
|
+
* predicates and conditions on top of the base RuleBuilder chain.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* types(project)
|
|
15
|
+
* .that().haveProperty('sortBy')
|
|
16
|
+
* .should().havePropertyType('sortBy', not(isString()))
|
|
17
|
+
* .because('sortBy must be a union of literals, not bare string')
|
|
18
|
+
* .check()
|
|
19
|
+
*/
|
|
20
|
+
export class TypeRuleBuilder extends RuleBuilder {
|
|
21
|
+
constructor(project) {
|
|
22
|
+
super(project);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Collect all InterfaceDeclarations and TypeAliasDeclarations
|
|
26
|
+
* from all source files in the project.
|
|
27
|
+
*/
|
|
28
|
+
getElements() {
|
|
29
|
+
const elements = [];
|
|
30
|
+
for (const sf of this.project.getSourceFiles()) {
|
|
31
|
+
elements.push(...sf.getInterfaces());
|
|
32
|
+
elements.push(...sf.getTypeAliases());
|
|
33
|
+
}
|
|
34
|
+
return elements;
|
|
35
|
+
}
|
|
36
|
+
// --- Type-specific predicates ---
|
|
37
|
+
/** Filter to interface declarations only (excludes type aliases). */
|
|
38
|
+
areInterfaces() {
|
|
39
|
+
return this.addPredicate(areInterfaces());
|
|
40
|
+
}
|
|
41
|
+
/** Filter to type alias declarations only (excludes interfaces). */
|
|
42
|
+
areTypeAliases() {
|
|
43
|
+
return this.addPredicate(areTypeAliases());
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Filter to types that have a property with the given name. Resolves
|
|
47
|
+
* through the type system, so it works for both interfaces and aliases.
|
|
48
|
+
*/
|
|
49
|
+
haveProperty(name) {
|
|
50
|
+
return this.addPredicate(haveProperty(name));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Filter to types whose named property has a type satisfying the matcher.
|
|
54
|
+
* Resolves through aliases and mapped types (`Partial<>`, `Pick<>`, ...).
|
|
55
|
+
*/
|
|
56
|
+
havePropertyOfType(name, matcher) {
|
|
57
|
+
return this.addPredicate(havePropertyOfType(name, matcher));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Filter to types that extend/reference the named type. Interfaces are
|
|
61
|
+
* matched by their `extends` clause; type aliases by a reference to the
|
|
62
|
+
* name in the resolved type text.
|
|
63
|
+
*/
|
|
64
|
+
extendType(name) {
|
|
65
|
+
return this.addPredicate(extendType(name));
|
|
66
|
+
}
|
|
67
|
+
// --- Type-specific conditions ---
|
|
68
|
+
/**
|
|
69
|
+
* Assert that the named property's type satisfies the matcher. Types
|
|
70
|
+
* lacking the property are skipped (no violation) — pair with
|
|
71
|
+
* `haveProperty()` to require it.
|
|
72
|
+
*/
|
|
73
|
+
havePropertyType(name, matcher) {
|
|
74
|
+
return this.addCondition(havePropertyType(name, matcher));
|
|
75
|
+
}
|
|
76
|
+
/** Assert that matched types are exported from their module. */
|
|
77
|
+
beExported() {
|
|
78
|
+
return this.addCondition(conditionBeExported());
|
|
79
|
+
}
|
|
80
|
+
/** Assert that the filtered type set is empty (no matched type may exist). */
|
|
81
|
+
notExist() {
|
|
82
|
+
return this.addCondition(conditionNotExist());
|
|
83
|
+
}
|
|
84
|
+
/** @deprecated Use `haveNameMatching()` after `.should()` instead. */
|
|
85
|
+
conditionHaveNameMatching(pattern) {
|
|
86
|
+
return this.addCondition(conditionHaveNameMatching(pattern));
|
|
87
|
+
}
|
|
88
|
+
// --- Member property conditions (plan 0030) ---
|
|
89
|
+
/** Assert that every matched type has all of the named properties (one violation per missing name). */
|
|
90
|
+
havePropertyNamed(...names) {
|
|
91
|
+
return this.addCondition(memberHavePropertyNamed(...names));
|
|
92
|
+
}
|
|
93
|
+
/** Assert that no matched type has any of the named properties (one violation per forbidden name found). */
|
|
94
|
+
notHavePropertyNamed(...names) {
|
|
95
|
+
return this.addCondition(memberNotHavePropertyNamed(...names));
|
|
96
|
+
}
|
|
97
|
+
/** Assert that every matched type has at least one property whose name matches the regex. */
|
|
98
|
+
havePropertyMatching(pattern) {
|
|
99
|
+
return this.addCondition(memberHavePropertyMatching(pattern));
|
|
100
|
+
}
|
|
101
|
+
/** Assert that no matched type has a property whose name matches the regex (one violation per match). */
|
|
102
|
+
notHavePropertyMatching(pattern) {
|
|
103
|
+
return this.addCondition(memberNotHavePropertyMatching(pattern));
|
|
104
|
+
}
|
|
105
|
+
/** Assert that every property of each matched type is `readonly` (resolves `Readonly<T>` too). */
|
|
106
|
+
haveOnlyReadonlyProperties() {
|
|
107
|
+
return this.addCondition(memberHaveOnlyReadonlyProperties());
|
|
108
|
+
}
|
|
109
|
+
/** Assert that no matched type has more than `max` properties (guards against oversized DTOs). */
|
|
110
|
+
maxProperties(max) {
|
|
111
|
+
return this.addCondition(memberMaxProperties(max));
|
|
112
|
+
}
|
|
113
|
+
// --- Identity predicates (convenience wrappers) ---
|
|
114
|
+
/**
|
|
115
|
+
* After `.that()`: filter types whose name matches the pattern.
|
|
116
|
+
* After `.should()`: assert matched types have names matching the pattern.
|
|
117
|
+
*/
|
|
118
|
+
haveNameMatching(pattern) {
|
|
119
|
+
if (this._phase === 'condition') {
|
|
120
|
+
const regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
121
|
+
return this.addCondition(conditionHaveNameMatching(regex));
|
|
122
|
+
}
|
|
123
|
+
return this.addPredicate(identityHaveNameMatching(pattern));
|
|
124
|
+
}
|
|
125
|
+
/** Filter to types that are exported from their module. */
|
|
126
|
+
areExported() {
|
|
127
|
+
return this.addPredicate(identityAreExported());
|
|
128
|
+
}
|
|
129
|
+
/** Filter to types that are NOT exported from their module. */
|
|
130
|
+
areNotExported() {
|
|
131
|
+
return this.addPredicate(identityAreNotExported());
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* After `.that()`: filter types in a file matching the glob.
|
|
135
|
+
* After `.should()`: assert types reside in a file matching the glob.
|
|
136
|
+
*/
|
|
137
|
+
resideInFile(glob) {
|
|
138
|
+
if (this._phase === 'condition') {
|
|
139
|
+
return this.addCondition(conditionResideInFile(glob));
|
|
140
|
+
}
|
|
141
|
+
return this.addPredicate(identityResideInFile(glob));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* After `.that()`: filter types in a folder matching the glob.
|
|
145
|
+
* After `.should()`: assert types reside in a folder matching the glob.
|
|
146
|
+
*/
|
|
147
|
+
resideInFolder(glob) {
|
|
148
|
+
if (this._phase === 'condition') {
|
|
149
|
+
return this.addCondition(conditionResideInFolder(glob));
|
|
150
|
+
}
|
|
151
|
+
return this.addPredicate(identityResideInFolder(glob));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Entry point for rules on interface and type alias declarations.
|
|
156
|
+
*
|
|
157
|
+
* Returns a TypeRuleBuilder that can filter and assert on all
|
|
158
|
+
* InterfaceDeclaration and TypeAliasDeclaration nodes in the project.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* // All types with a sortBy property must not use bare string
|
|
162
|
+
* types(project)
|
|
163
|
+
* .that().haveProperty('sortBy')
|
|
164
|
+
* .should().havePropertyType('sortBy', not(isString()))
|
|
165
|
+
* .check()
|
|
166
|
+
*/
|
|
167
|
+
export function types(p) {
|
|
168
|
+
return new TypeRuleBuilder(p);
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=type-rule-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-rule-builder.js","sourceRoot":"","sources":["../../src/builders/type-rule-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,UAAU,GAEX,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EACL,iBAAiB,IAAI,uBAAuB,EAC5C,oBAAoB,IAAI,0BAA0B,EAClD,oBAAoB,IAAI,0BAA0B,EAClD,uBAAuB,IAAI,6BAA6B,EACxD,0BAA0B,IAAI,gCAAgC,EAC9D,aAAa,IAAI,mBAAmB,GACrC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,UAAU,IAAI,mBAAmB,EACjC,QAAQ,IAAI,iBAAiB,EAC7B,gBAAgB,IAAI,yBAAyB,EAC7C,YAAY,IAAI,qBAAqB,EACrC,cAAc,IAAI,uBAAuB,GAC1C,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,gBAAgB,IAAI,wBAAwB,EAC5C,YAAY,IAAI,oBAAoB,EACpC,cAAc,IAAI,sBAAsB,EACxC,WAAW,IAAI,mBAAmB,EAClC,cAAc,IAAI,sBAAsB,GACzC,MAAM,2BAA2B,CAAA;AAElC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAyC;IAC5E,YAAY,OAAoB;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED;;;OAGG;IACO,WAAW;QACnB,MAAM,QAAQ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AAK,CAAC,CAAC,CAAA;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,2DAA2D;IAC3D,WAAW;QACT,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACjD,CAAC;IAED,+DAA+D;IAC/D,cAAc;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,sBAAsB,EAAE,CAAC,CAAA;IACpD,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,IAAY;QACvB,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,IAAY;QACzB,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAA;QACzD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,CAAc;IAClC,OAAO,IAAI,eAAe,CAAC,CAAC,CAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":""}
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAEhC,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface BaselineArgs {
|
|
2
|
+
ruleFiles: string[];
|
|
3
|
+
output: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Generate a baseline file from current rule violations.
|
|
7
|
+
*
|
|
8
|
+
* Wraps existing APIs: collectViolations + generateBaseline.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runBaseline(args: BaselineArgs): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=baseline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/baseline.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { collectViolations } from '@nielspeter/eess';
|
|
2
|
+
import { generateBaseline } from '@nielspeter/eess';
|
|
3
|
+
import { loadRuleFiles } from '../load-rules.js';
|
|
4
|
+
/**
|
|
5
|
+
* Generate a baseline file from current rule violations.
|
|
6
|
+
*
|
|
7
|
+
* Wraps existing APIs: collectViolations + generateBaseline.
|
|
8
|
+
*/
|
|
9
|
+
export async function runBaseline(args) {
|
|
10
|
+
const builders = await loadRuleFiles(args.ruleFiles);
|
|
11
|
+
const violations = collectViolations(...builders);
|
|
12
|
+
generateBaseline(violations, args.output);
|
|
13
|
+
process.stdout.write(`Baseline generated: ${String(violations.length)} violations recorded\n`);
|
|
14
|
+
process.stdout.write(`Written to: ${args.output}\n`);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../../src/cli/commands/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAQhD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAkB;IAClD,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACpD,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAA;IAEjD,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAEzC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAA;IAC9F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OutputFormat } from '@nielspeter/eess';
|
|
2
|
+
export interface CheckArgs {
|
|
3
|
+
ruleFiles: string[];
|
|
4
|
+
baseline?: string;
|
|
5
|
+
changed: boolean;
|
|
6
|
+
base: string;
|
|
7
|
+
format: OutputFormat | 'auto';
|
|
8
|
+
/** Use cache-busting imports for watch mode re-runs. */
|
|
9
|
+
fresh?: boolean;
|
|
10
|
+
/** Apply deterministic fixes instead of only reporting (plan 0066). */
|
|
11
|
+
fix?: boolean;
|
|
12
|
+
/** With `fix`, write to disk; otherwise dry-run (preview). */
|
|
13
|
+
apply?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Run architecture rules from the specified rule files.
|
|
17
|
+
*
|
|
18
|
+
* Wraps existing programmatic APIs: withBaseline, diffAware, detectFormat.
|
|
19
|
+
*/
|
|
20
|
+
export declare function runCheck(args: CheckArgs): Promise<number>;
|
|
21
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAiB,MAAM,kBAAkB,CAAA;AAKjF,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,YAAY,GAAG,MAAM,CAAA;IAC7B,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,uEAAuE;IACvE,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAgD/D"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { detectFormat, applyFixes } from '@nielspeter/eess';
|
|
2
|
+
import { withBaseline } from '@nielspeter/eess';
|
|
3
|
+
import { diffAware } from '@nielspeter/eess';
|
|
4
|
+
import { ArchRuleError } from '@nielspeter/eess';
|
|
5
|
+
import { loadRuleFiles } from '../load-rules.js';
|
|
6
|
+
/**
|
|
7
|
+
* Run architecture rules from the specified rule files.
|
|
8
|
+
*
|
|
9
|
+
* Wraps existing programmatic APIs: withBaseline, diffAware, detectFormat.
|
|
10
|
+
*/
|
|
11
|
+
export async function runCheck(args) {
|
|
12
|
+
const started = Date.now();
|
|
13
|
+
const format = args.format === 'auto' ? detectFormat() : args.format;
|
|
14
|
+
const options = { format };
|
|
15
|
+
if (args.baseline !== undefined) {
|
|
16
|
+
options.baseline = withBaseline(args.baseline);
|
|
17
|
+
}
|
|
18
|
+
if (args.changed) {
|
|
19
|
+
options.diff = diffAware(args.base);
|
|
20
|
+
}
|
|
21
|
+
const builders = await loadRuleFiles(args.ruleFiles, { fresh: args.fresh });
|
|
22
|
+
if (args.fix === true) {
|
|
23
|
+
return runFix(builders, options, args.apply === true);
|
|
24
|
+
}
|
|
25
|
+
let failures = 0;
|
|
26
|
+
for (const builder of builders) {
|
|
27
|
+
try {
|
|
28
|
+
builder.check(options);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof ArchRuleError) {
|
|
32
|
+
failures++;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Report the denominator so a fast green is provably non-vacuous, not silence.
|
|
40
|
+
// Terminal only — JSON/GitHub-annotation output on stdout stays machine-clean.
|
|
41
|
+
if (format === 'terminal') {
|
|
42
|
+
const ms = Date.now() - started;
|
|
43
|
+
const time = ms < 1000 ? `${ms}ms` : `${(ms / 1000).toFixed(2)}s`;
|
|
44
|
+
const rules = builders.length;
|
|
45
|
+
const files = args.ruleFiles.length;
|
|
46
|
+
const scope = `${rules} rule${rules === 1 ? '' : 's'} across ${files} file${files === 1 ? '' : 's'}`;
|
|
47
|
+
process.stderr.write(failures === 0
|
|
48
|
+
? `\n✓ eess-ts — ${scope} · 0 failing (${time})\n`
|
|
49
|
+
: `\n✗ eess-ts — ${failures} of ${scope} failing (${time})\n`);
|
|
50
|
+
}
|
|
51
|
+
return failures;
|
|
52
|
+
}
|
|
53
|
+
/** Collect a builder's violations without printing (prefers `.violations()`). */
|
|
54
|
+
function collectViolations(builder, options) {
|
|
55
|
+
if (typeof builder.violations === 'function')
|
|
56
|
+
return builder.violations();
|
|
57
|
+
try {
|
|
58
|
+
builder.check(options);
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error instanceof ArchRuleError)
|
|
63
|
+
return error.violations;
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Apply deterministic fixes (plan 0066). Dry-run unless `write`. Returns the
|
|
69
|
+
* count of violations that have no automatic fix (the real remaining failures).
|
|
70
|
+
*/
|
|
71
|
+
function runFix(builders, options, write) {
|
|
72
|
+
const all = builders.flatMap((b) => collectViolations(b, options));
|
|
73
|
+
const fixable = all.filter((v) => v.fix !== undefined);
|
|
74
|
+
const result = applyFixes(fixable, { write });
|
|
75
|
+
const header = write
|
|
76
|
+
? 'eess-ts --fix (applied)'
|
|
77
|
+
: 'eess-ts --fix (dry run — pass --apply to write)';
|
|
78
|
+
process.stdout.write(`${header}\n`);
|
|
79
|
+
for (const d of result.descriptions)
|
|
80
|
+
process.stdout.write(` ${write ? 'fixed' : 'would fix'}: ${d}\n`);
|
|
81
|
+
if (result.skipped > 0) {
|
|
82
|
+
process.stdout.write(` ${result.skipped} fix(es) skipped (overlapping — resolve manually)\n`);
|
|
83
|
+
}
|
|
84
|
+
const verb = write ? 'applied' : 'would apply';
|
|
85
|
+
process.stdout.write(`${result.applied} fix(es) ${verb} across ${result.files.length} file(s)\n`);
|
|
86
|
+
const remaining = all.filter((v) => v.fix === undefined);
|
|
87
|
+
if (remaining.length > 0) {
|
|
88
|
+
process.stdout.write(`${remaining.length} violation(s) with no automatic fix remain:\n`);
|
|
89
|
+
for (const v of remaining)
|
|
90
|
+
process.stdout.write(` ${v.file}:${v.line} ${v.message.split('\n')[0]}\n`);
|
|
91
|
+
}
|
|
92
|
+
return remaining.length;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[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