@ddd-ts-kit/eslint-plugin 0.16.0 → 0.17.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.
Files changed (235) hide show
  1. package/README.fr.md +465 -0
  2. package/README.md +149 -9
  3. package/dist/project/config.d.ts +8 -0
  4. package/dist/project/config.d.ts.map +1 -1
  5. package/dist/project/parse-config.d.ts.map +1 -1
  6. package/dist/project/parse-config.js +13 -0
  7. package/dist/project/parse-config.js.map +1 -1
  8. package/dist/rules/naming-business-name.d.ts +6 -0
  9. package/dist/rules/naming-business-name.d.ts.map +1 -0
  10. package/dist/rules/naming-business-name.js +175 -0
  11. package/dist/rules/naming-business-name.js.map +1 -0
  12. package/dist/rules/rules.d.ts.map +1 -1
  13. package/dist/rules/rules.js +2 -0
  14. package/dist/rules/rules.js.map +1 -1
  15. package/dist/support/business-names/binding-advice.d.ts +4 -0
  16. package/dist/support/business-names/binding-advice.d.ts.map +1 -0
  17. package/dist/support/business-names/binding-advice.js +12 -0
  18. package/dist/support/business-names/binding-advice.js.map +1 -0
  19. package/dist/support/business-names/binding-kind.d.ts +3 -0
  20. package/dist/support/business-names/binding-kind.d.ts.map +1 -0
  21. package/dist/support/business-names/binding-kind.js +2 -0
  22. package/dist/support/business-names/binding-kind.js.map +1 -0
  23. package/dist/support/business-names/built-class.d.ts +9 -0
  24. package/dist/support/business-names/built-class.d.ts.map +1 -0
  25. package/dist/support/business-names/built-class.js +37 -0
  26. package/dist/support/business-names/built-class.js.map +1 -0
  27. package/dist/support/business-names/called-member.d.ts +8 -0
  28. package/dist/support/business-names/called-member.d.ts.map +1 -0
  29. package/dist/support/business-names/called-member.js +10 -0
  30. package/dist/support/business-names/called-member.js.map +1 -0
  31. package/dist/support/business-names/camel.d.ts +3 -0
  32. package/dist/support/business-names/camel.d.ts.map +1 -0
  33. package/dist/support/business-names/camel.js +5 -0
  34. package/dist/support/business-names/camel.js.map +1 -0
  35. package/dist/support/business-names/collection-element.d.ts +4 -0
  36. package/dist/support/business-names/collection-element.d.ts.map +1 -0
  37. package/dist/support/business-names/collection-element.js +12 -0
  38. package/dist/support/business-names/collection-element.js.map +1 -0
  39. package/dist/support/business-names/conventional-model-name.d.ts +9 -0
  40. package/dist/support/business-names/conventional-model-name.d.ts.map +1 -0
  41. package/dist/support/business-names/conventional-model-name.js +22 -0
  42. package/dist/support/business-names/conventional-model-name.js.map +1 -0
  43. package/dist/support/business-names/generic-words.d.ts +6 -0
  44. package/dist/support/business-names/generic-words.d.ts.map +1 -0
  45. package/dist/support/business-names/generic-words.js +25 -0
  46. package/dist/support/business-names/generic-words.js.map +1 -0
  47. package/dist/support/business-names/is-name-free.d.ts +10 -0
  48. package/dist/support/business-names/is-name-free.d.ts.map +1 -0
  49. package/dist/support/business-names/is-name-free.js +26 -0
  50. package/dist/support/business-names/is-name-free.js.map +1 -0
  51. package/dist/support/business-names/judges-names.d.ts +7 -0
  52. package/dist/support/business-names/judges-names.d.ts.map +1 -0
  53. package/dist/support/business-names/judges-names.js +14 -0
  54. package/dist/support/business-names/judges-names.js.map +1 -0
  55. package/dist/support/business-names/pattern-identifiers.d.ts +4 -0
  56. package/dist/support/business-names/pattern-identifiers.d.ts.map +1 -0
  57. package/dist/support/business-names/pattern-identifiers.js +21 -0
  58. package/dist/support/business-names/pattern-identifiers.js.map +1 -0
  59. package/dist/support/business-names/plural.d.ts +3 -0
  60. package/dist/support/business-names/plural.d.ts.map +1 -0
  61. package/dist/support/business-names/plural.js +8 -0
  62. package/dist/support/business-names/plural.js.map +1 -0
  63. package/dist/support/business-names/proposed-name.d.ts +6 -0
  64. package/dist/support/business-names/proposed-name.d.ts.map +1 -0
  65. package/dist/support/business-names/proposed-name.js +2 -0
  66. package/dist/support/business-names/proposed-name.js.map +1 -0
  67. package/dist/support/business-names/rename-fix.d.ts +8 -0
  68. package/dist/support/business-names/rename-fix.d.ts.map +1 -0
  69. package/dist/support/business-names/rename-fix.js +26 -0
  70. package/dist/support/business-names/rename-fix.js.map +1 -0
  71. package/dist/support/business-names/repository-concept.d.ts +4 -0
  72. package/dist/support/business-names/repository-concept.d.ts.map +1 -0
  73. package/dist/support/business-names/repository-concept.js +10 -0
  74. package/dist/support/business-names/repository-concept.js.map +1 -0
  75. package/dist/support/business-names/singular.d.ts +3 -0
  76. package/dist/support/business-names/singular.d.ts.map +1 -0
  77. package/dist/support/business-names/singular.js +11 -0
  78. package/dist/support/business-names/singular.js.map +1 -0
  79. package/dist/support/business-names/typed-names.d.ts +13 -0
  80. package/dist/support/business-names/typed-names.d.ts.map +1 -0
  81. package/dist/support/business-names/typed-names.js +53 -0
  82. package/dist/support/business-names/typed-names.js.map +1 -0
  83. package/dist/support/business-names/words-of.d.ts +9 -0
  84. package/dist/support/business-names/words-of.d.ts.map +1 -0
  85. package/dist/support/business-names/words-of.js +8 -0
  86. package/dist/support/business-names/words-of.js.map +1 -0
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/docs/rules/application-command-query-separation.fr.md +57 -0
  90. package/docs/rules/application-command-query-separation.md +2 -0
  91. package/docs/rules/application-handler-shape.fr.md +55 -0
  92. package/docs/rules/application-handler-shape.md +2 -0
  93. package/docs/rules/aspects-outside-in.fr.md +57 -0
  94. package/docs/rules/aspects-outside-in.md +2 -0
  95. package/docs/rules/authz-actor-explicit.fr.md +73 -0
  96. package/docs/rules/authz-actor-explicit.md +2 -0
  97. package/docs/rules/authz-declared.fr.md +90 -0
  98. package/docs/rules/authz-declared.md +3 -1
  99. package/docs/rules/authz-fields-by-schema.fr.md +54 -0
  100. package/docs/rules/authz-fields-by-schema.md +2 -0
  101. package/docs/rules/authz-in-application.fr.md +91 -0
  102. package/docs/rules/authz-in-application.md +2 -0
  103. package/docs/rules/clean-blank-lines.fr.md +90 -0
  104. package/docs/rules/clean-blank-lines.md +2 -0
  105. package/docs/rules/clean-braces.fr.md +64 -0
  106. package/docs/rules/clean-braces.md +2 -0
  107. package/docs/rules/clean-file-size.fr.md +46 -0
  108. package/docs/rules/clean-file-size.md +2 -0
  109. package/docs/rules/clean-formatted.fr.md +35 -0
  110. package/docs/rules/clean-formatted.md +2 -0
  111. package/docs/rules/clean-function-ceiling.fr.md +56 -0
  112. package/docs/rules/clean-function-ceiling.md +2 -0
  113. package/docs/rules/clean-function-size.fr.md +48 -0
  114. package/docs/rules/clean-function-size.md +2 -0
  115. package/docs/rules/clean-no-commented-out-code.fr.md +51 -0
  116. package/docs/rules/clean-no-commented-out-code.md +2 -0
  117. package/docs/rules/clean-no-escape-hatch.fr.md +83 -0
  118. package/docs/rules/clean-no-escape-hatch.md +2 -0
  119. package/docs/rules/clean-no-flag-argument.fr.md +53 -0
  120. package/docs/rules/clean-no-flag-argument.md +2 -0
  121. package/docs/rules/clean-no-hash-private.fr.md +66 -0
  122. package/docs/rules/clean-no-hash-private.md +2 -0
  123. package/docs/rules/clean-no-magic-number.fr.md +62 -0
  124. package/docs/rules/clean-no-magic-number.md +2 -0
  125. package/docs/rules/clean-no-noise-comment.fr.md +58 -0
  126. package/docs/rules/clean-no-noise-comment.md +2 -0
  127. package/docs/rules/clean-one-export-per-file.fr.md +91 -0
  128. package/docs/rules/clean-one-export-per-file.md +2 -0
  129. package/docs/rules/clean-stepdown.fr.md +63 -0
  130. package/docs/rules/clean-stepdown.md +2 -0
  131. package/docs/rules/context-declared-relationship.fr.md +52 -0
  132. package/docs/rules/context-declared-relationship.md +2 -0
  133. package/docs/rules/context-extractable.fr.md +112 -0
  134. package/docs/rules/context-extractable.md +2 -0
  135. package/docs/rules/context-published-language-is-a-contract.fr.md +50 -0
  136. package/docs/rules/context-published-language-is-a-contract.md +2 -0
  137. package/docs/rules/context-published-language-only.fr.md +50 -0
  138. package/docs/rules/context-published-language-only.md +2 -0
  139. package/docs/rules/declarations-constructor-injection.fr.md +92 -0
  140. package/docs/rules/declarations-constructor-injection.md +2 -0
  141. package/docs/rules/declarations-role-declared.fr.md +118 -0
  142. package/docs/rules/declarations-role-declared.md +2 -0
  143. package/docs/rules/domain-aggregate-encapsulation.fr.md +66 -0
  144. package/docs/rules/domain-aggregate-encapsulation.md +2 -0
  145. package/docs/rules/domain-events-dispatched-on-save.fr.md +86 -0
  146. package/docs/rules/domain-events-dispatched-on-save.md +2 -0
  147. package/docs/rules/domain-events-transactional-before-commit.fr.md +95 -0
  148. package/docs/rules/domain-events-transactional-before-commit.md +2 -0
  149. package/docs/rules/domain-no-generic-error.fr.md +43 -0
  150. package/docs/rules/domain-no-generic-error.md +2 -0
  151. package/docs/rules/domain-value-object-class.fr.md +177 -0
  152. package/docs/rules/domain-value-object-class.md +2 -0
  153. package/docs/rules/domain-value-object-immutability.fr.md +55 -0
  154. package/docs/rules/domain-value-object-immutability.md +2 -0
  155. package/docs/rules/errors-constructor-not-public.fr.md +56 -0
  156. package/docs/rules/errors-constructor-not-public.md +2 -0
  157. package/docs/rules/errors-factory-name.fr.md +53 -0
  158. package/docs/rules/errors-factory-name.md +2 -0
  159. package/docs/rules/errors-through-factory.fr.md +48 -0
  160. package/docs/rules/errors-through-factory.md +2 -0
  161. package/docs/rules/event-sourcing-past-tense.fr.md +43 -0
  162. package/docs/rules/event-sourcing-past-tense.md +2 -0
  163. package/docs/rules/event-sourcing-projection-never-appends.fr.md +52 -0
  164. package/docs/rules/event-sourcing-projection-never-appends.md +2 -0
  165. package/docs/rules/event-sourcing-state-in-apply.fr.md +54 -0
  166. package/docs/rules/event-sourcing-state-in-apply.md +2 -0
  167. package/docs/rules/event-sourcing-store-behind-repository.fr.md +42 -0
  168. package/docs/rules/event-sourcing-store-behind-repository.md +2 -0
  169. package/docs/rules/event-sourcing-upcaster-required.fr.md +58 -0
  170. package/docs/rules/event-sourcing-upcaster-required.md +2 -0
  171. package/docs/rules/events-consumer-idempotent.fr.md +71 -0
  172. package/docs/rules/events-consumer-idempotent.md +2 -0
  173. package/docs/rules/events-name-format.fr.md +57 -0
  174. package/docs/rules/events-name-format.md +2 -0
  175. package/docs/rules/events-outbox-required.fr.md +60 -0
  176. package/docs/rules/events-outbox-required.md +2 -0
  177. package/docs/rules/governance-recorded-deviation.fr.md +58 -0
  178. package/docs/rules/governance-recorded-deviation.md +2 -0
  179. package/docs/rules/imports-alias-only.fr.md +77 -0
  180. package/docs/rules/imports-alias-only.md +2 -0
  181. package/docs/rules/imports-extension.fr.md +86 -0
  182. package/docs/rules/imports-extension.md +2 -0
  183. package/docs/rules/language-declared-vocabulary.fr.md +67 -0
  184. package/docs/rules/language-declared-vocabulary.md +2 -0
  185. package/docs/rules/layer-application-inward.fr.md +65 -0
  186. package/docs/rules/layer-application-inward.md +4 -2
  187. package/docs/rules/layer-domain-purity.fr.md +63 -0
  188. package/docs/rules/layer-domain-purity.md +4 -2
  189. package/docs/rules/layer-infrastructure-no-presentation.fr.md +49 -0
  190. package/docs/rules/layer-infrastructure-no-presentation.md +2 -0
  191. package/docs/rules/layer-presentation-no-infrastructure.fr.md +49 -0
  192. package/docs/rules/layer-presentation-no-infrastructure.md +2 -0
  193. package/docs/rules/lifecycle-status-through-machine.fr.md +72 -0
  194. package/docs/rules/lifecycle-status-through-machine.md +2 -0
  195. package/docs/rules/naming-business-name.fr.md +82 -0
  196. package/docs/rules/naming-business-name.md +81 -0
  197. package/docs/rules/ports-abstract-class.fr.md +73 -0
  198. package/docs/rules/ports-abstract-class.md +2 -0
  199. package/docs/rules/ports-implements-never-extends.fr.md +56 -0
  200. package/docs/rules/ports-implements-never-extends.md +2 -0
  201. package/docs/rules/ports-no-concrete-dependency.fr.md +56 -0
  202. package/docs/rules/ports-no-concrete-dependency.md +2 -0
  203. package/docs/rules/ports-no-token-constant.fr.md +60 -0
  204. package/docs/rules/ports-no-token-constant.md +2 -0
  205. package/docs/rules/ports-value-import.fr.md +58 -0
  206. package/docs/rules/ports-value-import.md +2 -0
  207. package/docs/rules/presentation-controller-delegates.fr.md +60 -0
  208. package/docs/rules/presentation-controller-delegates.md +2 -0
  209. package/docs/rules/presentation-controller-shape.fr.md +53 -0
  210. package/docs/rules/presentation-controller-shape.md +2 -0
  211. package/docs/rules/presentation-guard-at-the-edge.fr.md +58 -0
  212. package/docs/rules/presentation-guard-at-the-edge.md +2 -0
  213. package/docs/rules/presentation-shared-cache-varies.fr.md +57 -0
  214. package/docs/rules/presentation-shared-cache-varies.md +2 -0
  215. package/docs/rules/process-sends-commands-only.fr.md +67 -0
  216. package/docs/rules/process-sends-commands-only.md +2 -0
  217. package/docs/rules/purity-no-ambient-randomness.fr.md +46 -0
  218. package/docs/rules/purity-no-ambient-randomness.md +2 -0
  219. package/docs/rules/purity-no-environment.fr.md +48 -0
  220. package/docs/rules/purity-no-environment.md +2 -0
  221. package/docs/rules/purity-no-system-clock.fr.md +52 -0
  222. package/docs/rules/purity-no-system-clock.md +2 -0
  223. package/docs/rules/scheduling-job-name.fr.md +60 -0
  224. package/docs/rules/scheduling-job-name.md +2 -0
  225. package/docs/rules/scheduling-job-triggers-use-case.fr.md +74 -0
  226. package/docs/rules/scheduling-job-triggers-use-case.md +2 -0
  227. package/docs/rules/schema-presentation-only.fr.md +48 -0
  228. package/docs/rules/schema-presentation-only.md +2 -0
  229. package/docs/rules/standard-no-parallel-interface.fr.md +100 -0
  230. package/docs/rules/standard-no-parallel-interface.md +2 -0
  231. package/docs/rules/test-no-mocks.fr.md +50 -0
  232. package/docs/rules/test-no-mocks.md +2 -0
  233. package/docs/rules/tracing-platform-only.fr.md +68 -0
  234. package/docs/rules/tracing-platform-only.md +2 -0
  235. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ **English** · [Français](layer-domain-purity.fr.md)
2
+
1
3
  # ddd-ts-kit/layer-domain-purity
2
4
 
3
5
  Architecture id: `layer/domain-purity`. Default severity: `error` in `recommended`, `error` in `strict`.
@@ -11,7 +13,7 @@ The domain is the part of the system that must survive a change of framework, OR
11
13
  ## Reported
12
14
 
13
15
  - a package outside `domainAllowedPackages` (default: `@ddd-ts-kit/kernel`)
14
- - `@ddd-ts-kit/aspects`, `@ddd-ts-kit/audit`, `@ddd-ts-kit/redis`, `@ddd-ts-kit/scheduling`, `@ddd-ts-kit/sentry` and `@ddd-ts-kit/tracing`, by any entry (`.`, `/decorators`, `/testing`, `/node`, ...), with a message of their own: they apply or record a concern from outside the model
16
+ - `@ddd-ts-kit/aspects`, `@ddd-ts-kit/audit`, `@ddd-ts-kit/redis`, `@ddd-ts-kit/s3`, `@ddd-ts-kit/scheduling`, `@ddd-ts-kit/sentry` and `@ddd-ts-kit/tracing`, by any entry (`.`, `/decorators`, `/testing`, `/node`, ...), with a message of their own: they apply or record a concern from outside the model
15
17
  - in a declared-style project (`stack.style: "declared"`): `@ddd-ts-kit/kernel/declarations`, even though `@ddd-ts-kit/kernel` is allowed, with a message of its own: the domain declares nothing
16
18
  - any Node built-in
17
19
  - another layer of the same context, the platform, `main.ts`
@@ -44,7 +46,7 @@ Static imports, type-only imports, `export ... from`, dynamic `import()`, `requi
44
46
 
45
47
  ## Options
46
48
 
47
- None. `domainAllowedPackages` in `ddd-ts-kit.config.json` extends the allow-list. The four packages above stay refused even when the list names them: logging, metrics, retry, timeout, circuit breaking, caching and tracing reach the model from the composition root (`.with(...)` on a binding, the `decorate` hook), a bus middleware or an adapter in `infrastructure/`; Redis sits behind a port; the audit trail is fed by the bus middleware, the authorization hook and an event subscription. The only way around is a recorded suppression of the line.
49
+ None. `domainAllowedPackages` in `ddd-ts-kit.config.json` extends the allow-list. The seven packages above stay refused whatever the list says, even when it names them: logging, metrics, retry, timeout, circuit breaking, caching and tracing reach the model from the composition root (`.with(...)` on a binding, the `decorate` hook), a bus middleware or an adapter in `infrastructure/`; Redis sits behind a port, an object store behind the `FileStorage` port of the kernel, the scheduler behind the `JobScheduler` port and error reporting behind the `ErrorReporter` port; the audit trail is fed by the bus middleware, the authorization hook and an event subscription. The only way around is a recorded suppression of the line.
48
50
 
49
51
  `rules."layer/domain-purity"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line layer/domain-purity -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
50
52
 
@@ -0,0 +1,49 @@
1
+ [English](layer-infrastructure-no-presentation.md) · **Français**
2
+ <!-- translation-of: layer-infrastructure-no-presentation.md sha256:b7e06c69f41cb0cb -->
3
+
4
+ # ddd-ts-kit/layer-infrastructure-no-presentation
5
+
6
+ Identifiant d'architecture : `layer/infrastructure-no-presentation`. Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : `infrastructure/` d'un contexte, tests exclus.
9
+
10
+ ## Pourquoi
11
+
12
+ Les adaptateurs implémentent des ports de l'application et du domaine. Un adaptateur qui connaît un DTO du transport couple la persistance à HTTP : le type partagé appartient à l'application.
13
+
14
+ ## Signalé
15
+
16
+ - un import de `presentation/` du même contexte
17
+
18
+ Incorrect :
19
+
20
+ ```ts
21
+ // src/contexts/billing/infrastructure/persistence/drizzle-invoice.repository.ts
22
+ import type { IssueInvoiceBody } from '@/contexts/billing/presentation/http/issue-invoice.dto';
23
+ ```
24
+
25
+ Correct :
26
+
27
+ ```ts
28
+ import type { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
29
+ ```
30
+
31
+ ## Détails
32
+
33
+ Les imports statiques, les imports de type seul, `export ... from`, les `import()` dynamiques, `require()`, `import x = require()` et les types `import("...")` sont tous lus, à travers les chemins relatifs et l'`importAlias` configuré.
34
+
35
+ ## Options
36
+
37
+ Aucune.
38
+
39
+ `rules."layer/infrastructure-no-presentation"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line layer/infrastructure-no-presentation -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
40
+
41
+ ## Limites
42
+
43
+ - La cible est classée d'après son chemin : un *barrel* d'une couche permise qui réexporte une couche interdite n'est pas suivi. `dependency-cruiser` (voir `pipeline/depcruise-config.mjs`) résout le vrai graphe et comble ce manque.
44
+ - Un spécificateur calculé (`import(name)`) n'est pas jugé.
45
+ - Les chemins `tsconfig` autres que `importAlias` ne sont pas résolus.
46
+
47
+ ## Avec le checker de la CLI
48
+
49
+ `ddd-ts-kit check` signale le même identifiant à partir d'une lecture du fichier par expressions régulières, assez rapide pour un *hook* d'éditeur. Cette règle fait autorité : elle lit l'arbre syntaxique.
@@ -1,3 +1,5 @@
1
+ **English** · [Français](layer-infrastructure-no-presentation.fr.md)
2
+
1
3
  # ddd-ts-kit/layer-infrastructure-no-presentation
2
4
 
3
5
  Architecture id: `layer/infrastructure-no-presentation`. Default severity: `error` in `recommended`, `error` in `strict`.
@@ -0,0 +1,49 @@
1
+ [English](layer-presentation-no-infrastructure.md) · **Français**
2
+ <!-- translation-of: layer-presentation-no-infrastructure.md sha256:9e36510c520ef7cc -->
3
+
4
+ # ddd-ts-kit/layer-presentation-no-infrastructure
5
+
6
+ Identifiant d'architecture : `layer/presentation-no-infrastructure`. Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : `presentation/` d'un contexte, tests exclus.
9
+
10
+ ## Pourquoi
11
+
12
+ Une route traduit une requête HTTP en commande ou en requête, et un résultat en réponse. Quand elle atteint directement un adaptateur, le cas d'usage est contourné, et avec lui ses règles, son unité de travail et son autorisation.
13
+
14
+ ## Signalé
15
+
16
+ - un import de `infrastructure/` du même contexte
17
+
18
+ Incorrect :
19
+
20
+ ```ts
21
+ // src/contexts/billing/presentation/http/issue-invoice.route.ts
22
+ import { DrizzleInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository';
23
+ ```
24
+
25
+ Correct :
26
+
27
+ ```ts
28
+ import { IssueInvoiceCommand } from '@/contexts/billing/application/commands/issue-invoice/issue-invoice.command';
29
+ ```
30
+
31
+ ## Détails
32
+
33
+ Les imports statiques, les imports de type seul, `export ... from`, les `import()` dynamiques, `require()`, `import x = require()` et les types `import("...")` sont tous lus, à travers les chemins relatifs et l'`importAlias` configuré.
34
+
35
+ ## Options
36
+
37
+ Aucune.
38
+
39
+ `rules."layer/presentation-no-infrastructure"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line layer/presentation-no-infrastructure -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
40
+
41
+ ## Limites
42
+
43
+ - La cible est classée d'après son chemin : un *barrel* d'une couche permise qui réexporte une couche interdite n'est pas suivi. `dependency-cruiser` (voir `pipeline/depcruise-config.mjs`) résout le vrai graphe et comble ce manque.
44
+ - Un spécificateur calculé (`import(name)`) n'est pas jugé.
45
+ - Les chemins `tsconfig` autres que `importAlias` ne sont pas résolus.
46
+
47
+ ## Avec le checker de la CLI
48
+
49
+ `ddd-ts-kit check` signale le même identifiant à partir d'une lecture du fichier par expressions régulières, assez rapide pour un *hook* d'éditeur. Cette règle fait autorité : elle lit l'arbre syntaxique.
@@ -1,3 +1,5 @@
1
+ **English** · [Français](layer-presentation-no-infrastructure.fr.md)
2
+
1
3
  # ddd-ts-kit/layer-presentation-no-infrastructure
2
4
 
3
5
  Architecture id: `layer/presentation-no-infrastructure`. Default severity: `error` in `recommended`, `error` in `strict`.
@@ -0,0 +1,72 @@
1
+ [English](lifecycle-status-through-machine.md) · **Français**
2
+ <!-- translation-of: lifecycle-status-through-machine.md sha256:a589325d42b548b2 -->
3
+
4
+ # ddd-ts-kit/lifecycle-status-through-machine
5
+
6
+ Identifiant d'architecture : `lifecycle/status-through-machine`. Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : `domain/aggregates/*` d'un contexte, *specs* mises à part, quand le fichier importe une
9
+ machine à états de `domain/state-machines/`.
10
+
11
+ ## Pourquoi
12
+
13
+ Une machine à états dit une fois quel statut suit quel autre, et ce qui refuse une transition
14
+ interdite. Un agrégat qui écrit aussi son statut à la main garde une seconde copie, muette, du
15
+ cycle de vie : le diagramme généré depuis la machine ment alors, et une transition que la machine
16
+ interdit a lieu quand même. Le statut n'est donc jamais écrit que depuis la machine, ou recopié
17
+ d'un statut déjà lu.
18
+
19
+ ## Signalé
20
+
21
+ Dans un fichier d'agrégat qui importe un module `*.state-machine`, à l'intérieur d'un membre d'une classe :
22
+
23
+ - une propriété d'objet `status: <value>` dont la valeur n'est ni un appel `<machine>.next(..)` ou
24
+ `<machine>.start(..)` d'une machine importée, ni un statut lu ailleurs (`this.state.status`,
25
+ `state.status`), ni la variable `status`
26
+ - une affectation `<target>.status = <value>`, selon le même test
27
+
28
+ Incorrect :
29
+
30
+ ```ts
31
+ confirm(now: Date): void {
32
+ if (this.state.status !== 'requested') {
33
+ throw AppointmentError.alreadyConfirmed(this.id);
34
+ }
35
+
36
+ this.state = { ...this.state, changedAt: now, status: 'booked' };
37
+ }
38
+ ```
39
+
40
+ Correct :
41
+
42
+ ```ts
43
+ confirm(now: Date): void {
44
+ this.state = { ...this.state, changedAt: now, status: appointmentLifecycle.next(this.state.status, 'confirm') };
45
+ }
46
+ ```
47
+
48
+ ## Détails
49
+
50
+ La machine est toute liaison importée d'un module dont le chemin se termine par
51
+ `state-machines/<name>.state-machine`. Ce que la machine garantit : `defineStateMachine` de
52
+ `@ddd-ts-kit/kernel`.
53
+
54
+ ## Options
55
+
56
+ Aucune.
57
+
58
+ `rules."lifecycle/status-through-machine"` à `off` dans `ddd-ts-kit.config.json` désactive la
59
+ règle, et `// ddd-ts-kit-disable-next-line lifecycle/status-through-machine -- <reason>` désactive
60
+ une ligne, exactement comme pour `ddd-ts-kit check`.
61
+
62
+ ## Limites
63
+
64
+ - Un fichier à la fois : un agrégat dont la machine à états existe sans être importée est signalé
65
+ par `ddd-ts-kit check` seul.
66
+ - Un statut écrit par une fonction auxiliaire, ou tenu dans l'initialiseur d'un champ de la classe,
67
+ n'est pas suivi.
68
+
69
+ ## Avec le checker de la CLI
70
+
71
+ `ddd-ts-kit check` signale le même identifiant à partir du texte des fichiers, et aussi un agrégat
72
+ dont la machine à états existe (`domain/state-machines/<aggregate>.state-machine.ts`) sans être importée.
@@ -1,3 +1,5 @@
1
+ **English** · [Français](lifecycle-status-through-machine.fr.md)
2
+
1
3
  # ddd-ts-kit/lifecycle-status-through-machine
2
4
 
3
5
  Architecture id: `lifecycle/status-through-machine`. Default severity: `error` in `recommended`, `error` in `strict`.
@@ -0,0 +1,82 @@
1
+ [English](naming-business-name.md) · **Français**
2
+ <!-- translation-of: naming-business-name.md sha256:89217992f8690282 -->
3
+
4
+ # ddd-ts-kit/naming-business-name
5
+
6
+ Identifiant d'architecture : `naming/business-name`. Sévérité par défaut : `error`. Corrigible (`eslint --fix`) là où le nom est connu.
7
+
8
+ S'applique à : `domain/` et `application/` de chaque contexte, et au noyau partagé hors de son `presentation/` ; tests exclus. Active par défaut, dans un nouveau projet comme dans un projet existant : une configuration sans `businessNames` lit la liste par défaut.
9
+
10
+ ## Pourquoi
11
+
12
+ Le code du modèle, c'est le langage omniprésent (ubiquitous language) écrit. Un gestionnaire qui charge un rendez-vous et le nomme `target`, une boucle qui parcourt les rappels échus sous le nom `item`, un paramètre appelé `data` : chacun oblige le lecteur à retraduire la ligne dans les mots du métier, et cache le concept qu'elle manipule. Un nom générique se propage aussi, parce que la ligne suivante s'écrit en copiant la précédente : les gabarits de gestionnaire de commande du kit écrivaient `const target = X.create(..)` jusqu'à la 0.17, et quarante gestionnaires de l'application d'exemple en ont hérité. Nommée d'après son concept, `appointment`, `reminder`, `delegation`, une ligne se lit comme l'expert du domaine la dirait.
13
+
14
+ ## Signalé
15
+
16
+ Un nom qui est l'un des mots génériques, `target`, `targets`, `data`, `item`, `items`, `obj`, `object`, `thing`, `things`, `stuff`, `info`, `element`, `el`, `tmp`, `temp`, `foo`, `bar` ou `baz`, donné à :
17
+
18
+ - une variable, `const target = ..` ;
19
+ - une variable de boucle, `for (const target of due)` ;
20
+ - un nom déstructuré, `const { lines: data } = command`, à toute profondeur ;
21
+ - un paramètre d'une fonction, d'une méthode, d'une fonction fléchée, d'une signature abstraite ou de surcharge, d'une signature de méthode d'interface, ou d'un type fonction ;
22
+ - une propriété d'une classe (propriétés de paramètre comprises), d'une interface, ou d'un alias de type objet.
23
+
24
+ Incorrect :
25
+
26
+ ```ts
27
+ const target = await this.appointmentRepository.findById(command.appointmentId);
28
+
29
+ for (const target of due) {
30
+ target.expire(command.at);
31
+ }
32
+ ```
33
+
34
+ Correct :
35
+
36
+ ```ts
37
+ const appointment = await this.appointmentRepository.findById(command.appointmentId);
38
+
39
+ for (const appointment of due) {
40
+ appointment.expire(command.at);
41
+ }
42
+ ```
43
+
44
+ ## Le correctif
45
+
46
+ Une variable dont l'initialiseur dit quel concept elle désigne est renommée, avec chacun de ses usages, du nom de ce concept en camelCase :
47
+
48
+ - `X.create(..)` et `new X(..)`, `X` étant une classe du fichier ou importée du projet (`new Map()` ne dit rien du métier) : `const appointment = Appointment.create(..)` ;
49
+ - un appel sur un *repository* : avec l'information de types (les presets du plugin la donnent), le type qu'il répond, une fois attendu et sans `undefined`, quand c'est un agrégat, une entité ou un objet-valeur du projet (`domain/aggregates/`, `domain/entities/`, `domain/value-objects/`, le noyau partagé) ; `appointments` pour une liste. Le *repository* est une instance d'un port de `domain/repositories/`, ou une liaison nommée `<concept>Repository`. Sans information de types, les noms décident : `this.appointmentRepository.findById(..)` (`find`, `get`, `load`, `require`, seuls ou suivis de `One` ou `ById`) désigne un `appointment`, `findDue(..)` reçu par un mot au pluriel (`targets`, `items`, `things`) désigne des `appointments`.
50
+
51
+ Une propriété abrégée garde sa clé : `{ target }` devient `{ target: appointment }`. La règle signale sans corriger quand le nom est déjà pris (déclaré dans la portée, masqué entre un usage et la déclaration, ou employé dans la portée pour autre chose), quand la variable est exportée, et quand la liaison désigne un élément alors que le nom en dit plusieurs, ou l'inverse. Une variable de boucle n'est jamais corrigée : le message donne le singulier de sa collection (`reminder` pour `dueReminders`, ou le type de l'élément avec l'information de types).
52
+
53
+ Mettre un projet à jour tient en une commande, puis les signalements qui restent :
54
+
55
+ ```bash
56
+ npx eslint . --fix
57
+ npx eslint .
58
+ ```
59
+
60
+ ## Détails
61
+
62
+ Une clé d'un objet littéral suit le type pour lequel elle est écrite et n'est pas jugée : `{ items, total }` est la forme d'une `Page` du noyau. Un type littéral imbriqué dans une annotation, `props: { data: string }`, n'est pas non plus une déclaration du modèle. Une clause `catch` n'est pas jugée.
63
+
64
+ ## Options
65
+
66
+ `words` : les mots génériques, à la place de la liste par défaut. `allow` : des mots retirés de la liste.
67
+
68
+ ```js
69
+ 'ddd-ts-kit/naming-business-name': ['error', { allow: ['info'] }]
70
+ ```
71
+
72
+ Les deux options passent par-dessus `businessNames` de `ddd-ts-kit.config.json`, `{ "words": [..], "allow": [..] }`, que lit aussi `ddd-ts-kit check` : gardez la liste là, pour que les deux analyseurs jugent les mêmes noms. `rules."naming/business-name"` à `off` fait taire la règle, et `// ddd-ts-kit-disable-next-line naming/business-name -- <raison>` fait taire une ligne, exactement comme pour `ddd-ts-kit check`.
73
+
74
+ ## Limites
75
+
76
+ - L'infrastructure, la présentation, la plateforme et les tests ne sont pas jugés : un adaptateur parle les mots de sa bibliothèque, et une spec ceux de son scénario. Un *serializer* de `presentation/` gagne tout de même à être nommé d'après ce qu'il sérialise.
77
+ - Un mot générique à l'intérieur d'un nom plus long (`targetDate`, `itemCount`) n'est pas signalé : il est qualifié. `language/no-technical-name` juge les noms des classes et des cas d'usage.
78
+ - Sans information de types, un *repository* dont la méthode ne nomme ni un élément ni plusieurs (`save`, `search`, `count`) ne reçoit aucune proposition.
79
+
80
+ ## Avec le checker de la CLI
81
+
82
+ `ddd-ts-kit check` signale le même identifiant à partir du texte des fichiers, avec la même liste et aux mêmes endroits, et propose le nom de la classe qu'un initialiseur construit ou du *repository* qu'il lit. Cette règle fait autorité, et c'est elle qui renomme.
@@ -0,0 +1,81 @@
1
+ **English** · [Français](naming-business-name.fr.md)
2
+
3
+ # ddd-ts-kit/naming-business-name
4
+
5
+ Architecture id: `naming/business-name`. Default severity: `error`. Fixable (`eslint --fix`) where the name is known.
6
+
7
+ Applies to: `domain/` and `application/` of every context, and the shared kernel outside its `presentation/`; tests excluded. On by default, in a new project and in an existing one: a config without `businessNames` reads the default list.
8
+
9
+ ## Why
10
+
11
+ The code of the model is the ubiquitous language written down. A handler that loads an appointment and names it `target`, a loop that walks the due reminders as `item`, a parameter called `data`: each makes the reader translate the line back into the business, and hides which concept it handles. A generic name also spreads, because the next line is written by copying the last one: the command handler templates of the kit wrote `const target = X.create(..)` until 0.17, and forty handlers of the example application inherited it. Named after its concept, `appointment`, `reminder`, `delegation`, a line reads as the domain expert would say it.
12
+
13
+ ## Reported
14
+
15
+ A name that is one of the generic words, `target`, `targets`, `data`, `item`, `items`, `obj`, `object`, `thing`, `things`, `stuff`, `info`, `element`, `el`, `tmp`, `temp`, `foo`, `bar` or `baz`, given to:
16
+
17
+ - a variable, `const target = ..`;
18
+ - a loop variable, `for (const target of due)`;
19
+ - a destructured binding, `const { lines: data } = command`, at any depth;
20
+ - a parameter of a function, a method, an arrow, an abstract or overload signature, a method signature of an interface, or a function type;
21
+ - a property of a class (parameter properties included), of an interface, or of a type alias of an object.
22
+
23
+ Incorrect:
24
+
25
+ ```ts
26
+ const target = await this.appointmentRepository.findById(command.appointmentId);
27
+
28
+ for (const target of due) {
29
+ target.expire(command.at);
30
+ }
31
+ ```
32
+
33
+ Correct:
34
+
35
+ ```ts
36
+ const appointment = await this.appointmentRepository.findById(command.appointmentId);
37
+
38
+ for (const appointment of due) {
39
+ appointment.expire(command.at);
40
+ }
41
+ ```
42
+
43
+ ## The fix
44
+
45
+ A variable whose initializer says which concept it holds is renamed, with every use of it, to the name of that concept in camel case:
46
+
47
+ - `X.create(..)` and `new X(..)`, `X` a class of the file or one imported from the project (`new Map()` says nothing of the business): `const appointment = Appointment.create(..)`;
48
+ - a call on a repository: with type information (the presets of the plugin give it), the type it answers, once awaited and without `undefined`, when it is an aggregate, an entity or a value object of the project (`domain/aggregates/`, `domain/entities/`, `domain/value-objects/`, the shared kernel); `appointments` for a list. The repository is an instance of a port of `domain/repositories/`, or a binding named `<concept>Repository`. Without type information, the names decide: `this.appointmentRepository.findById(..)` (`find`, `get`, `load`, `require`, alone or with `One` or `ById`) holds an `appointment`, `findDue(..)` held by a plural word (`targets`, `items`, `things`) holds `appointments`.
49
+
50
+ A shorthand property keeps its key: `{ target }` becomes `{ target: appointment }`. The rule reports without fixing when the name is already taken (declared in the scope, shadowing between a use and the declaration, or used inside the scope for something else), when the variable is exported, and when the binding holds one element but the name says several, or the other way round. A loop variable is never fixed: the message gives the singular of its collection (`reminder` for `dueReminders`, or the element type with type information).
51
+
52
+ Upgrading a project is one command, then the reports that remain:
53
+
54
+ ```bash
55
+ npx eslint . --fix
56
+ npx eslint .
57
+ ```
58
+
59
+ ## Details
60
+
61
+ A key of an object literal follows the type it is written for and is not judged: `{ items, total }` is the shape of a `Page` of the kernel. A type literal nested in an annotation, `props: { data: string }`, is not a declaration of the model either. A catch clause is not judged.
62
+
63
+ ## Options
64
+
65
+ `words`: the generic words, in place of the default list. `allow`: words removed from the list.
66
+
67
+ ```js
68
+ 'ddd-ts-kit/naming-business-name': ['error', { allow: ['info'] }]
69
+ ```
70
+
71
+ Both options come over `businessNames` of `ddd-ts-kit.config.json`, `{ "words": [..], "allow": [..] }`, which `ddd-ts-kit check` reads too: keep the list there so that both analyzers judge the same names. `rules."naming/business-name"` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line naming/business-name -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
72
+
73
+ ## Limits
74
+
75
+ - Infrastructure, presentation, the platform and the tests are not judged: an adapter speaks the words of its library, and a spec the words of its scenario. A serializer of `presentation/` is still better named after what it serializes.
76
+ - A generic word inside a longer name (`targetDate`, `itemCount`) is not reported: it is qualified. `language/no-technical-name` judges the names of classes and use cases.
77
+ - Without type information, a repository whose method names neither one element nor several (`save`, `search`, `count`) gets no proposal.
78
+
79
+ ## With the CLI checker
80
+
81
+ `ddd-ts-kit check` reports the same id from the text of the files, with the same list and the same places, and proposes the name of the class an initializer builds or of the repository it reads. This rule is the authority, and the one that renames.
@@ -0,0 +1,73 @@
1
+ [English](ports-abstract-class.md) · **Français**
2
+ <!-- translation-of: ports-abstract-class.md sha256:1ebb5cd851088e2c -->
3
+
4
+ # ddd-ts-kit/ports-abstract-class
5
+
6
+ Identifiant d'architecture : `ports/abstract-class`. Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : les fichiers de port d'un contexte : `domain/repositories/*.repository.ts` et `application/ports/*.port.ts`.
9
+
10
+ ## Pourquoi
11
+
12
+ Un port est une classe abstraite qui n'a que des membres abstraits. La classe est à la fois le contrat et le jeton d'injection : elle nomme la dépendance dans une liste de dépendances, porte son type jusqu'au constructeur, et il n'y a ni constante ni fichier de jetons à garder en accord avec elle. Un port qui contient un corps, un champ ou un constructeur est une classe de base déguisée : les adaptateurs se mettent à hériter du comportement, et un *fake* ne convient plus.
13
+
14
+ ## Signalé
15
+
16
+ - une classe qui n'est pas `abstract`
17
+ - un constructeur
18
+ - un membre `private`, `protected` ou `#`
19
+ - une méthode avec un corps, une propriété avec un initialiseur, un membre qui n'est pas `abstract`
20
+ - une `interface` exportée : un port se déclare comme une classe abstraite
21
+
22
+ Incorrect :
23
+
24
+ ```ts
25
+ // application/ports/payment-gateway.port.ts
26
+ export interface PaymentGateway {
27
+ charge(invoiceId: string): Promise<void>;
28
+ }
29
+
30
+ // domain/repositories/invoice.repository.ts
31
+ export abstract class InvoiceRepository {
32
+ constructor(protected readonly table: string) {}
33
+
34
+ async exists(id: string): Promise<boolean> {
35
+ return (await this.findById(id)) !== undefined;
36
+ }
37
+ }
38
+ ```
39
+
40
+ Correct :
41
+
42
+ ```ts
43
+ // application/ports/payment-gateway.port.ts
44
+ export abstract class PaymentGateway {
45
+ abstract charge(invoiceId: string): Promise<void>;
46
+ }
47
+
48
+ // domain/repositories/invoice.repository.ts
49
+ import { Repository } from '@ddd-ts-kit/kernel';
50
+
51
+ export abstract class InvoiceRepository extends Repository<Invoice> {}
52
+ ```
53
+
54
+ ## Détails
55
+
56
+ Un port peut en étendre un autre : le `Repository<A>` du noyau, ou un port du même contexte. Un membre est permis en plus des membres abstraits : `static readonly tokenKey = '<package>.<Port>'`, un littéral de chaîne qui donne au port une seule identité quand son *package* est chargé deux fois. Une valeur qui n'est pas un port (des réglages, une connexion à la base de données) se type de la même façon, par une classe abstraite aux propriétés `abstract readonly`.
57
+
58
+ Un alias `type` exporté n'est pas signalé : la forme des données qui transitent par le port peut être un type. Une interface non exportée est laissée tranquille aussi.
59
+
60
+ ## Options
61
+
62
+ Aucune.
63
+
64
+ `rules."ports/abstract-class"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line ports/abstract-class -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
65
+
66
+ ## Limites
67
+
68
+ - Un membre hérité d'une classe d'un autre fichier n'est pas lu : `@Repository`, `@Gateway` et `@Adapter` refusent un port doté d'un corps au chargement du fichier.
69
+ - Un port déclaré hors des deux dossiers de ports n'est pas jugé.
70
+
71
+ ## Avec le checker de la CLI
72
+
73
+ `ddd-ts-kit check` signale le même identifiant à partir du texte des fichiers. Cette règle fait autorité pour le code.
@@ -1,3 +1,5 @@
1
+ **English** · [Français](ports-abstract-class.fr.md)
2
+
1
3
  # ddd-ts-kit/ports-abstract-class
2
4
 
3
5
  Architecture id: `ports/abstract-class`. Default severity: `error` in `recommended`, `error` in `strict`.
@@ -0,0 +1,56 @@
1
+ [English](ports-implements-never-extends.md) · **Français**
2
+ <!-- translation-of: ports-implements-never-extends.md sha256:2a318e3c9e3a8f11 -->
3
+
4
+ # ddd-ts-kit/ports-implements-never-extends
5
+
6
+ Identifiant d'architecture : `ports/implements-never-extends`. Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : chaque fichier passé au lint.
9
+
10
+ ## Pourquoi
11
+
12
+ Un adaptateur honore un contrat ; il n'en hérite pas. `implements` laisse le compilateur vérifier l'adaptateur par rapport au port et garde le port sans comportement, pour qu'un *fake*, une classe en mémoire et un client distant soient interchangeables. `extends` fait du port une classe de base et y attache chaque adaptateur.
13
+
14
+ ## Signalé
15
+
16
+ - une classe portant `@Repository(Port, ..)`, `@Gateway(Port, ..)` ou `@Adapter(Port, ..)` qui n'écrit pas `implements Port`, ou qui écrit `extends Port`
17
+ - la classe donnée à `bind(Port).toClass(Class, ..)` ou à `rebind(Port).toClass(Class, ..)` qui n'implémente pas `Port`, ou qui l'étend
18
+ - sous `infrastructure/` d'un contexte : une classe qui étend (`extends`) une classe importée d'un fichier de port
19
+
20
+ Incorrect :
21
+
22
+ ```ts
23
+ @Repository(InvoiceRepository, [Database])
24
+ export class KnexInvoiceRepository extends InvoiceRepository {}
25
+
26
+ builder.bind(PaymentGateway).toClass(StripePaymentGateway, [PaymentSettings]);
27
+ // où : export class StripePaymentGateway {}
28
+ ```
29
+
30
+ Correct :
31
+
32
+ ```ts
33
+ @Repository(InvoiceRepository, [Database])
34
+ export class KnexInvoiceRepository implements InvoiceRepository {}
35
+
36
+ export class StripePaymentGateway implements PaymentGateway {}
37
+ ```
38
+
39
+ ## Détails
40
+
41
+ La classe donnée à `toClass` est cherchée dans le fichier analysé, puis dans le fichier d'où elle est importée par un chemin relatif ou l'alias d'import : ce fichier est lu sur le disque et analysé sans les types. Quand elle est introuvable (une classe d'un *package*, un *barrel*, un export qui renomme), rien n'est signalé. Une classe liée à elle-même (`bind(Registry).toClass(Registry)`) n'est pas un port et n'est pas jugée. Les fichiers de port sont `domain/repositories/*.repository.ts` et `application/ports/*.port.ts`.
42
+
43
+ ## Options
44
+
45
+ Aucune.
46
+
47
+ `rules."ports/implements-never-extends"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line ports/implements-never-extends -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
48
+
49
+ ## Limites
50
+
51
+ - `implements` est comparé par nom : `implements kernel.Clock` pour un port nommé `Clock` n'est pas reconnu ; importez le port par son nom.
52
+ - Un adaptateur qui étend son port par une classe intermédiaire d'un autre fichier n'est pas vu : les décorateurs le refusent au chargement du fichier.
53
+
54
+ ## Avec le checker de la CLI
55
+
56
+ `ddd-ts-kit check` signale le même identifiant à partir du texte des fichiers. Cette règle fait autorité pour le code.
@@ -1,3 +1,5 @@
1
+ **English** · [Français](ports-implements-never-extends.fr.md)
2
+
1
3
  # ddd-ts-kit/ports-implements-never-extends
2
4
 
3
5
  Architecture id: `ports/implements-never-extends`. Default severity: `error` in `recommended`, `error` in `strict`.
@@ -0,0 +1,56 @@
1
+ [English](ports-no-concrete-dependency.md) · **Français**
2
+ <!-- translation-of: ports-no-concrete-dependency.md sha256:16e87b49946851fe -->
3
+
4
+ # ddd-ts-kit/ports-no-concrete-dependency
5
+
6
+ Identifiant d'architecture : `ports/no-concrete-dependency`. Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : chaque fichier passé au lint.
9
+
10
+ ## Pourquoi
11
+
12
+ Une dépendance se nomme par son port, jamais par ce qui l'implémente. Un gestionnaire (handler) à qui l'on donne `KnexInvoiceRepository` est câblé à une technologie, ne peut pas recevoir de *fake*, et fait dépendre la couche application de l'infrastructure par sa propre déclaration. Dans le style déclaré, une classe énonce dans son constructeur ce dont elle dépend : les types de ses paramètres sont donc tenus comme les entrées d'une liste.
13
+
14
+ ## Signalé
15
+
16
+ - une classe nommée dans une liste de dépendances et importée depuis `infrastructure/` d'un contexte
17
+ - une classe nommée dans une liste de dépendances et importée depuis `test/fakes/` d'un contexte
18
+ - dans un projet au style déclaré, dans un fichier de rôle : une classe de l'un ou l'autre endroit qui type un paramètre du constructeur d'une classe portant un décorateur de déclaration sans liste (`constructor(private readonly invoices: KnexInvoiceRepository) {}`)
19
+
20
+ Incorrect :
21
+
22
+ ```ts
23
+ import { KnexInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/knex-invoice.repository';
24
+
25
+ @CommandHandler(IssueInvoiceCommand, [KnexInvoiceRepository, Clock])
26
+ export class IssueInvoiceHandler {}
27
+ ```
28
+
29
+ Correct :
30
+
31
+ ```ts
32
+ import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
33
+
34
+ @CommandHandler(IssueInvoiceCommand, [InvoiceRepository, Clock])
35
+ export class IssueInvoiceHandler {}
36
+ ```
37
+
38
+ ## Détails
39
+
40
+ Une liste de dépendances est le tableau qui nomme ce que reçoit un constructeur : le dernier argument d'un décorateur de déclaration de `@ddd-ts-kit/kernel/declarations` (`@CommandHandler(M, [..])`, `@QueryHandler`, `@IntegrationEventHandler`, `@DomainEventHandler`, `@Scheduled`, `@Repository`, `@Gateway`, `@Adapter`, `@Policy`) et le second argument de `.toClass(C, [..])` et de `.handledBy(H, [..])` de `@ddd-ts-kit/di`.
41
+
42
+ Le premier argument de `toClass` et de `handledBy` est l'implémentation et ne fait pas partie de la liste : `builder.bind(InvoiceRepository).toClass(KnexInvoiceRepository, [Database])` est la façon dont un module dit quelle classe se tient derrière un port. L'origine d'un nom se lit dans son import, à travers les chemins relatifs et l'`importAlias` configuré.
43
+
44
+ ## Options
45
+
46
+ Aucune.
47
+
48
+ `rules."ports/no-concrete-dependency"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line ports/no-concrete-dependency -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
49
+
50
+ ## Limites
51
+
52
+ - Une classe concrète déclarée dans le même fichier, ou atteinte par un *barrel* hors de `infrastructure/`, n'est pas vue : le compilateur refuse une classe concrète là où son port est attendu.
53
+
54
+ ## Avec le checker de la CLI
55
+
56
+ `ddd-ts-kit check` signale le même identifiant à partir du texte des fichiers. Cette règle fait autorité pour le code.
@@ -1,3 +1,5 @@
1
+ **English** · [Français](ports-no-concrete-dependency.fr.md)
2
+
1
3
  # ddd-ts-kit/ports-no-concrete-dependency
2
4
 
3
5
  Architecture id: `ports/no-concrete-dependency`. Default severity: `error` in `recommended`, `error` in `strict`.