@md-code/follow-architecture 0.1.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/LICENSE +202 -0
- package/README.md +1420 -139
- package/dist/aliases.d.ts +3 -0
- package/dist/aliases.js +12 -0
- package/dist/args.d.ts +18 -0
- package/dist/args.js +94 -0
- package/dist/bin/follow-architecture.d.ts +2 -0
- package/dist/bin/follow-architecture.js +23 -0
- package/dist/closure-project.d.ts +4 -0
- package/dist/closure-project.js +132 -0
- package/dist/code-entities/classify.d.ts +11 -0
- package/dist/code-entities/classify.js +45 -0
- package/dist/code-entities/connector.d.ts +8 -0
- package/dist/code-entities/connector.js +119 -0
- package/dist/code-entities/entities.d.ts +9 -0
- package/dist/code-entities/entities.js +227 -0
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +259 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +105 -0
- package/dist/config-options.d.ts +76 -0
- package/dist/config-options.js +52 -0
- package/dist/config-project.d.ts +4 -0
- package/dist/config-project.js +92 -0
- package/dist/config-report.d.ts +19 -0
- package/dist/config-report.js +161 -0
- package/dist/config-rule.d.ts +95 -0
- package/dist/config-rule.js +211 -0
- package/dist/config-state.d.ts +25 -0
- package/dist/config-state.js +269 -0
- package/dist/config.d.ts +107 -0
- package/dist/config.js +38 -0
- package/dist/css/index.d.ts +31 -0
- package/dist/css/index.js +251 -0
- package/dist/css/syntax/css/gate.d.ts +2 -0
- package/dist/css/syntax/css/gate.js +69 -0
- package/dist/css/syntax/css/index.d.ts +7 -0
- package/dist/css/syntax/css/index.js +51 -0
- package/dist/css/syntax/css/reference.d.ts +3 -0
- package/dist/css/syntax/css/reference.js +36 -0
- package/dist/css/syntax/language.d.ts +25 -0
- package/dist/css/syntax/language.js +81 -0
- package/dist/css/syntax/scss/index.d.ts +25 -0
- package/dist/css/syntax/scss/index.js +95 -0
- package/dist/css/syntax/scss/reference.d.ts +3 -0
- package/dist/css/syntax/scss/reference.js +17 -0
- package/dist/css/syntax/styled/document.d.ts +68 -0
- package/dist/css/syntax/styled/document.js +261 -0
- package/dist/css/syntax/styled/markup.d.ts +6 -0
- package/dist/css/syntax/styled/markup.js +84 -0
- package/dist/css/syntax/styled/tags.d.ts +2 -0
- package/dist/css/syntax/styled/tags.js +22 -0
- package/dist/css/syntax/styled/template.d.ts +23 -0
- package/dist/css/syntax/styled/template.js +67 -0
- package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
- package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
- package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
- package/dist/css/syntax/tailwind/tailwind.js +118 -0
- package/dist/css/value/check.d.ts +86 -0
- package/dist/css/value/check.js +122 -0
- package/dist/css/value/expression/arithmetic.d.ts +7 -0
- package/dist/css/value/expression/arithmetic.js +73 -0
- package/dist/css/value/expression/block.d.ts +9 -0
- package/dist/css/value/expression/block.js +92 -0
- package/dist/css/value/expression/conditional.d.ts +8 -0
- package/dist/css/value/expression/conditional.js +53 -0
- package/dist/css/value/expression/index.d.ts +5 -0
- package/dist/css/value/expression/index.js +73 -0
- package/dist/css/value/expression/map.d.ts +7 -0
- package/dist/css/value/expression/map.js +113 -0
- package/dist/css/value/object/index.d.ts +5 -0
- package/dist/css/value/object/index.js +113 -0
- package/dist/css/value/object/members.d.ts +7 -0
- package/dist/css/value/object/members.js +103 -0
- package/dist/css/value/object/node.d.ts +8 -0
- package/dist/css/value/object/node.js +134 -0
- package/dist/css/value/object/path.d.ts +10 -0
- package/dist/css/value/object/path.js +152 -0
- package/dist/css/value/pieces.d.ts +61 -0
- package/dist/css/value/pieces.js +65 -0
- package/dist/css/value/resolve.d.ts +33 -0
- package/dist/css/value/resolve.js +104 -0
- package/dist/css/value/scope.d.ts +28 -0
- package/dist/css/value/scope.js +205 -0
- package/dist/css/value/substitute.d.ts +10 -0
- package/dist/css/value/substitute.js +145 -0
- package/dist/css/value/values.d.ts +23 -0
- package/dist/css/value/values.js +131 -0
- package/dist/entities/architecture.d.ts +165 -0
- package/dist/entities/architecture.js +2 -0
- package/dist/entities/ast/assignments-nodes.d.ts +10 -0
- package/dist/entities/ast/assignments-nodes.js +64 -0
- package/dist/entities/ast/assignments-raw.d.ts +6 -0
- package/dist/entities/ast/assignments-raw.js +139 -0
- package/dist/entities/ast/assignments-tagged.d.ts +5 -0
- package/dist/entities/ast/assignments-tagged.js +195 -0
- package/dist/entities/ast/assignments.d.ts +9 -0
- package/dist/entities/ast/assignments.js +80 -0
- package/dist/entities/ast/branches.d.ts +4 -0
- package/dist/entities/ast/branches.js +32 -0
- package/dist/entities/ast/calls.d.ts +6 -0
- package/dist/entities/ast/calls.js +150 -0
- package/dist/entities/ast/classes.d.ts +5 -0
- package/dist/entities/ast/classes.js +61 -0
- package/dist/entities/ast/climb.d.ts +12 -0
- package/dist/entities/ast/climb.js +17 -0
- package/dist/entities/ast/comments.d.ts +5 -0
- package/dist/entities/ast/comments.js +130 -0
- package/dist/entities/ast/declaration.d.ts +4 -0
- package/dist/entities/ast/declaration.js +26 -0
- package/dist/entities/ast/depth.d.ts +17 -0
- package/dist/entities/ast/depth.js +166 -0
- package/dist/entities/ast/enums.d.ts +6 -0
- package/dist/entities/ast/enums.js +17 -0
- package/dist/entities/ast/export-chain.d.ts +15 -0
- package/dist/entities/ast/export-chain.js +171 -0
- package/dist/entities/ast/file-exports.d.ts +7 -0
- package/dist/entities/ast/file-exports.js +101 -0
- package/dist/entities/ast/file-facts.d.ts +16 -0
- package/dist/entities/ast/file-facts.js +64 -0
- package/dist/entities/ast/file-imports.d.ts +5 -0
- package/dist/entities/ast/file-imports.js +100 -0
- package/dist/entities/ast/file.d.ts +5 -0
- package/dist/entities/ast/file.js +23 -0
- package/dist/entities/ast/functions.d.ts +8 -0
- package/dist/entities/ast/functions.js +111 -0
- package/dist/entities/ast/heritage.d.ts +4 -0
- package/dist/entities/ast/heritage.js +44 -0
- package/dist/entities/ast/index.d.ts +9 -0
- package/dist/entities/ast/index.js +181 -0
- package/dist/entities/ast/kind.d.ts +5 -0
- package/dist/entities/ast/kind.js +34 -0
- package/dist/entities/ast/loose.d.ts +37 -0
- package/dist/entities/ast/loose.js +2 -0
- package/dist/entities/ast/modifiers.d.ts +5 -0
- package/dist/entities/ast/modifiers.js +32 -0
- package/dist/entities/ast/project.d.ts +9 -0
- package/dist/entities/ast/project.js +106 -0
- package/dist/entities/ast/properties.d.ts +11 -0
- package/dist/entities/ast/properties.js +176 -0
- package/dist/entities/ast/resolve.d.ts +16 -0
- package/dist/entities/ast/resolve.js +317 -0
- package/dist/entities/ast/tree.d.ts +31 -0
- package/dist/entities/ast/tree.js +518 -0
- package/dist/entities/ast/types.d.ts +6 -0
- package/dist/entities/ast/types.js +46 -0
- package/dist/entities/ast/usage.d.ts +11 -0
- package/dist/entities/ast/usage.js +81 -0
- package/dist/entities/ast/variables.d.ts +8 -0
- package/dist/entities/ast/variables.js +91 -0
- package/dist/entities/context.d.ts +29 -0
- package/dist/entities/context.js +2 -0
- package/dist/entities/facts.d.ts +284 -0
- package/dist/entities/facts.js +2 -0
- package/dist/entities/findings.d.ts +19 -0
- package/dist/entities/findings.js +2 -0
- package/dist/entities/kinds.d.ts +40 -0
- package/dist/entities/kinds.js +332 -0
- package/dist/entities/location/homes.d.ts +28 -0
- package/dist/entities/location/homes.js +195 -0
- package/dist/entities/location/place.d.ts +10 -0
- package/dist/entities/location/place.js +63 -0
- package/dist/entities/location/where.d.ts +19 -0
- package/dist/entities/location/where.js +277 -0
- package/dist/entities/location.d.ts +16 -0
- package/dist/entities/location.js +140 -0
- package/dist/entities/operators.d.ts +14 -0
- package/dist/entities/operators.js +30 -0
- package/dist/entities/overview/data.d.ts +43 -0
- package/dist/entities/overview/data.js +2 -0
- package/dist/entities/overview/decision.d.ts +60 -0
- package/dist/entities/overview/decision.js +2 -0
- package/dist/entities/overview/file-tree.d.ts +10 -0
- package/dist/entities/overview/file-tree.js +2 -0
- package/dist/entities/overview/finding.d.ts +58 -0
- package/dist/entities/overview/finding.js +2 -0
- package/dist/entities/overview/graph.d.ts +82 -0
- package/dist/entities/overview/graph.js +2 -0
- package/dist/entities/overview/input.d.ts +15 -0
- package/dist/entities/overview/input.js +2 -0
- package/dist/entities/overview/summaries.d.ts +81 -0
- package/dist/entities/overview/summaries.js +2 -0
- package/dist/entities/place.d.ts +5 -0
- package/dist/entities/place.js +2 -0
- package/dist/entities/queries.d.ts +9 -0
- package/dist/entities/queries.js +375 -0
- package/dist/entities/repair.d.ts +16 -0
- package/dist/entities/repair.js +29 -0
- package/dist/entities/schema.d.ts +22 -0
- package/dist/entities/schema.js +81 -0
- package/dist/entities/story.d.ts +47 -0
- package/dist/entities/story.js +2 -0
- package/dist/entities/structure-facts.d.ts +11 -0
- package/dist/entities/structure-facts.js +2 -0
- package/dist/entities/token.d.ts +23 -0
- package/dist/entities/token.js +2 -0
- package/dist/entities/tree/build.d.ts +6 -0
- package/dist/entities/tree/build.js +313 -0
- package/dist/entities/tree/entries.d.ts +7 -0
- package/dist/entities/tree/entries.js +145 -0
- package/dist/entities/tree/index.d.ts +6 -0
- package/dist/entities/tree/index.js +21 -0
- package/dist/entities/tree/match.d.ts +17 -0
- package/dist/entities/tree/match.js +190 -0
- package/dist/fa-index.d.ts +16 -0
- package/dist/fa-index.js +165 -0
- package/dist/fa-open.d.ts +51 -0
- package/dist/fa-open.js +242 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +232 -0
- package/dist/fa-values.d.ts +37 -0
- package/dist/fa-values.js +104 -0
- package/dist/facts-record.d.ts +45 -0
- package/dist/facts-record.js +297 -0
- package/dist/frameworks/angular/index.d.ts +7 -0
- package/dist/frameworks/angular/index.js +18 -0
- package/dist/frameworks/facet.d.ts +18 -0
- package/dist/frameworks/facet.js +15 -0
- package/dist/frameworks/index.d.ts +9 -0
- package/dist/frameworks/index.js +134 -0
- package/dist/frameworks/react/index.d.ts +7 -0
- package/dist/frameworks/react/index.js +237 -0
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +7 -0
- package/dist/frameworks/vue/index.js +18 -0
- package/dist/ignore.d.ts +3 -0
- package/dist/ignore.js +62 -0
- package/dist/index-file.d.ts +43 -0
- package/dist/index-file.js +218 -0
- package/dist/index-run.d.ts +39 -0
- package/dist/index-run.js +217 -0
- package/dist/index-zone.d.ts +25 -0
- package/dist/index-zone.js +219 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.js +411 -0
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +25 -0
- package/dist/nodes/children.js +165 -0
- package/dist/nodes/finally/emit.d.ts +6 -0
- package/dist/nodes/finally/emit.js +71 -0
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -0
- package/dist/nodes/finally/index.d.ts +8 -0
- package/dist/nodes/finally/index.js +35 -0
- package/dist/nodes/finally/queries.d.ts +5 -0
- package/dist/nodes/finally/queries.js +25 -0
- package/dist/nodes/finally/relations-access.d.ts +5 -0
- package/dist/nodes/finally/relations-access.js +50 -0
- package/dist/nodes/finally/relations-edge.d.ts +29 -0
- package/dist/nodes/finally/relations-edge.js +148 -0
- package/dist/nodes/finally/relations-group.d.ts +31 -0
- package/dist/nodes/finally/relations-group.js +106 -0
- package/dist/nodes/finally/relations.d.ts +5 -0
- package/dist/nodes/finally/relations.js +85 -0
- package/dist/nodes/finally/required.d.ts +5 -0
- package/dist/nodes/finally/required.js +92 -0
- package/dist/nodes/finally/violation.d.ts +17 -0
- package/dist/nodes/finally/violation.js +2 -0
- package/dist/nodes/similar.d.ts +21 -0
- package/dist/nodes/similar.js +178 -0
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/pipeline-entities.d.ts +6 -0
- package/dist/pipeline-entities.js +79 -0
- package/dist/pipeline-facts.d.ts +12 -0
- package/dist/pipeline-facts.js +114 -0
- package/dist/pipeline-unclassified.d.ts +14 -0
- package/dist/pipeline-unclassified.js +188 -0
- package/dist/pipeline.d.ts +7 -0
- package/dist/pipeline.js +28 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +3 -0
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +55 -0
- package/dist/report/asks.js +60 -0
- package/dist/report/cli-report.d.ts +2 -0
- package/dist/report/cli-report.js +13 -0
- package/dist/report/config-error-guard.d.ts +8 -0
- package/dist/report/config-error-guard.js +5 -0
- package/dist/report/configErrors.d.ts +126 -0
- package/dist/report/configErrors.js +121 -0
- package/dist/report/errorTypes/codes/structure.d.ts +15 -0
- package/dist/report/errorTypes/codes/structure.js +76 -0
- package/dist/report/errorTypes/decision-maker.d.ts +23 -0
- package/dist/report/errorTypes/decision-maker.js +109 -0
- package/dist/report/errorTypes/destinations.d.ts +38 -0
- package/dist/report/errorTypes/destinations.js +165 -0
- package/dist/report/errorTypes/finding-type.d.ts +11 -0
- package/dist/report/errorTypes/finding-type.js +2 -0
- package/dist/report/errorTypes/index.d.ts +15 -0
- package/dist/report/errorTypes/index.js +55 -0
- package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
- package/dist/report/errorTypes/types/fileContents.js +40 -0
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/unknownEntity.js +27 -0
- package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
- package/dist/report/errorTypes/types/wrongAction.js +140 -0
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
- package/dist/report/errorTypes/types/wrongPlacement.js +67 -0
- package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
- package/dist/report/errorTypes/vocabulary/ids.js +16 -0
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
- package/dist/report/errorTypes/vocabulary/phrases.js +187 -0
- package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
- package/dist/report/errorTypes/vocabulary/places.js +36 -0
- package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
- package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
- package/dist/report/finding-from.d.ts +9 -0
- package/dist/report/finding-from.js +108 -0
- package/dist/report/notices.d.ts +9 -0
- package/dist/report/notices.js +57 -0
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +12 -0
- package/dist/report/render-report.js +145 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +188 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +1262 -0
- package/dist/report/user-report/data/collect.d.ts +4 -0
- package/dist/report/user-report/data/collect.js +93 -0
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/entities.js +88 -0
- package/dist/report/user-report/data/entity-examples.d.ts +16 -0
- package/dist/report/user-report/data/entity-examples.js +136 -0
- package/dist/report/user-report/data/entity-filters.d.ts +15 -0
- package/dist/report/user-report/data/entity-filters.js +79 -0
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/entity-marks.js +79 -0
- package/dist/report/user-report/data/file-tree.d.ts +9 -0
- package/dist/report/user-report/data/file-tree.js +80 -0
- package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
- package/dist/report/user-report/data/finding-boundary.js +21 -0
- package/dist/report/user-report/data/finding-plan.d.ts +16 -0
- package/dist/report/user-report/data/finding-plan.js +45 -0
- package/dist/report/user-report/data/finding-title.d.ts +12 -0
- package/dist/report/user-report/data/finding-title.js +36 -0
- package/dist/report/user-report/data/findings.d.ts +10 -0
- package/dist/report/user-report/data/findings.js +181 -0
- package/dist/report/user-report/data/graph-edges.d.ts +19 -0
- package/dist/report/user-report/data/graph-edges.js +109 -0
- package/dist/report/user-report/data/graph-entities.d.ts +6 -0
- package/dist/report/user-report/data/graph-entities.js +158 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
- package/dist/report/user-report/data/graph-helpers.js +67 -0
- package/dist/report/user-report/data/graph.d.ts +12 -0
- package/dist/report/user-report/data/graph.js +97 -0
- package/dist/report/user-report/data/nodes.d.ts +11 -0
- package/dist/report/user-report/data/nodes.js +116 -0
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/rules.js +62 -0
- package/dist/report/user-report/data/scan.d.ts +8 -0
- package/dist/report/user-report/data/scan.js +69 -0
- package/dist/report/user-report/html/shell.d.ts +3 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +8 -0
- package/dist/report/user-report/index.js +58 -0
- package/dist/report/user-report/shared/describe.d.ts +7 -0
- package/dist/report/user-report/shared/describe.js +86 -0
- package/dist/rules/index.d.ts +7 -0
- package/dist/rules/index.js +327 -0
- package/dist/rules/list-vars.d.ts +5 -0
- package/dist/rules/list-vars.js +149 -0
- package/dist/rules/name.d.ts +16 -0
- package/dist/rules/name.js +18 -0
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/rules/normalize.js +108 -0
- package/dist/rules/vars.d.ts +22 -0
- package/dist/rules/vars.js +117 -0
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.d.ts +2 -0
- package/dist/scripts/audit-report.js +157 -0
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +282 -0
- package/dist/usage-mode.d.ts +7 -0
- package/dist/usage-mode.js +16 -0
- package/dist/usage-pass.d.ts +19 -0
- package/dist/usage-pass.js +136 -0
- package/dist/usage-prepare.d.ts +2 -0
- package/dist/usage-prepare.js +22 -0
- package/dist/usage-sweep.d.ts +10 -0
- package/dist/usage-sweep.js +264 -0
- package/dist/utils/accumulate.d.ts +6 -0
- package/dist/utils/accumulate.js +18 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +173 -0
- package/dist/utils/article.d.ts +2 -0
- package/dist/utils/article.js +12 -0
- package/dist/utils/classify.d.ts +12 -0
- package/dist/utils/classify.js +25 -0
- package/dist/utils/configs.d.ts +25 -0
- package/dist/utils/configs.js +97 -0
- package/dist/utils/count.d.ts +7 -0
- package/dist/utils/count.js +13 -0
- package/dist/utils/dispatch.d.ts +2 -0
- package/dist/utils/dispatch.js +27 -0
- package/dist/utils/distinct.d.ts +2 -0
- package/dist/utils/distinct.js +14 -0
- package/dist/utils/field.d.ts +14 -0
- package/dist/utils/field.js +60 -0
- package/dist/utils/file-name.d.ts +2 -0
- package/dist/utils/file-name.js +11 -0
- package/dist/utils/files.d.ts +7 -0
- package/dist/utils/files.js +77 -0
- package/dist/utils/fixpoint.d.ts +2 -0
- package/dist/utils/fixpoint.js +19 -0
- package/dist/utils/gate.d.ts +2 -0
- package/dist/utils/gate.js +12 -0
- package/dist/utils/group.d.ts +3 -0
- package/dist/utils/group.js +33 -0
- package/dist/utils/host.d.ts +3 -0
- package/dist/utils/host.js +16 -0
- package/dist/utils/imports.d.ts +12 -0
- package/dist/utils/imports.js +185 -0
- package/dist/utils/judged.d.ts +5 -0
- package/dist/utils/judged.js +19 -0
- package/dist/utils/keyed.d.ts +2 -0
- package/dist/utils/keyed.js +23 -0
- package/dist/utils/map-record.d.ts +2 -0
- package/dist/utils/map-record.js +11 -0
- package/dist/utils/packages.d.ts +15 -0
- package/dist/utils/packages.js +207 -0
- package/dist/utils/path-label.d.ts +6 -0
- package/dist/utils/path-label.js +37 -0
- package/dist/utils/pattern.d.ts +19 -0
- package/dist/utils/pattern.js +231 -0
- package/dist/utils/permission.d.ts +16 -0
- package/dist/utils/permission.js +18 -0
- package/dist/utils/plural.d.ts +2 -0
- package/dist/utils/plural.js +9 -0
- package/dist/utils/qualified.d.ts +2 -0
- package/dist/utils/qualified.js +21 -0
- package/dist/utils/rank.d.ts +2 -0
- package/dist/utils/rank.js +24 -0
- package/dist/utils/read-field.d.ts +12 -0
- package/dist/utils/read-field.js +50 -0
- package/dist/utils/read-when.d.ts +2 -0
- package/dist/utils/read-when.js +17 -0
- package/dist/utils/reason.d.ts +4 -0
- package/dist/utils/reason.js +9 -0
- package/dist/utils/record.d.ts +3 -0
- package/dist/utils/record.js +21 -0
- package/dist/utils/resolve.d.ts +2 -0
- package/dist/utils/resolve.js +24 -0
- package/dist/utils/search.d.ts +2 -0
- package/dist/utils/search.js +21 -0
- package/dist/utils/seen.d.ts +6 -0
- package/dist/utils/seen.js +27 -0
- package/dist/utils/span.d.ts +5 -0
- package/dist/utils/span.js +2 -0
- package/dist/utils/speak.d.ts +2 -0
- package/dist/utils/speak.js +18 -0
- package/dist/utils/split.d.ts +8 -0
- package/dist/utils/split.js +21 -0
- package/dist/utils/template.d.ts +5 -0
- package/dist/utils/template.js +5 -0
- package/dist/utils/text.d.ts +4 -0
- package/dist/utils/text.js +42 -0
- package/dist/utils/tokenize.d.ts +2 -0
- package/dist/utils/tokenize.js +18 -0
- package/dist/utils/try-read.d.ts +4 -0
- package/dist/utils/try-read.js +24 -0
- package/dist/utils/typed-field.d.ts +3 -0
- package/dist/utils/typed-field.js +16 -0
- package/dist/utils/verdicts.d.ts +4 -0
- package/dist/utils/verdicts.js +20 -0
- package/entities/operators.ts +31 -0
- package/package.json +101 -47
- package/report/errorTypes/vocabulary/ids.ts +17 -0
- package/report/errorTypes/vocabulary/phrases.ts +181 -0
- package/report/errorTypes/vocabulary/places.ts +51 -0
- package/report/errorTypes/vocabulary/verbs.ts +31 -0
- package/report/user-report/shared/describe.ts +107 -0
- package/ast.js +0 -107
- package/bin/follow-architecture.js +0 -6
- package/config.js +0 -101
- package/entities/aliases.js +0 -10
- package/entities/invariants.js +0 -134
- package/entities/nodes.js +0 -112
- package/main.js +0 -96
- package/plugin.js +0 -5
- package/report.js +0 -73
- package/utils.js +0 -104
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrich = exports.classAttributes = exports.applies = exports.id = void 0;
|
|
4
|
+
// React: what a component RENDERS and what it HANDS DOWN.
|
|
5
|
+
//
|
|
6
|
+
// The engine sees JSX as syntax; this facet turns it into facts a rule can ask
|
|
7
|
+
// about:
|
|
8
|
+
// jsx every element the component itself renders (nearest enclosing
|
|
9
|
+
// function is the component, so a nested component's markup is its
|
|
10
|
+
// own), with the attributes and the spreads it passes
|
|
11
|
+
// props the names the component RECEIVES (destructured params, or the
|
|
12
|
+
// parameter name when it takes the object whole)
|
|
13
|
+
// forwarded the received names that reappear on a child — `{...props}` counts
|
|
14
|
+
// as everything it received. This is props drilling as a NUMBER, so
|
|
15
|
+
// a rule says `gt: 3` or `gt: 10` without any engine change.
|
|
16
|
+
const ts_morph_1 = require("ts-morph");
|
|
17
|
+
const tree_1 = require("@md-code/follow-architecture/entities/ast/tree");
|
|
18
|
+
const climb_1 = require("@md-code/follow-architecture/entities/ast/climb");
|
|
19
|
+
const distinct_1 = require("@md-code/follow-architecture/utils/distinct");
|
|
20
|
+
const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
|
|
21
|
+
const id = "react";
|
|
22
|
+
exports.id = id;
|
|
23
|
+
// "Is this a function?" is asked of the SHAPE, not of a list of kind names: a
|
|
24
|
+
// function-like node has parameters and a body. Anything TypeScript calls a
|
|
25
|
+
// function answers yes, and nothing here has to be updated when it adds one.
|
|
26
|
+
// The capabilities are probed through the shared optional-shape view.
|
|
27
|
+
const isFunctionLike = (node) => typeof node.getParameters === "function" && typeof node.getBody === "function";
|
|
28
|
+
// A CANDIDATE carries facts, not a node: it is read as a function when the facts a
|
|
29
|
+
// function has are there (`parameters`, `returns`), which the AST module records
|
|
30
|
+
// only for function-shaped pieces.
|
|
31
|
+
const isFunctionCandidate = (candidate) => Array.isArray(candidate.parameters) && Array.isArray(candidate.returns);
|
|
32
|
+
// Where the code this candidate DECLARES starts rendering. A function is its own
|
|
33
|
+
// renderer, so its start line is the declaration's. A BINDING is judged by the
|
|
34
|
+
// function it is initialised WITH: a wrapped type annotation
|
|
35
|
+
// (`const X: FC<{\n…\n}> = (p) => …`) pushes the arrow onto a later line than the
|
|
36
|
+
// `const`, so the declaration's start line cannot be compared with the element's
|
|
37
|
+
// owner. The initializer is the TOPMOST function descendant (smallest depth) —
|
|
38
|
+
// nested callbacks and inner components sit deeper and are their own pieces.
|
|
39
|
+
const RENDER_FUNCTION_KINDS = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunction"]);
|
|
40
|
+
const renderStartLine = (candidate) => {
|
|
41
|
+
if (candidate.kind?.own?.is !== "VariableDeclaration")
|
|
42
|
+
return candidate.lines?.[0] ?? null;
|
|
43
|
+
const functions = (candidate.kind?.descendants ?? []).filter((descendant) => RENDER_FUNCTION_KINDS.has(String(descendant.is)));
|
|
44
|
+
const initialization = functions.reduce((top, descendant) => (top === null || (descendant.depth ?? 0) < (top.depth ?? 0) ? descendant : top), null);
|
|
45
|
+
return initialization?.line ?? null;
|
|
46
|
+
};
|
|
47
|
+
// The nearest function-like owner: the shared climb, with this facet's own
|
|
48
|
+
// holder test (the shape probe above).
|
|
49
|
+
const nearestFunction = (node) => {
|
|
50
|
+
const stop = (0, climb_1.climbFrom)(node, { isHolder: isFunctionLike });
|
|
51
|
+
return stop.found ? stop.node : null;
|
|
52
|
+
};
|
|
53
|
+
const openingOf = (element) => ts_morph_1.Node.isJsxElement(element) ? element.getOpeningElement() : element;
|
|
54
|
+
const tagOf = (element) => {
|
|
55
|
+
const tag = openingOf(element).getTagNameNode();
|
|
56
|
+
return tag ? String(tag.getText()) : null;
|
|
57
|
+
};
|
|
58
|
+
// `{a}` from `a={a}` — the value a child is handed, as written. The initializer's
|
|
59
|
+
// own text is the fact; a missing initializer is nothing handed.
|
|
60
|
+
const attributeValueText = (attribute) => {
|
|
61
|
+
const initializer = attribute.getInitializer();
|
|
62
|
+
if (!initializer)
|
|
63
|
+
return null;
|
|
64
|
+
return initializer.getText();
|
|
65
|
+
};
|
|
66
|
+
const elementFacts = (element) => {
|
|
67
|
+
const opening = openingOf(element);
|
|
68
|
+
const attributes = [];
|
|
69
|
+
const spreads = [];
|
|
70
|
+
for (const attribute of opening.getAttributes()) {
|
|
71
|
+
if (ts_morph_1.Node.isJsxSpreadAttribute(attribute)) {
|
|
72
|
+
spreads.push(String(attribute.getExpression().getText()));
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const name = attribute.getNameNode().getText();
|
|
76
|
+
attributes.push({ name: String(name), value: attributeValueText(attribute) });
|
|
77
|
+
}
|
|
78
|
+
return { tag: tagOf(element), line: element.getStartLineNumber(), attributes, spreads };
|
|
79
|
+
};
|
|
80
|
+
// One parameter's contribution: the destructured field names when it takes the
|
|
81
|
+
// object apart, the parameter's own name when it takes the object whole.
|
|
82
|
+
const namesOfParameter = (parameter) => {
|
|
83
|
+
if (Array.isArray(parameter.bindings) && parameter.bindings.length) {
|
|
84
|
+
return parameter.bindings.flatMap((binding) => (binding.name ? [String(binding.name)] : []));
|
|
85
|
+
}
|
|
86
|
+
return parameter.name ? [String(parameter.name)] : [];
|
|
87
|
+
};
|
|
88
|
+
// `{ props, item }` / `(props)` — what the component was given. The
|
|
89
|
+
// distinct-collect walk is the shared `distinctFlat` core.
|
|
90
|
+
const receivedOf = (candidate) => (0, distinct_1.distinctFlat)(candidate.parameters ?? [], namesOfParameter);
|
|
91
|
+
// Does a received prop's NAME appear in a value as a whole word (not as a member
|
|
92
|
+
// of something else, `props.title` does not forward `title`)? One reading, used
|
|
93
|
+
// for both attributes and spreads. The name is ESCAPED: a transient styled prop
|
|
94
|
+
// (`$isError`) is a legal name, and an unescaped `$` is a regex anchor.
|
|
95
|
+
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
96
|
+
const mentions = (value, name) => new RegExp(`(^|[^\\w$.])${escapeRegExp(name)}([^\\w$]|$)`).test(value);
|
|
97
|
+
// The received names an element's ATTRIBUTES mention, in attribute order.
|
|
98
|
+
const forwardedByAttributes = (element, received) => {
|
|
99
|
+
const names = [];
|
|
100
|
+
for (const attribute of element.attributes) {
|
|
101
|
+
const fromOwnProp = received.find((name) => mentions(attribute.value ?? "", name));
|
|
102
|
+
if (fromOwnProp)
|
|
103
|
+
names.push(fromOwnProp);
|
|
104
|
+
}
|
|
105
|
+
return names;
|
|
106
|
+
};
|
|
107
|
+
// The received names an element's SPREADS mention, in spread order.
|
|
108
|
+
// `{...props}` counts as everything it received.
|
|
109
|
+
const forwardedBySpreads = (element, received) => {
|
|
110
|
+
const names = [];
|
|
111
|
+
for (const spread of element.spreads) {
|
|
112
|
+
for (const name of received)
|
|
113
|
+
if (mentions(spread, name))
|
|
114
|
+
names.push(name);
|
|
115
|
+
}
|
|
116
|
+
return names;
|
|
117
|
+
};
|
|
118
|
+
// The received names a component hands down: through attributes first (in order),
|
|
119
|
+
// then through spreads. One dedup at the end keeps first-mention order.
|
|
120
|
+
const forwardedOf = (own, received) => {
|
|
121
|
+
const byAttributes = own.flatMap((element) => forwardedByAttributes(element, received));
|
|
122
|
+
const bySpreads = own.flatMap((element) => forwardedBySpreads(element, received));
|
|
123
|
+
return [...new Set([...byAttributes, ...bySpreads])];
|
|
124
|
+
};
|
|
125
|
+
// A rendered COMPONENT (not a host tag): the JSX convention is an upper-case
|
|
126
|
+
// identifier. A host tag (`div`, `span`) is a leaf — it renders nothing of ours.
|
|
127
|
+
const componentTag = (tag) => (tag && /^[A-Z][\w$]*$/.test(tag) ? tag : null);
|
|
128
|
+
// A local wrapper that hands the render to a component: `const Card = styled(Box)`
|
|
129
|
+
// / `memo(Box)` — the tag is the wrapper, the renderable component is its first
|
|
130
|
+
// identifier argument that names a piece in this file. One hop only; anything
|
|
131
|
+
// else is the wrapper itself.
|
|
132
|
+
const aliasTargetOf = (sf, tag, names) => {
|
|
133
|
+
const initializer = sf
|
|
134
|
+
.getVariableDeclarations()
|
|
135
|
+
.find((declaration) => declaration.getName() === tag)
|
|
136
|
+
?.getInitializer();
|
|
137
|
+
if (!initializer || !ts_morph_1.Node.isCallExpression(initializer))
|
|
138
|
+
return null;
|
|
139
|
+
const target = initializer
|
|
140
|
+
.getArguments()
|
|
141
|
+
.find((argument) => ts_morph_1.Node.isIdentifier(argument) && names.has(argument.getText()));
|
|
142
|
+
return target && ts_morph_1.Node.isIdentifier(target) ? target.getText() : null;
|
|
143
|
+
};
|
|
144
|
+
// The links the depth walk follows: every component this piece renders, and the
|
|
145
|
+
// module declaring it (null = this file). Imported names resolve through the
|
|
146
|
+
// import map; local components and one-hop wrappers stay in this file. This is
|
|
147
|
+
// the facet's answer — the depth walk itself names no framework.
|
|
148
|
+
const linksOf = (own, ctx, names) => {
|
|
149
|
+
const links = [];
|
|
150
|
+
for (const element of own) {
|
|
151
|
+
const tag = componentTag(element.tag);
|
|
152
|
+
if (!tag)
|
|
153
|
+
continue;
|
|
154
|
+
const module = ctx.importMap?.get(tag) ?? null;
|
|
155
|
+
if (module) {
|
|
156
|
+
links.push({ name: tag, module });
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (names.has(tag)) {
|
|
160
|
+
links.push({ name: tag, module: null });
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const alias = ctx.sf ? aliasTargetOf(ctx.sf, tag, names) : null;
|
|
164
|
+
if (alias)
|
|
165
|
+
links.push({ name: alias, module: null });
|
|
166
|
+
}
|
|
167
|
+
return links;
|
|
168
|
+
};
|
|
169
|
+
// The event attribute convention: `onClick`, `onChange`, `on*`. The value names
|
|
170
|
+
// the function the event runs — that function is the component's handler.
|
|
171
|
+
const EVENT_ATTRIBUTE = /^on[A-Z]/;
|
|
172
|
+
const IDENTIFIER = /[A-Za-z_$][\w$]*/g;
|
|
173
|
+
// The local names one event attribute references. A braced expression may name
|
|
174
|
+
// one or several (`onClick={busy ? stop : go}`); a name the file does not
|
|
175
|
+
// declare is not one of ours.
|
|
176
|
+
const namesInEvent = (attribute, names) => attribute.value
|
|
177
|
+
? [...attribute.value.matchAll(IDENTIFIER)].map((match) => match[0]).filter((name) => names.has(name))
|
|
178
|
+
: [];
|
|
179
|
+
const handlerNamesOf = (own, names) => {
|
|
180
|
+
const handlers = new Set();
|
|
181
|
+
for (const element of own) {
|
|
182
|
+
for (const attribute of element.attributes) {
|
|
183
|
+
if (!EVENT_ATTRIBUTE.test(attribute.name))
|
|
184
|
+
continue;
|
|
185
|
+
for (const name of namesInEvent(attribute, names))
|
|
186
|
+
handlers.add(name);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return handlers;
|
|
190
|
+
};
|
|
191
|
+
const elementsOf = (sf) => {
|
|
192
|
+
const elements = [
|
|
193
|
+
...sf.getDescendantsOfKind(tree_1.SK.JsxSelfClosingElement),
|
|
194
|
+
...sf.getDescendantsOfKind(tree_1.SK.JsxElement),
|
|
195
|
+
];
|
|
196
|
+
return elements
|
|
197
|
+
.map((element) => ({
|
|
198
|
+
pos: element.getStart(),
|
|
199
|
+
owner: nearestFunction(element)?.getStartLineNumber() ?? null,
|
|
200
|
+
facts: elementFacts(element),
|
|
201
|
+
}))
|
|
202
|
+
.filter((entry) => entry.facts.tag)
|
|
203
|
+
.sort((a, b) => a.pos - b.pos);
|
|
204
|
+
};
|
|
205
|
+
const enrich = (candidates, ctx) => {
|
|
206
|
+
const { sf } = ctx;
|
|
207
|
+
if (!sf)
|
|
208
|
+
return candidates;
|
|
209
|
+
const elements = elementsOf(sf);
|
|
210
|
+
const names = new Set(candidates.map((candidate) => candidate.name).filter((name) => Boolean(name)));
|
|
211
|
+
// A handler is named where the event is wired, once for the whole file.
|
|
212
|
+
const handlers = handlerNamesOf(elements.map((entry) => entry.facts), names);
|
|
213
|
+
for (const candidate of candidates) {
|
|
214
|
+
if (!isFunctionCandidate(candidate))
|
|
215
|
+
continue;
|
|
216
|
+
const startLine = renderStartLine(candidate);
|
|
217
|
+
const own = elements.filter((entry) => startLine !== null && entry.owner === startLine).map((entry) => entry.facts);
|
|
218
|
+
const received = receivedOf(candidate);
|
|
219
|
+
(0, facet_1.attach)(candidate, {
|
|
220
|
+
id,
|
|
221
|
+
component: own.length > 0,
|
|
222
|
+
jsx: own,
|
|
223
|
+
props: received,
|
|
224
|
+
forwarded: forwardedOf(own, received),
|
|
225
|
+
links: linksOf(own, ctx, names),
|
|
226
|
+
handler: candidate.name ? handlers.has(candidate.name) : false,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return candidates;
|
|
230
|
+
};
|
|
231
|
+
exports.enrich = enrich;
|
|
232
|
+
// Cheap gate: JSX only exists in these files, so a .ts helper pays nothing.
|
|
233
|
+
const applies = ({ rel, sf }) => /\.(tsx|jsx)$/i.test(String(rel ?? "")) || /<[A-Za-z]/.test(sf?.getFullText() ?? "");
|
|
234
|
+
exports.applies = applies;
|
|
235
|
+
// React's own spelling of the class attribute.
|
|
236
|
+
const classAttributes = ["className"];
|
|
237
|
+
exports.classAttributes = classAttributes;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
|
|
2
|
+
import type { Candidate } from "@md-code/follow-architecture/entities/facts";
|
|
3
|
+
declare const id = "test";
|
|
4
|
+
declare const enrich: (candidates: Candidate[], ctx: FacetContext) => Candidate[];
|
|
5
|
+
declare const applies: ({ sf }: FacetContext) => boolean;
|
|
6
|
+
export { id, applies, enrich };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrich = exports.applies = exports.id = void 0;
|
|
4
|
+
// Tests: what a file written for a test runner is.
|
|
5
|
+
//
|
|
6
|
+
// The engine sees `describe(...)`, `it(...)`, `expect(...)` as calls like any
|
|
7
|
+
// other; this facet reads them as a test file's facts, so an entity can be
|
|
8
|
+
// inferred from what the file DOES rather than from where it happens to live:
|
|
9
|
+
//
|
|
10
|
+
// runner the module the test API was imported from (`vitest` → "vitest",
|
|
11
|
+
// `@jest/globals` → "jest")
|
|
12
|
+
// cases `it`/`test` calls — the tests themselves
|
|
13
|
+
// asserts `expect` calls
|
|
14
|
+
// hooks the `before*`/`after*` hooks the file installs, by name
|
|
15
|
+
// snapshots `toMatchSnapshot`/`toMatchInlineSnapshot` calls
|
|
16
|
+
// mocks `vi.*`/`jest.*` mock calls
|
|
17
|
+
//
|
|
18
|
+
// A TYPE-only import is a TypeScript reading, not a test: `import type { Mock }
|
|
19
|
+
// from "vitest"` — or a `type` specifier — brings no runtime, so a file that only
|
|
20
|
+
// borrows a test type stays a plain module.
|
|
21
|
+
//
|
|
22
|
+
// The facts are the FILE's: a test file is a test file in every piece it declares,
|
|
23
|
+
// the same way the vue and angular gates attach their base to every candidate. The
|
|
24
|
+
// namespace is written through `attach`, so a component reading already on the
|
|
25
|
+
// candidate (a `.tsx` test that renders) keeps its id and its jsx — the test facts
|
|
26
|
+
// sit beside it instead of replacing them.
|
|
27
|
+
const ts_morph_1 = require("ts-morph");
|
|
28
|
+
const tree_1 = require("@md-code/follow-architecture/entities/ast/tree");
|
|
29
|
+
const properties_1 = require("@md-code/follow-architecture/entities/ast/properties");
|
|
30
|
+
const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
|
|
31
|
+
const id = "test";
|
|
32
|
+
exports.id = id;
|
|
33
|
+
// The modules a test runtime is imported FROM, and the id the fact carries. A
|
|
34
|
+
// reader's vocabulary, not the engine's: another runner is one entry here.
|
|
35
|
+
const RUNNERS = new Map([
|
|
36
|
+
["vitest", "vitest"],
|
|
37
|
+
["@jest/globals", "jest"],
|
|
38
|
+
]);
|
|
39
|
+
// Does the import bring a VALUE binding? A `type`-only declaration, or one whose
|
|
40
|
+
// every named specifier is `type`, is the type checker's business only.
|
|
41
|
+
const hasValueBinding = (declaration) => {
|
|
42
|
+
if (declaration.isTypeOnly())
|
|
43
|
+
return false;
|
|
44
|
+
const named = declaration.getNamedImports();
|
|
45
|
+
if (named.length === 0)
|
|
46
|
+
return true;
|
|
47
|
+
return named.some((specifier) => !specifier.isTypeOnly());
|
|
48
|
+
};
|
|
49
|
+
const runnerOf = (sf) => {
|
|
50
|
+
for (const declaration of sf.getImportDeclarations()) {
|
|
51
|
+
const runner = RUNNERS.get(declaration.getModuleSpecifierValue());
|
|
52
|
+
if (runner && hasValueBinding(declaration))
|
|
53
|
+
return runner;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
// The call NAMES a test file is written with — the runners' own vocabulary, so it
|
|
58
|
+
// lives here rather than in the engine. A name is read as its chain's ROOT
|
|
59
|
+
// (`it.each(…)` is a case, `expect(x).toMatchSnapshot()` is an assertion), and the
|
|
60
|
+
// terminal member is kept for the matchers.
|
|
61
|
+
const CASES = new Set(["it", "test"]);
|
|
62
|
+
const ASSERTS = new Set(["expect"]);
|
|
63
|
+
const HOOKS = new Set(["beforeAll", "beforeEach", "afterAll", "afterEach"]);
|
|
64
|
+
const SNAPSHOTS = new Set(["toMatchSnapshot", "toMatchInlineSnapshot"]);
|
|
65
|
+
const MOCKS = new Set([
|
|
66
|
+
"mock",
|
|
67
|
+
"doMock",
|
|
68
|
+
"unmock",
|
|
69
|
+
"doUnmock",
|
|
70
|
+
"fn",
|
|
71
|
+
"spyOn",
|
|
72
|
+
"stubGlobal",
|
|
73
|
+
"mocked",
|
|
74
|
+
"importActual",
|
|
75
|
+
"importMock",
|
|
76
|
+
]);
|
|
77
|
+
const MOCK_ROOTS = new Set(["vi", "jest"]);
|
|
78
|
+
// A chain is ONE call. `expect(x).toBe(y)` is a single assertion and its inner
|
|
79
|
+
// `expect(x)` is where that assertion begins — counting both would double every
|
|
80
|
+
// number the reader reports, so a call that is a chain's first link is skipped and
|
|
81
|
+
// the outermost call speaks for it.
|
|
82
|
+
const isChainStart = (call) => {
|
|
83
|
+
const parent = call.getParent();
|
|
84
|
+
if (!parent)
|
|
85
|
+
return false;
|
|
86
|
+
if (ts_morph_1.Node.isPropertyAccessExpression(parent) || ts_morph_1.Node.isElementAccessExpression(parent))
|
|
87
|
+
return parent.getExpression() === call;
|
|
88
|
+
if (ts_morph_1.Node.isCallExpression(parent))
|
|
89
|
+
return parent.getExpression() === call;
|
|
90
|
+
if (ts_morph_1.Node.isTaggedTemplateExpression(parent))
|
|
91
|
+
return parent.getTag() === call;
|
|
92
|
+
return false;
|
|
93
|
+
};
|
|
94
|
+
const rootOf = (expr) => {
|
|
95
|
+
const origin = (0, properties_1.leftmostOrigin)(expr);
|
|
96
|
+
return origin ? origin.split(".")[0] : null;
|
|
97
|
+
};
|
|
98
|
+
// One call, one bucket — the bucket its root names (`vi.mock` is a mock, `it` a
|
|
99
|
+
// case, `expect` an assertion). A chain speaks once: the outermost call is counted,
|
|
100
|
+
// the inner `expect(x)` is the same assertion beginning.
|
|
101
|
+
const tally = (target, counts, hooks) => {
|
|
102
|
+
const root = rootOf(target);
|
|
103
|
+
const member = (0, properties_1.lastMemberName)(target);
|
|
104
|
+
if (!root)
|
|
105
|
+
return;
|
|
106
|
+
if (CASES.has(root))
|
|
107
|
+
counts.cases += 1;
|
|
108
|
+
if (HOOKS.has(root))
|
|
109
|
+
hooks.add(root);
|
|
110
|
+
if (MOCK_ROOTS.has(root) && member !== null && MOCKS.has(member))
|
|
111
|
+
counts.mocks += 1;
|
|
112
|
+
if (!ASSERTS.has(root))
|
|
113
|
+
return;
|
|
114
|
+
// A snapshot match IS an assertion — counted as both, because the two questions
|
|
115
|
+
// a rule asks ("is anything asserted here?" and "does this file pin output?")
|
|
116
|
+
// have different answers.
|
|
117
|
+
counts.asserts += 1;
|
|
118
|
+
if (member !== null && SNAPSHOTS.has(member))
|
|
119
|
+
counts.snapshots += 1;
|
|
120
|
+
};
|
|
121
|
+
// What the file's calls say: one walk over the calls it makes.
|
|
122
|
+
const countsOf = (sf) => {
|
|
123
|
+
const counts = { cases: 0, asserts: 0, snapshots: 0, mocks: 0 };
|
|
124
|
+
const hooks = new Set();
|
|
125
|
+
for (const call of sf.getDescendantsOfKind(tree_1.SK.CallExpression)) {
|
|
126
|
+
if (!isChainStart(call))
|
|
127
|
+
tally(call.getExpression(), counts, hooks);
|
|
128
|
+
}
|
|
129
|
+
return { ...counts, hooks: [...hooks] };
|
|
130
|
+
};
|
|
131
|
+
// The file's test facts — or nothing at all. A file with no test runtime and no
|
|
132
|
+
// test call is not a test file, so it gets no `framework.test` (an absent fact is
|
|
133
|
+
// never a false one).
|
|
134
|
+
const testFactsOf = (sf) => {
|
|
135
|
+
const runner = runnerOf(sf);
|
|
136
|
+
const counts = countsOf(sf);
|
|
137
|
+
if (!runner && !counts.cases && !counts.asserts)
|
|
138
|
+
return null;
|
|
139
|
+
return { runner, ...counts };
|
|
140
|
+
};
|
|
141
|
+
const enrich = (candidates, ctx) => {
|
|
142
|
+
const test = ctx.sf ? testFactsOf(ctx.sf) : null;
|
|
143
|
+
if (!test)
|
|
144
|
+
return candidates;
|
|
145
|
+
for (const candidate of candidates) {
|
|
146
|
+
// The component readers own `id` where they spoke; the test reader names the
|
|
147
|
+
// file only where nobody else did.
|
|
148
|
+
(0, facet_1.attach)(candidate, { id: candidate.framework?.id ?? id, test });
|
|
149
|
+
}
|
|
150
|
+
return candidates;
|
|
151
|
+
};
|
|
152
|
+
exports.enrich = enrich;
|
|
153
|
+
// Cheap gate: a test runtime imported, or a call spelled like a test API (the
|
|
154
|
+
// globals-only flavour — a jest file that imports nothing). A .ts helper pays a
|
|
155
|
+
// text scan and, when it calls nothing test-shaped, one import read.
|
|
156
|
+
const applies = ({ sf }) => Boolean(sf) && (runnerOf(sf) !== null || /(^|[^\w$.])(it|test|expect)\s*\(/.test(sf.getFullText()));
|
|
157
|
+
exports.applies = applies;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Candidate } from "@md-code/follow-architecture/entities/facts";
|
|
2
|
+
import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
|
|
3
|
+
declare const id = "vue";
|
|
4
|
+
declare const enrich: (candidates: Candidate[]) => Candidate[];
|
|
5
|
+
declare const applies: ({ rel, text }: FacetContext) => boolean;
|
|
6
|
+
declare const classAttributes: string[];
|
|
7
|
+
export { id, applies, classAttributes, enrich };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrich = exports.classAttributes = exports.applies = exports.id = void 0;
|
|
4
|
+
const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
|
|
5
|
+
const id = "vue";
|
|
6
|
+
exports.id = id;
|
|
7
|
+
const enrich = (candidates) => {
|
|
8
|
+
for (const candidate of candidates) {
|
|
9
|
+
(0, facet_1.attach)(candidate, { id, component: false, props: [], forwarded: [] });
|
|
10
|
+
}
|
|
11
|
+
return candidates;
|
|
12
|
+
};
|
|
13
|
+
exports.enrich = enrich;
|
|
14
|
+
// A template writes the class list into `class`, like HTML does.
|
|
15
|
+
const applies = ({ rel, text }) => /\.vue$/i.test(String(rel ?? "")) || /<template[\s>]/.test(String(text ?? ""));
|
|
16
|
+
exports.applies = applies;
|
|
17
|
+
const classAttributes = ["class"];
|
|
18
|
+
exports.classAttributes = classAttributes;
|
package/dist/ignore.d.ts
ADDED
package/dist/ignore.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IGNORE_PATHS = exports.IGNORE_DIRS = void 0;
|
|
4
|
+
// THE SCAN SCOPE OF THE TOOL, for directories. One list, two callers: the CLI
|
|
5
|
+
// (`--ignore-dir` ADDS to it) and the ESLint rule (`ignoreDirs` ADDS to it), so
|
|
6
|
+
// a lint run and a scan run look at the same files — they used to disagree, and
|
|
7
|
+
// the rule's extra entries existed only because its scan was repo-wide.
|
|
8
|
+
//
|
|
9
|
+
// Every entry is a directory NAME, matched at any depth (see `walk`): generated
|
|
10
|
+
// output, installed dependencies and tooling/config folders, none of which is
|
|
11
|
+
// under the architecture contract. `utils/node/files` keeps dot-entries out by
|
|
12
|
+
// default; the dot folders that ARE scanned here (`.github`, `.changeset`, …)
|
|
13
|
+
// are listed precisely because the walk visits dot-entries for this tool.
|
|
14
|
+
const IGNORE_DIRS = [
|
|
15
|
+
"node_modules",
|
|
16
|
+
".git",
|
|
17
|
+
".vscode-test",
|
|
18
|
+
"out",
|
|
19
|
+
"dist",
|
|
20
|
+
"build",
|
|
21
|
+
"coverage",
|
|
22
|
+
".next",
|
|
23
|
+
".keystone",
|
|
24
|
+
"reports",
|
|
25
|
+
".turbo",
|
|
26
|
+
".artifacts",
|
|
27
|
+
"screenshots",
|
|
28
|
+
".agent",
|
|
29
|
+
".changeset",
|
|
30
|
+
".github",
|
|
31
|
+
];
|
|
32
|
+
exports.IGNORE_DIRS = IGNORE_DIRS;
|
|
33
|
+
// THE SCAN SCOPE OF THE TOOL, for paths. `IGNORE_DIRS` above matches a NAME at
|
|
34
|
+
// any depth; this list names the repo-relative places that are not under the
|
|
35
|
+
// architecture contract yet: the deployable apps, the platform packages only
|
|
36
|
+
// those apps consume, the tooling scripts and the root config files. Paths and
|
|
37
|
+
// globs, not names, on purpose — `packages/native` is out of scope while
|
|
38
|
+
// `packages/follow-architecture/report/user-report/cli-report.ts` and
|
|
39
|
+
// `packages/follow-architecture/tests/cli/` are IN it, and a folder name cannot
|
|
40
|
+
// tell them apart.
|
|
41
|
+
//
|
|
42
|
+
// One list, three consumers: the CLI (`--ignore` ADDS to it), the ESLint rule
|
|
43
|
+
// (`ignores` ADDS to it) and the flat config's global `ignores` in
|
|
44
|
+
// `packages/eslint/base.js`. A scan, a lint run and the editor's server therefore
|
|
45
|
+
// see the same files. Every entry is a minimatch pattern against a path relative
|
|
46
|
+
// to the repo root.
|
|
47
|
+
const IGNORE_PATHS = [
|
|
48
|
+
"apps/**",
|
|
49
|
+
"packages/api/**",
|
|
50
|
+
"packages/native/**",
|
|
51
|
+
"packages/cli/**",
|
|
52
|
+
"packages/infrastructure/**",
|
|
53
|
+
"packages/stylelint/**",
|
|
54
|
+
"scripts/**",
|
|
55
|
+
// Every JS file, at any depth: the repo's sources are TypeScript, so a `.js`,
|
|
56
|
+
// `.cjs` or `.mjs` here is a config or a build artifact, not contract code. This
|
|
57
|
+
// also covers the root configs (`eslint.config.mjs`, `*.config.js`).
|
|
58
|
+
"**/*.js",
|
|
59
|
+
"**/*.cjs",
|
|
60
|
+
"**/*.mjs",
|
|
61
|
+
];
|
|
62
|
+
exports.IGNORE_PATHS = IGNORE_PATHS;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type FileRecord } from "./facts-record";
|
|
2
|
+
import { type ProjectEntityIndex } from "./code-entities/project";
|
|
3
|
+
import { type Index } from "./fa-index";
|
|
4
|
+
import { type Light, type Summary } from "./fa-values";
|
|
5
|
+
import type { Arch } from "./entities/architecture";
|
|
6
|
+
import type { Candidate } from "./entities/facts";
|
|
7
|
+
import type { Finding } from "./entities/findings";
|
|
8
|
+
import type { RunArgs } from "./index-run";
|
|
9
|
+
import type { Project } from "ts-morph";
|
|
10
|
+
import type { SeenStore } from "./utils/seen";
|
|
11
|
+
declare const emptyRegistry: () => ProjectEntityIndex;
|
|
12
|
+
declare const addSummary: (index: ProjectEntityIndex, abs: string, rel: string, summary: Summary) => void;
|
|
13
|
+
declare const addPieces: (index: ProjectEntityIndex, candidates: readonly Candidate[]) => void;
|
|
14
|
+
declare const registryFromIndex: (index: Index, arch: Arch, absFiles: readonly string[], repoFiles: readonly string[]) => ProjectEntityIndex;
|
|
15
|
+
declare const readOne: (abs: string, run: {
|
|
16
|
+
arch: Arch;
|
|
17
|
+
repoFiles: string[];
|
|
18
|
+
}, project: Project) => FileRecord;
|
|
19
|
+
type ScanArgs = {
|
|
20
|
+
run: RunArgs;
|
|
21
|
+
index: Index;
|
|
22
|
+
light: Map<string, Light>;
|
|
23
|
+
kept: Map<string, FileRecord>;
|
|
24
|
+
absFiles: readonly string[];
|
|
25
|
+
live: ReadonlySet<string>;
|
|
26
|
+
projectOpen: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare const recordFor: (args: ScanArgs, abs: string) => FileRecord;
|
|
29
|
+
type FileAt = {
|
|
30
|
+
abs: string;
|
|
31
|
+
entry: Light | undefined;
|
|
32
|
+
fresh: boolean;
|
|
33
|
+
};
|
|
34
|
+
declare const checkOne: (args: ScanArgs, file: FileAt, findings: Finding[]) => boolean;
|
|
35
|
+
type OneFileRun = {
|
|
36
|
+
arch: Arch;
|
|
37
|
+
repoFiles: string[];
|
|
38
|
+
dedupe: SeenStore;
|
|
39
|
+
index: Index | null;
|
|
40
|
+
};
|
|
41
|
+
declare const checkIndexed: (abs: string, run: OneFileRun, buffer?: string | null) => Finding[];
|
|
42
|
+
export { emptyRegistry, addSummary, addPieces, readOne, recordFor, checkOne, checkIndexed, registryFromIndex };
|
|
43
|
+
export type { ScanArgs };
|