@ddd-ts-kit/eslint-plugin 0.2.0 → 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 (41) hide show
  1. package/README.md +3 -0
  2. package/dist/project/config.d.ts +2 -0
  3. package/dist/project/config.d.ts.map +1 -1
  4. package/dist/project/parse-config.d.ts.map +1 -1
  5. package/dist/project/parse-config.js +2 -0
  6. package/dist/project/parse-config.js.map +1 -1
  7. package/dist/rules/domain-no-generic-error.js +1 -1
  8. package/dist/rules/domain-no-generic-error.js.map +1 -1
  9. package/dist/rules/errors-constructor-not-public.d.ts +2 -0
  10. package/dist/rules/errors-constructor-not-public.d.ts.map +1 -0
  11. package/dist/rules/errors-constructor-not-public.js +41 -0
  12. package/dist/rules/errors-constructor-not-public.js.map +1 -0
  13. package/dist/rules/errors-factory-name.d.ts +4 -0
  14. package/dist/rules/errors-factory-name.d.ts.map +1 -0
  15. package/dist/rules/errors-factory-name.js +88 -0
  16. package/dist/rules/errors-factory-name.js.map +1 -0
  17. package/dist/rules/errors-through-factory.d.ts +2 -0
  18. package/dist/rules/errors-through-factory.d.ts.map +1 -0
  19. package/dist/rules/errors-through-factory.js +39 -0
  20. package/dist/rules/errors-through-factory.js.map +1 -0
  21. package/dist/rules/rules.d.ts.map +1 -1
  22. package/dist/rules/rules.js +6 -0
  23. package/dist/rules/rules.js.map +1 -1
  24. package/dist/support/errors/constant-case.d.ts +3 -0
  25. package/dist/support/errors/constant-case.d.ts.map +1 -0
  26. package/dist/support/errors/constant-case.js +6 -0
  27. package/dist/support/errors/constant-case.js.map +1 -0
  28. package/dist/support/errors/is-error-class.d.ts +4 -0
  29. package/dist/support/errors/is-error-class.d.ts.map +1 -0
  30. package/dist/support/errors/is-error-class.js +6 -0
  31. package/dist/support/errors/is-error-class.js.map +1 -0
  32. package/dist/support/errors/is-error-file.d.ts +4 -0
  33. package/dist/support/errors/is-error-file.d.ts.map +1 -0
  34. package/dist/support/errors/is-error-file.js +10 -0
  35. package/dist/support/errors/is-error-file.js.map +1 -0
  36. package/dist/version.d.ts +1 -1
  37. package/dist/version.js +1 -1
  38. package/docs/rules/errors-constructor-not-public.md +53 -0
  39. package/docs/rules/errors-factory-name.md +50 -0
  40. package/docs/rules/errors-through-factory.md +45 -0
  41. package/package.json +1 -1
package/README.md CHANGED
@@ -104,6 +104,9 @@ is an error whatever the configured limit). `strict` sets every rule to `error`.
104
104
  | [`domain/aggregate-encapsulation`](docs/rules/domain-aggregate-encapsulation.md) | `ddd-ts-kit/domain-aggregate-encapsulation` | aggregates and entities: no public constructor, no public mutable property, no setter | `error` | custom |
105
105
  | [`domain/value-object-immutability`](docs/rules/domain-value-object-immutability.md) | `ddd-ts-kit/domain-value-object-immutability` | value objects: every property `readonly`, no setter, no write to `this` | `error` | custom |
106
106
  | [`domain/no-generic-error`](docs/rules/domain-no-generic-error.md) | `ddd-ts-kit/domain-no-generic-error` | no `throw new Error(...)` in `domain/` and `application/` | `error` | custom |
107
+ | [`errors/through-factory`](docs/rules/errors-through-factory.md) | `ddd-ts-kit/errors-through-factory` | under `"stack.refusals": "factories"`, no `new` of a class imported from `domain/errors/`: a refusal is built by a static factory of its concept class | `error` | custom |
108
+ | [`errors/constructor-not-public`](docs/rules/errors-constructor-not-public.md) | `ddd-ts-kit/errors-constructor-not-public` | under `"stack.refusals": "factories"`, an error class of `domain/errors/` has no public constructor, declared or inherited from `DomainError` | `error` | custom |
109
+ | [`errors/factory-name`](docs/rules/errors-factory-name.md) | `ddd-ts-kit/errors-factory-name` | under `"stack.refusals": "factories"`, a factory is not named `create`, `make`, `of` or `error1`, and its code is its name in constant case, alone or with the name of the concept | `error` | custom |
107
110
  | [`application/handler-shape`](docs/rules/application-handler-shape.md) | `ddd-ts-kit/application-handler-shape` | a `*.handler.ts` exports one class whose single public method is `execute` | `error` | custom |
108
111
  | [`application/command-query-separation`](docs/rules/application-command-query-separation.md) | `ddd-ts-kit/application-command-query-separation` | nothing under `application/queries` calls `save`, `delete`, `publish` on a dependency | `warn` | custom |
109
112
  | [`domain-events/dispatched-on-save`](docs/rules/domain-events-dispatched-on-save.md) | `ddd-ts-kit/domain-events-dispatched-on-save` | no `pullEvents()` in `application/` and `infrastructure/`; no `DomainEventDispatcher` imported, listed as a dependency or received by a constructor in `application/commands`, `application/queries` and a repository adapter | `error` | custom |
@@ -18,6 +18,8 @@ export interface Stack {
18
18
  readonly assembly: Assembly;
19
19
  /** Where a declared class states what it depends on: its constructor signature, or the list of its decorator. A config that does not say is `listed`. */
20
20
  readonly dependencies: 'signature' | 'listed';
21
+ /** How a domain error is written: static factories on one class per concept, or a class per error. A config that does not say is `classes`. */
22
+ readonly refusals: 'factories' | 'classes';
21
23
  /** Kept as written: with `prisma` the generated client under `generated/` has an import alias of its own. */
22
24
  readonly orm: string;
23
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/project/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,WAAW,KAAK;IACpB,qIAAqI;IACrI,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,iHAAiH;IACjH,QAAQ,CAAC,QAAQ,EA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":"parse-config.d.ts","sourceRoot":"","sources":["../../src/project/parse-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO/G,+GAA+G;AAC/G,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAmB1C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAyBhD"}
1
+ {"version":3,"file":"parse-config.d.ts","sourceRoot":"","sources":["../../src/project/parse-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO/G,+GAA+G;AAC/G,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAoB1C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAyBhD"}
@@ -7,6 +7,7 @@ export const FUNCTION_LINES_CEILING = 100;
7
7
  const STYLES = ['declared', 'explicit'];
8
8
  const ASSEMBLIES = ['barrel', 'discovery'];
9
9
  const DEPENDENCY_STATEMENTS = ['signature', 'listed'];
10
+ const REFUSAL_FORMS = ['factories', 'classes'];
10
11
  const KERNEL = ['@ddd-ts-kit/kernel'];
11
12
  /** The application layer declares its permissions and policies with `@ddd-ts-kit/auth`, which imports the kernel only. */
12
13
  const APPLICATION = [...KERNEL, '@ddd-ts-kit/auth'];
@@ -49,6 +50,7 @@ function parseStack(value) {
49
50
  style: oneOf(STYLES, raw['style'], 'explicit'),
50
51
  assembly: oneOf(ASSEMBLIES, raw['assembly'], 'barrel'),
51
52
  dependencies: oneOf(DEPENDENCY_STATEMENTS, raw['dependencies'], 'listed'),
53
+ refusals: oneOf(REFUSAL_FORMS, raw['refusals'], 'classes'),
52
54
  orm: text(raw['orm'], 'drizzle'),
53
55
  };
54
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-config.js","sourceRoot":"","sources":["../../src/project/parse-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBA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AC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrH,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,QAA2B;IAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5F,CAAC;AAED,SAAS,KAAK,CAAmB,MAAoB,EAAE,SAAkB,EAAE,QAAW;IACpF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,IAAI,QAAQ,CAAC;AACjE,CAAC;AAED,SAAS,IAAI,CAAC,KAAc,EAAE,QAAgB;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC"}
@@ -7,7 +7,7 @@ export const domainNoGenericError = defineRule({
7
7
  recommended: 'error',
8
8
  description: 'No `throw new Error(...)` in domain/ or application/: an expected failure is a DomainError with a stable code.',
9
9
  messages: {
10
- generic: 'A generic Error says nothing a caller can act on. Throw a DomainError with a stable code (`ddd-ts-kit generate domain-error {{context}} <Name>`): presentation maps the code to a status in one place.',
10
+ generic: 'A generic Error says nothing a caller can act on. Throw a DomainError with a stable code, built by a factory of the error class of its concept (`ddd-ts-kit generate error {{context}} <Concept> <refusal>`): presentation maps the code to a status in one place.',
11
11
  },
12
12
  create({ file, sourceCode, report }) {
13
13
  const { location } = file;
@@ -1 +1 @@
1
- {"version":3,"file":"domain-no-generic-error.js","sourceRoot":"","sources":["../../src/rules/domain-no-generic-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,C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ructor", [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
2
+ //# sourceMappingURL=errors-constructor-not-public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-constructor-not-public.d.ts","sourceRoot":"","sources":["../../src/rules/errors-constructor-not-public.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,0BAA0B,iMA0CrC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import { className } from '../support/classes/class-name.js';
3
+ import { constructorOf } from '../support/classes/constructor-of.js';
4
+ import { visibilityOf } from '../support/classes/visibility-of.js';
5
+ import { isErrorClass } from '../support/errors/is-error-class.js';
6
+ import { isErrorFile } from '../support/errors/is-error-file.js';
7
+ import { defineRule } from '../support/rule/define-rule.js';
8
+ export const errorsConstructorNotPublic = defineRule({
9
+ id: 'errors/constructor-not-public',
10
+ type: 'problem',
11
+ recommended: 'error',
12
+ description: 'Under "stack.refusals": "factories", the constructor of an error class of domain/errors/ is not public: the class extends ConceptError and declares none, or declares it private or protected.',
13
+ messages: {
14
+ publicConstructor: 'The constructor of {{className}} is public: anyone can build a refusal with a code and a message of their own. Extend ConceptError of @ddd-ts-kit/kernel and remove the constructor (its own is protected), then build each refusal in a static factory with `{{className}}.refusal(code, message, facts)`.',
15
+ inheritedPublic: '{{className}} extends DomainError and declares no constructor, so it inherits a public one. Extend ConceptError of @ddd-ts-kit/kernel, whose constructor is protected, and build each refusal in a static factory with `{{className}}.refusal(code, message, facts)`.',
16
+ },
17
+ create({ file, report }) {
18
+ if (!isErrorFile(file)) {
19
+ return {};
20
+ }
21
+ return {
22
+ ClassBody(body) {
23
+ const owner = body.parent;
24
+ if (!isErrorClass(owner) || owner.abstract) {
25
+ return;
26
+ }
27
+ const constructor = constructorOf(body);
28
+ const data = { className: className(owner) };
29
+ if (constructor !== undefined && visibilityOf(constructor) === 'public') {
30
+ report({ node: constructor.key, messageId: 'publicConstructor', data });
31
+ }
32
+ if (constructor === undefined &&
33
+ owner.superClass?.type === AST_NODE_TYPES.Identifier &&
34
+ owner.superClass.name === 'DomainError') {
35
+ report({ node: owner.id ?? owner, messageId: 'inheritedPublic', data });
36
+ }
37
+ },
38
+ };
39
+ },
40
+ });
41
+ //# sourceMappingURL=errors-constructor-not-public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-constructor-not-public.js","sourceRoot":"","sources":["../../src/rules/errors-constructor-not-public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAA0C;IAC5F,EAAE,EAAE,+BAA+B;IACnC,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,OAAO;IACpB,WAAW,EACT,gMAAgM;IAClM,QAAQ,EAAE;QACR,iBAAiB,EACf,6SAA6S;QAC/S,eAAe,EACb,uQAAuQ;KAC1Q;IACD,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;QACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,SAAS,CAAC,IAAI;gBACZ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;gBAE1B,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBAC3C,OAAO;gBACT,CAAC;gBAED,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM,IAAI,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBAE7C,IAAI,WAAW,KAAK,SAAS,IAAI,YAAY,CAAC,WAAW,CAAC,KAAK,QAAQ,EAAE,CAAC;oBACxE,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1E,CAAC;gBAED,IACE,WAAW,KAAK,SAAS;oBACzB,KAAK,CAAC,UAAU,EAAE,IAAI,KAAK,cAAc,CAAC,UAAU;oBACpD,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,aAAa,EACvC,CAAC;oBACD,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,IAAI,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1E,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ type MessageId = 'vagueName' | 'codeNotLiteral' | 'codeFormat' | 'mismatch';
2
+ export declare const errorsFactoryName: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ export {};
4
+ //# sourceMappingURL=errors-factory-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-factory-name.d.ts","sourceRoot":"","sources":["../../src/rules/errors-factory-name.ts"],"names":[],"mappings":"AAUA,KAAK,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,YAAY,GAAG,UAAU,CAAC;AAY5E,eAAO,MAAM,iBAAiB,mKAmC5B,CAAC"}
@@ -0,0 +1,88 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import { className } from '../support/classes/class-name.js';
3
+ import { memberName } from '../support/classes/member-name.js';
4
+ import { visibilityOf } from '../support/classes/visibility-of.js';
5
+ import { descendants } from '../support/descendants.js';
6
+ import { constantCase } from '../support/errors/constant-case.js';
7
+ import { isErrorClass } from '../support/errors/is-error-class.js';
8
+ import { isErrorFile } from '../support/errors/is-error-file.js';
9
+ import { defineRule } from '../support/rule/define-rule.js';
10
+ /** Names that say an error is being made, never which rule of the business refused. */
11
+ const VAGUE_NAMES = ['create', 'make', 'of', 'from', 'build', 'new', 'error', 'failure', 'fail', 'refusal', 'refuse'];
12
+ const ERROR_CODE = /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/;
13
+ export const errorsFactoryName = defineRule({
14
+ id: 'errors/factory-name',
15
+ type: 'problem',
16
+ recommended: 'error',
17
+ description: 'Under "stack.refusals": "factories", a static factory of an error class is named after the refusal, in the words of the business, and its code is that name in constant case, alone or with the name of the concept.',
18
+ messages: {
19
+ vagueName: '`{{className}}.{{name}}` says that an error is built, not which rule refused. Name the factory after the refusal, as a domain expert would say it: `slotTaken`, `alreadyConfirmed`, `notFound`.',
20
+ codeNotLiteral: 'The code `{{className}}.{{name}}` gives to `refusal(...)` is not a string literal. Write it in place, in constant case: the code is the contract of the refusal, read by the HTTP mapping, the OpenAPI document, the audit trail and the tests.',
21
+ codeFormat: 'The code "{{code}}" of `{{className}}.{{name}}` is not in constant case. Write upper-case words separated by underscores, for example {{expected}}.',
22
+ mismatch: 'The factory `{{className}}.{{name}}` sets the code "{{code}}", which says something else. Write {{expected}}, or rename the factory after the code: a reader of the code that refuses and a reader of the contract must meet the same words.',
23
+ },
24
+ create({ file, report }) {
25
+ if (!isErrorFile(file)) {
26
+ return {};
27
+ }
28
+ return {
29
+ ClassBody(body) {
30
+ if (!isErrorClass(body.parent)) {
31
+ return;
32
+ }
33
+ const owner = className(body.parent);
34
+ for (const method of body.body.filter(isFactory)) {
35
+ judge({ name: memberName(method) ?? '', concept: owner, method }, report);
36
+ }
37
+ },
38
+ };
39
+ },
40
+ });
41
+ function isFactory(member) {
42
+ return (member.type === AST_NODE_TYPES.MethodDefinition &&
43
+ member.static &&
44
+ member.kind === 'method' &&
45
+ visibilityOf(member) === 'public' &&
46
+ refusalCallIn(member) !== undefined);
47
+ }
48
+ function refusalCallIn(method) {
49
+ return [...descendants(method.value)].find(isRefusalCall);
50
+ }
51
+ function isRefusalCall(node) {
52
+ return (node.type === AST_NODE_TYPES.CallExpression &&
53
+ node.callee.type === AST_NODE_TYPES.MemberExpression &&
54
+ node.callee.property.type === AST_NODE_TYPES.Identifier &&
55
+ node.callee.property.name === 'refusal');
56
+ }
57
+ function judge(factory, report) {
58
+ const { name, concept, method } = factory;
59
+ const data = { className: concept, name };
60
+ if (VAGUE_NAMES.includes(name.toLowerCase()) || /\d/.test(name)) {
61
+ report({ node: method.key, messageId: 'vagueName', data });
62
+ return;
63
+ }
64
+ const [code] = refusalCallIn(method)?.arguments ?? [];
65
+ if (code?.type !== AST_NODE_TYPES.Literal || typeof code.value !== 'string') {
66
+ report({ node: code ?? method.key, messageId: 'codeNotLiteral', data });
67
+ return;
68
+ }
69
+ judgeCode(factory, { node: code, value: code.value }, report);
70
+ }
71
+ function judgeCode(factory, code, report) {
72
+ const expected = expectedCodes(factory);
73
+ const data = { className: factory.concept, name: factory.name, code: code.value };
74
+ if (!ERROR_CODE.test(code.value)) {
75
+ report({ node: code.node, messageId: 'codeFormat', data: { ...data, expected: expected[0] ?? '' } });
76
+ return;
77
+ }
78
+ if (!expected.includes(code.value)) {
79
+ report({ node: code.node, messageId: 'mismatch', data: { ...data, expected: expected.join(' or ') } });
80
+ }
81
+ }
82
+ /** `AppointmentError.notFound` may set `NOT_FOUND`, `APPOINTMENT_NOT_FOUND` or `NOT_FOUND_APPOINTMENT`. */
83
+ function expectedCodes({ name, concept }) {
84
+ const refusal = constantCase(name);
85
+ const subject = constantCase(concept.replace(/Error$/, ''));
86
+ return subject === '' ? [refusal] : [refusal, `${subject}_${refusal}`, `${refusal}_${subject}`];
87
+ }
88
+ //# sourceMappingURL=errors-factory-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-factory-name.js","sourceRoot":"","sources":["../../src/rules/errors-factory-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAe,MAAM,gCAAgC,CAAC;AAIzE,uFAAuF;AACvF,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACtH,MAAM,UAAU,GAAG,+BAA+B,CAAC;AAQnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAY;IACrD,EAAE,EAAE,qBAAqB;IACzB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,OAAO;IACpB,WAAW,EACT,sNAAsN;IACxN,QAAQ,EAAE;QACR,SAAS,EACP,iMAAiM;QACnM,cAAc,EACZ,iPAAiP;QACnP,UAAU,EACR,qJAAqJ;QACvJ,QAAQ,EACN,8OAA8O;KACjP;IACD,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;QACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACZ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AAE,CAAC;QACjC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAErG,OAAO;IACT,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IACzG,CAAC;AACH,CAAC;AAED,2GAA2G;AAC3G,SAAS,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAW;IAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IAE5D,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,OAAO,IAAI,OAAO,EAAE,EAAE,GAAG,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;AAClG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const errorsThroughFactory: import("@typescript-eslint/utils/ts-eslint").RuleModule<"constructed", [], import("../index.js").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
2
+ //# sourceMappingURL=errors-through-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-through-factory.d.ts","sourceRoot":"","sources":["../../src/rules/errors-through-factory.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,uKAkC/B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import { defineRule } from '../support/rule/define-rule.js';
3
+ const ERRORS_DIRECTORY = /(^|\/)domain\/errors\//;
4
+ export const errorsThroughFactory = defineRule({
5
+ id: 'errors/through-factory',
6
+ type: 'problem',
7
+ recommended: 'error',
8
+ description: 'Under "stack.refusals": "factories", a domain error is built by a static factory of its concept class: no `new` of a class of domain/errors/ outside that class.',
9
+ messages: {
10
+ constructed: '`new {{name}}(...)` builds a refusal outside its error class, with whatever code and message the caller writes. Call the static factory named after the refusal, `throw <Concept>Error.<refusal>(...)`, and add it when it is missing: `ddd-ts-kit generate error {{context}} <Concept> <refusal>`.',
11
+ },
12
+ create({ file, report }) {
13
+ const { location } = file;
14
+ if (file.config.stack.refusals !== 'factories' || location.area !== 'context') {
15
+ return {};
16
+ }
17
+ const errors = new Set();
18
+ return {
19
+ ImportDeclaration(node) {
20
+ if (ERRORS_DIRECTORY.test(node.source.value)) {
21
+ for (const name of importedNames(node)) {
22
+ errors.add(name);
23
+ }
24
+ }
25
+ },
26
+ NewExpression(node) {
27
+ if (node.callee.type === AST_NODE_TYPES.Identifier && errors.has(node.callee.name)) {
28
+ report({ node, messageId: 'constructed', data: { name: node.callee.name, context: location.context } });
29
+ }
30
+ },
31
+ };
32
+ },
33
+ });
34
+ function importedNames(node) {
35
+ return node.specifiers
36
+ .filter((specifier) => specifier.type === AST_NODE_TYPES.ImportSpecifier)
37
+ .map((specifier) => specifier.local.name);
38
+ }
39
+ //# sourceMappingURL=errors-through-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-through-factory.js","sourceRoot":"","sources":["../../src/rules/errors-through-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,gBAAgB,GAAG,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AC,IAAgC;IACrD,OAAO,IAAI,CAAC,UAAU;SACnB,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,CAAC;SACxE,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAwGlE,+HAA+H;AAC/H,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEnD,CAAC"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AA8GlE,+HAA+H;AAC/H,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEnD,CAAC"}
@@ -23,6 +23,9 @@ import { domainAggregateEncapsulation } from './domain-aggregate-encapsulation.j
23
23
  import { domainEventsDispatchedOnSave } from './domain-events-dispatched-on-save.js';
24
24
  import { domainEventsTransactionalBeforeCommit } from './domain-events-transactional-before-commit.js';
25
25
  import { domainNoGenericError } from './domain-no-generic-error.js';
26
+ import { errorsConstructorNotPublic } from './errors-constructor-not-public.js';
27
+ import { errorsFactoryName } from './errors-factory-name.js';
28
+ import { errorsThroughFactory } from './errors-through-factory.js';
26
29
  import { domainValueObjectImmutability } from './domain-value-object-immutability.js';
27
30
  import { eventsConsumerIdempotent } from './events-consumer-idempotent.js';
28
31
  import { eventsNameFormat } from './events-name-format.js';
@@ -68,6 +71,9 @@ const ALL = [
68
71
  domainAggregateEncapsulation,
69
72
  domainValueObjectImmutability,
70
73
  domainNoGenericError,
74
+ errorsThroughFactory,
75
+ errorsConstructorNotPublic,
76
+ errorsFactoryName,
71
77
  applicationHandlerShape,
72
78
  applicationCommandQuerySeparation,
73
79
  domainEventsDispatchedOnSave,
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/rules/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,mCAAmC,EACnC,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C,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAC7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** `slotTaken` and `SlotTaken` both read `SLOT_TAKEN`. */
2
+ export declare function constantCase(name: string): string;
3
+ //# sourceMappingURL=constant-case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant-case.d.ts","sourceRoot":"","sources":["../../../src/support/errors/constant-case.ts"],"names":[],"mappings":"AAEA,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD"}
@@ -0,0 +1,6 @@
1
+ import { splitWords } from '../words/split-words.js';
2
+ /** `slotTaken` and `SlotTaken` both read `SLOT_TAKEN`. */
3
+ export function constantCase(name) {
4
+ return splitWords(name).join('_').toUpperCase();
5
+ }
6
+ //# sourceMappingURL=constant-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant-case.js","sourceRoot":"","sources":["../../../src/support/errors/constant-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,0DAA0D;AAC1D,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ClassNode } from '../classes/class-name.js';
2
+ /** A class of an error file that extends something: `ConceptError`, `DomainError`, or a base of the project. */
3
+ export declare function isErrorClass(node: ClassNode): boolean;
4
+ //# sourceMappingURL=is-error-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-error-class.d.ts","sourceRoot":"","sources":["../../../src/support/errors/is-error-class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,gHAAgH;AAChH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAErD"}
@@ -0,0 +1,6 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ /** A class of an error file that extends something: `ConceptError`, `DomainError`, or a base of the project. */
3
+ export function isErrorClass(node) {
4
+ return node.superClass?.type === AST_NODE_TYPES.Identifier;
5
+ }
6
+ //# sourceMappingURL=is-error-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-error-class.js","sourceRoot":"","sources":["../../../src/support/errors/is-error-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,gHAAgH;AAChH,MAAM,UAAU,YAAY,CAAC,IAAe;IAC1C,OAAO,IAAI,CAAC,UAAU,EAAE,IAAI,KAAK,cAAc,CAAC,UAAU,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LintedFile } from '../../project/linted-file.js';
2
+ /** A production file of `domain/errors/` of a context, in a project that builds its refusals through factories. */
3
+ export declare function isErrorFile(file: LintedFile): boolean;
4
+ //# sourceMappingURL=is-error-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-error-file.d.ts","sourceRoot":"","sources":["../../../src/support/errors/is-error-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,mHAAmH;AACnH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAUrD"}
@@ -0,0 +1,10 @@
1
+ /** A production file of `domain/errors/` of a context, in a project that builds its refusals through factories. */
2
+ export function isErrorFile(file) {
3
+ const { location } = file;
4
+ return (file.config.stack.refusals === 'factories' &&
5
+ location.area === 'context' &&
6
+ location.layer === 'domain' &&
7
+ location.inside[0] === 'errors' &&
8
+ !file.isTest);
9
+ }
10
+ //# sourceMappingURL=is-error-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-error-file.js","sourceRoot":"","sources":["../../../src/support/errors/is-error-file.ts"],"names":[],"mappings":"AAEA,mHAAmH;AACnH,MAAM,UAAU,WAAW,CAAC,IAAgB;IAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE1B,OAAO,CACL,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,WAAW;QAC1C,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC3B,QAAQ,CAAC,KAAK,KAAK,QAAQ;QAC3B,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ;QAC/B,CAAC,IAAI,CAAC,MAAM,CACb,CAAC;AACJ,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.0";
1
+ export declare const VERSION = "0.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.2.0';
1
+ export const VERSION = '0.3.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -0,0 +1,53 @@
1
+ # ddd-ts-kit/errors-constructor-not-public
2
+
3
+ Architecture id: `errors/constructor-not-public`. Default severity: `error` in `recommended`, `error` in `strict`.
4
+
5
+ Applies to: the production files of `domain/errors/` of a context, in a project whose config says `"stack.refusals": "factories"`.
6
+
7
+ ## Why
8
+
9
+ A public constructor lets any caller build a refusal with a code and a message of its own. `ConceptError` of `@ddd-ts-kit/kernel` has a protected constructor, and a class that extends it declares none: a refusal then exists only through a static factory.
10
+
11
+ ## Reported
12
+
13
+ - a class that extends another one and declares a public constructor
14
+ - a class that extends `DomainError` and declares no constructor: it inherits a public one
15
+
16
+ An abstract class is not judged.
17
+
18
+ Incorrect:
19
+
20
+ ```ts
21
+ export class SlotTakenError extends DomainError {
22
+ readonly code = 'SLOT_TAKEN';
23
+
24
+ constructor(calendarId: string) {
25
+ super(`The slot on calendar ${calendarId} is already held.`);
26
+ }
27
+ }
28
+ ```
29
+
30
+ Correct:
31
+
32
+ ```ts
33
+ export class AppointmentError extends ConceptError {
34
+ static slotTaken(calendarId: string) {
35
+ return AppointmentError.refusal('SLOT_TAKEN', `The slot on calendar ${calendarId} is already held.`, { calendarId });
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Options
41
+
42
+ None.
43
+
44
+ `rules."errors/constructor-not-public"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line errors/constructor-not-public -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
45
+
46
+ ## Limits
47
+
48
+ - A class that extends a base of the project and declares no constructor is trusted: the visibility it inherits is in another file.
49
+ - Nothing is fixed: making a constructor private breaks every `new` of the class. `ddd-ts-kit error-factories` moves a project to factories as a whole.
50
+
51
+ ## With the CLI checker
52
+
53
+ Held by this plugin alone: the shape of a class needs a syntax tree.
@@ -0,0 +1,50 @@
1
+ # ddd-ts-kit/errors-factory-name
2
+
3
+ Architecture id: `errors/factory-name`. Default severity: `error` in `recommended`, `error` in `strict`.
4
+
5
+ Applies to: the production files of `domain/errors/` of a context, in a project whose config says `"stack.refusals": "factories"`.
6
+
7
+ ## Why
8
+
9
+ The factory is read by the developer who refuses, the code by the client, the mapper, the audit trail and the tests. They must meet the same words, and those words are the business's: `slotTaken` and `SLOT_TAKEN`, never `create` and `BOOKING_FAILED`.
10
+
11
+ ## Reported
12
+
13
+ A factory is a public static method of an error class that calls `refusal(...)`.
14
+
15
+ - a name that says an error is built and not which rule refused: `create`, `make`, `of`, `from`, `build`, `new`, `error`, `failure`, `fail`, `refusal`, `refuse`, or a name holding a digit (`error1`)
16
+ - a code that is not a string literal, or not in constant case
17
+ - a code that is not the name of the factory in constant case, alone or with the name of the concept before or after it: `AppointmentError.notFound` sets `NOT_FOUND`, `APPOINTMENT_NOT_FOUND` or `NOT_FOUND_APPOINTMENT`
18
+
19
+ Incorrect:
20
+
21
+ ```ts
22
+ static slotTaken(calendarId: string) {
23
+ return AppointmentError.refusal('BOOKING_FAILED', 'The slot is already held.', { calendarId });
24
+ }
25
+ ```
26
+
27
+ Correct:
28
+
29
+ ```ts
30
+ static slotTaken(calendarId: string) {
31
+ return AppointmentError.refusal('SLOT_TAKEN', 'The slot is already held.', { calendarId });
32
+ }
33
+ ```
34
+
35
+ ## Options
36
+
37
+ None.
38
+
39
+ `rules."errors/factory-name"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line errors/factory-name -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
40
+
41
+ A code already published under other words cannot change: rename the factory after it, or keep the name and silence that line with the reason.
42
+
43
+ ## Limits
44
+
45
+ - Whether a name is a business phrase cannot be decided by a tool: only the names that are certainly not are refused. `language/glossary-term` holds the name of the class.
46
+ - The first `refusal(...)` call of the method is the one read.
47
+
48
+ ## With the CLI checker
49
+
50
+ Held by this plugin alone. That a code is unique in its context is `errors/code-unique`, held by the checker.
@@ -0,0 +1,45 @@
1
+ # ddd-ts-kit/errors-through-factory
2
+
3
+ Architecture id: `errors/through-factory`. Default severity: `error` in `recommended`, `error` in `strict`.
4
+
5
+ Applies to: every file of a context, tests included, in a project whose config says `"stack.refusals": "factories"`. A config without the key was written when an error was a class built with `new`: nothing is reported there.
6
+
7
+ ## Why
8
+
9
+ The code that refuses reads as a sentence, and the refusals of one concept live in one class: `throw AppointmentError.slotTaken(calendar.id, slot.startsAt)`. The factory writes the code, the message and the facts once. A `new` outside the class is a refusal whose code and message are whatever the caller wrote.
10
+
11
+ ## Reported
12
+
13
+ - `new X(...)` where `X` is imported from a file of `domain/errors/`
14
+
15
+ Incorrect:
16
+
17
+ ```ts
18
+ import { SlotTakenError } from '@/contexts/scheduling/domain/errors/slot-taken.error';
19
+
20
+ throw new SlotTakenError(calendar.id, slot.startsAt);
21
+ ```
22
+
23
+ Correct:
24
+
25
+ ```ts
26
+ import { AppointmentError } from '@/contexts/scheduling/domain/errors/appointment.error';
27
+
28
+ throw AppointmentError.slotTaken(calendar.id, slot.startsAt);
29
+ ```
30
+
31
+ ## Options
32
+
33
+ None.
34
+
35
+ `rules."errors/through-factory"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line errors/through-factory -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
36
+
37
+ ## Limits
38
+
39
+ - An error class is known by where it is imported from: a class declared elsewhere than `domain/errors/` is not seen (`naming/suffix` keeps errors there).
40
+ - The errors of the kit (`NotFoundError`, `InvariantViolation`, `ValidationError`...) are each one refusal with a fixed code and stay built with `new`.
41
+ - Nothing is fixed: which factory replaces a constructor is a decision. `ddd-ts-kit error-factories` writes the plan of a migration and applies it.
42
+
43
+ ## With the CLI checker
44
+
45
+ Held by this plugin alone: the checker lists the rule and judges nothing. The compiler refuses the same thing once the class extends `ConceptError`, whose constructor is protected.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/eslint-plugin",
3
- "version": "0.2.0",
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": {