@ddd-ts-kit/eslint-plugin 0.1.1 → 0.3.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 (112) hide show
  1. package/README.md +6 -1
  2. package/dist/project/config.d.ts +6 -0
  3. package/dist/project/config.d.ts.map +1 -1
  4. package/dist/project/is-judged.d.ts +5 -0
  5. package/dist/project/is-judged.d.ts.map +1 -0
  6. package/dist/project/is-judged.js +7 -0
  7. package/dist/project/is-judged.js.map +1 -0
  8. package/dist/project/parse-config.d.ts.map +1 -1
  9. package/dist/project/parse-config.js +6 -0
  10. package/dist/project/parse-config.js.map +1 -1
  11. package/dist/project/resolve-import.d.ts.map +1 -1
  12. package/dist/project/resolve-import.js +4 -1
  13. package/dist/project/resolve-import.js.map +1 -1
  14. package/dist/project/specifier-suffix.d.ts +6 -0
  15. package/dist/project/specifier-suffix.d.ts.map +1 -0
  16. package/dist/project/specifier-suffix.js +8 -0
  17. package/dist/project/specifier-suffix.js.map +1 -0
  18. package/dist/project/to-alias.d.ts +3 -2
  19. package/dist/project/to-alias.d.ts.map +1 -1
  20. package/dist/project/to-alias.js +4 -3
  21. package/dist/project/to-alias.js.map +1 -1
  22. package/dist/rules/clean-one-export-per-file.js +7 -3
  23. package/dist/rules/clean-one-export-per-file.js.map +1 -1
  24. package/dist/rules/declarations-constructor-injection.d.ts +5 -0
  25. package/dist/rules/declarations-constructor-injection.d.ts.map +1 -0
  26. package/dist/rules/declarations-constructor-injection.js +80 -0
  27. package/dist/rules/declarations-constructor-injection.js.map +1 -0
  28. package/dist/rules/domain-no-generic-error.js +1 -1
  29. package/dist/rules/domain-no-generic-error.js.map +1 -1
  30. package/dist/rules/errors-constructor-not-public.d.ts +2 -0
  31. package/dist/rules/errors-constructor-not-public.d.ts.map +1 -0
  32. package/dist/rules/errors-constructor-not-public.js +41 -0
  33. package/dist/rules/errors-constructor-not-public.js.map +1 -0
  34. package/dist/rules/errors-factory-name.d.ts +4 -0
  35. package/dist/rules/errors-factory-name.d.ts.map +1 -0
  36. package/dist/rules/errors-factory-name.js +88 -0
  37. package/dist/rules/errors-factory-name.js.map +1 -0
  38. package/dist/rules/errors-through-factory.d.ts +2 -0
  39. package/dist/rules/errors-through-factory.d.ts.map +1 -0
  40. package/dist/rules/errors-through-factory.js +39 -0
  41. package/dist/rules/errors-through-factory.js.map +1 -0
  42. package/dist/rules/imports-alias-only.d.ts.map +1 -1
  43. package/dist/rules/imports-alias-only.js +7 -9
  44. package/dist/rules/imports-alias-only.js.map +1 -1
  45. package/dist/rules/imports-extension.d.ts +5 -0
  46. package/dist/rules/imports-extension.d.ts.map +1 -0
  47. package/dist/rules/imports-extension.js +45 -0
  48. package/dist/rules/imports-extension.js.map +1 -0
  49. package/dist/rules/ports-no-concrete-dependency.d.ts +3 -1
  50. package/dist/rules/ports-no-concrete-dependency.d.ts.map +1 -1
  51. package/dist/rules/ports-no-concrete-dependency.js +51 -3
  52. package/dist/rules/ports-no-concrete-dependency.js.map +1 -1
  53. package/dist/rules/rules.d.ts.map +1 -1
  54. package/dist/rules/rules.js +10 -0
  55. package/dist/rules/rules.js.map +1 -1
  56. package/dist/support/declarations/declared-roles.d.ts.map +1 -1
  57. package/dist/support/declarations/declared-roles.js +1 -0
  58. package/dist/support/declarations/declared-roles.js.map +1 -1
  59. package/dist/support/errors/constant-case.d.ts +3 -0
  60. package/dist/support/errors/constant-case.d.ts.map +1 -0
  61. package/dist/support/errors/constant-case.js +6 -0
  62. package/dist/support/errors/constant-case.js.map +1 -0
  63. package/dist/support/errors/is-error-class.d.ts +4 -0
  64. package/dist/support/errors/is-error-class.d.ts.map +1 -0
  65. package/dist/support/errors/is-error-class.js +6 -0
  66. package/dist/support/errors/is-error-class.js.map +1 -0
  67. package/dist/support/errors/is-error-file.d.ts +4 -0
  68. package/dist/support/errors/is-error-file.d.ts.map +1 -0
  69. package/dist/support/errors/is-error-file.js +10 -0
  70. package/dist/support/errors/is-error-file.js.map +1 -0
  71. package/dist/support/injection/language-types.d.ts +3 -0
  72. package/dist/support/injection/language-types.d.ts.map +1 -0
  73. package/dist/support/injection/language-types.js +20 -0
  74. package/dist/support/injection/language-types.js.map +1 -0
  75. package/dist/support/injection/not-classes.d.ts +4 -0
  76. package/dist/support/injection/not-classes.d.ts.map +1 -0
  77. package/dist/support/injection/not-classes.js +20 -0
  78. package/dist/support/injection/not-classes.js.map +1 -0
  79. package/dist/support/injection/parameter-reading.d.ts +9 -0
  80. package/dist/support/injection/parameter-reading.d.ts.map +1 -0
  81. package/dist/support/injection/parameter-reading.js +2 -0
  82. package/dist/support/injection/parameter-reading.js.map +1 -0
  83. package/dist/support/injection/read-parameter.d.ts +9 -0
  84. package/dist/support/injection/read-parameter.d.ts.map +1 -0
  85. package/dist/support/injection/read-parameter.js +41 -0
  86. package/dist/support/injection/read-parameter.js.map +1 -0
  87. package/dist/support/injection/written-name.d.ts +4 -0
  88. package/dist/support/injection/written-name.d.ts.map +1 -0
  89. package/dist/support/injection/written-name.js +13 -0
  90. package/dist/support/injection/written-name.js.map +1 -0
  91. package/dist/version.d.ts +1 -1
  92. package/dist/version.js +1 -1
  93. package/docs/rules/clean-one-export-per-file.md +1 -1
  94. package/docs/rules/context-declared-relationship.md +2 -2
  95. package/docs/rules/context-extractable.md +3 -3
  96. package/docs/rules/context-published-language-is-a-contract.md +1 -1
  97. package/docs/rules/context-published-language-only.md +2 -2
  98. package/docs/rules/declarations-constructor-injection.md +89 -0
  99. package/docs/rules/declarations-role-declared.md +15 -9
  100. package/docs/rules/domain-events-transactional-before-commit.md +1 -1
  101. package/docs/rules/errors-constructor-not-public.md +53 -0
  102. package/docs/rules/errors-factory-name.md +50 -0
  103. package/docs/rules/errors-through-factory.md +45 -0
  104. package/docs/rules/imports-alias-only.md +10 -9
  105. package/docs/rules/imports-extension.md +83 -0
  106. package/docs/rules/layer-application-inward.md +3 -3
  107. package/docs/rules/layer-domain-purity.md +3 -3
  108. package/docs/rules/layer-infrastructure-no-presentation.md +2 -2
  109. package/docs/rules/layer-presentation-no-infrastructure.md +2 -2
  110. package/docs/rules/ports-no-concrete-dependency.md +4 -3
  111. package/docs/rules/test-no-mocks.md +1 -1
  112. package/package.json +1 -1
@@ -23,7 +23,7 @@ Incorrect:
23
23
  import { eq } from 'drizzle-orm';
24
24
  import { retry } from '@ddd-ts-kit/aspects';
25
25
  import { RedisCache } from '@ddd-ts-kit/redis';
26
- import { DrizzleInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository.js';
26
+ import { DrizzleInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository';
27
27
  ```
28
28
 
29
29
  Correct:
@@ -31,8 +31,8 @@ Correct:
31
31
  ```ts
32
32
  // a port is an abstract class: the type of the dependency and its injection token
33
33
  import { Cache, Clock } from '@ddd-ts-kit/kernel';
34
- import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository.js';
35
- import { PaymentGateway } from '@/contexts/billing/application/ports/payment-gateway.port.js';
34
+ import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
35
+ import { PaymentGateway } from '@/contexts/billing/application/ports/payment-gateway.port';
36
36
 
37
37
  // declared style
38
38
  import { CommandHandler } from '@ddd-ts-kit/kernel/declarations';
@@ -24,7 +24,7 @@ Incorrect:
24
24
  import { z } from 'zod';
25
25
  import { randomUUID } from 'node:crypto';
26
26
  import { Logged } from '@ddd-ts-kit/aspects/decorators';
27
- import type { InvoiceRow } from '@/contexts/billing/infrastructure/persistence/billing.schema.js';
27
+ import type { InvoiceRow } from '@/contexts/billing/infrastructure/persistence/billing.schema';
28
28
  ```
29
29
 
30
30
  Correct:
@@ -32,8 +32,8 @@ Correct:
32
32
  ```ts
33
33
  // src/contexts/billing/domain/aggregates/invoice.aggregate.ts
34
34
  import { AggregateRoot } from '@ddd-ts-kit/kernel';
35
- import type { Amount } from '@/contexts/billing/domain/value-objects/amount.vo.js';
36
- import { Money } from '@/shared-kernel/money.vo.js';
35
+ import type { Amount } from '@/contexts/billing/domain/value-objects/amount.vo';
36
+ import { Money } from '@/shared-kernel/money.vo';
37
37
  ```
38
38
 
39
39
  ## Details
@@ -16,13 +16,13 @@ Incorrect:
16
16
 
17
17
  ```ts
18
18
  // src/contexts/billing/infrastructure/persistence/drizzle-invoice.repository.ts
19
- import type { IssueInvoiceBody } from '@/contexts/billing/presentation/http/issue-invoice.dto.js';
19
+ import type { IssueInvoiceBody } from '@/contexts/billing/presentation/http/issue-invoice.dto';
20
20
  ```
21
21
 
22
22
  Correct:
23
23
 
24
24
  ```ts
25
- import type { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository.js';
25
+ import type { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
26
26
  ```
27
27
 
28
28
  ## Details
@@ -16,13 +16,13 @@ Incorrect:
16
16
 
17
17
  ```ts
18
18
  // src/contexts/billing/presentation/http/issue-invoice.route.ts
19
- import { DrizzleInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository.js';
19
+ import { DrizzleInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository';
20
20
  ```
21
21
 
22
22
  Correct:
23
23
 
24
24
  ```ts
25
- import { IssueInvoiceCommand } from '@/contexts/billing/application/commands/issue-invoice/issue-invoice.command.js';
25
+ import { IssueInvoiceCommand } from '@/contexts/billing/application/commands/issue-invoice/issue-invoice.command';
26
26
  ```
27
27
 
28
28
  ## Details
@@ -6,17 +6,18 @@ Applies to: every linted file.
6
6
 
7
7
  ## Why
8
8
 
9
- A dependency list names ports, never what implements them. A handler that lists `KnexInvoiceRepository` is wired to one technology, cannot be given a fake, and makes the application layer depend on infrastructure through its own registration.
9
+ A dependency is named by its port, never by what implements it. A handler that is given `KnexInvoiceRepository` is wired to one technology, cannot be given a fake, and makes the application layer depend on infrastructure through its own registration. In the declared style a class states what it depends on in its constructor, so the types of its parameters are held like the entries of a list.
10
10
 
11
11
  ## Reported
12
12
 
13
13
  - a class named in a dependency list and imported from `infrastructure/` of a context
14
14
  - a class named in a dependency list and imported from `test/fakes/` of a context
15
+ - in a declared-style project, in a role file: a class of either place that types a constructor parameter of a class carrying a declaration decorator without a list (`constructor(private readonly invoices: KnexInvoiceRepository) {}`)
15
16
 
16
17
  Incorrect:
17
18
 
18
19
  ```ts
19
- import { KnexInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/knex-invoice.repository.js';
20
+ import { KnexInvoiceRepository } from '@/contexts/billing/infrastructure/persistence/knex-invoice.repository';
20
21
 
21
22
  @CommandHandler(IssueInvoiceCommand, [KnexInvoiceRepository, Clock])
22
23
  export class IssueInvoiceHandler {}
@@ -25,7 +26,7 @@ export class IssueInvoiceHandler {}
25
26
  Correct:
26
27
 
27
28
  ```ts
28
- import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository.js';
29
+ import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository';
29
30
 
30
31
  @CommandHandler(IssueInvoiceCommand, [InvoiceRepository, Clock])
31
32
  export class IssueInvoiceHandler {}
@@ -17,7 +17,7 @@ Incorrect:
17
17
 
18
18
  ```ts
19
19
  const save = vi.fn();
20
- vi.mock('@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository.js');
20
+ vi.mock('@/contexts/billing/infrastructure/persistence/drizzle-invoice.repository');
21
21
  ```
22
22
 
23
23
  Correct:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/eslint-plugin",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "AST-accurate ESLint rules for DDD and Clean Architecture in TypeScript: layer and context isolation, domain purity, clean code ordering.",
5
5
  "license": "MIT",
6
6
  "repository": {