@ddd-ts-kit/eslint-plugin 0.16.1 → 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 (93) hide show
  1. package/README.fr.md +3 -2
  2. package/README.md +2 -1
  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/authz-declared.fr.md +2 -2
  90. package/docs/rules/authz-declared.md +1 -1
  91. package/docs/rules/naming-business-name.fr.md +82 -0
  92. package/docs/rules/naming-business-name.md +81 -0
  93. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conventional-model-name.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/conventional-model-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASvD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAYpG"}
@@ -0,0 +1,22 @@
1
+ import { repositoryConcept } from './repository-concept.js';
2
+ /** A read of one element: `findById`, `get`, `load`, `findOne`, `requireById`. */
3
+ const ONE = /^(?:find|get|load|require)(?:One)?(?:ById)?$/;
4
+ /** A read of several elements by the name of its method: `findDue`, `findAll`, `getByPractice`. */
5
+ const MANY = /^(?:find|get|load)[A-Z]/;
6
+ const OF_ONE = /(?:ById|One)$/;
7
+ /**
8
+ * Without type information, what a call on a repository answers by the convention of its names:
9
+ * the concept of `appointmentRepository`, one of it for a read of one element, several for a
10
+ * read that names what it selects. Undefined when the names say neither.
11
+ */
12
+ export function conventionalModelName(call, several) {
13
+ const concept = repositoryConcept(call.object);
14
+ if (concept === undefined) {
15
+ return undefined;
16
+ }
17
+ if (!several) {
18
+ return ONE.test(call.method) ? { element: concept, many: false } : undefined;
19
+ }
20
+ return MANY.test(call.method) && !OF_ONE.test(call.method) ? { element: concept, many: true } : undefined;
21
+ }
22
+ //# sourceMappingURL=conventional-model-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conventional-model-name.js","sourceRoot":"","sources":["../../../src/support/business-names/conventional-model-name.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,kFAAkF;AAClF,MAAM,GAAG,GAAG,8CAA8C,CAAC;AAC3D,mGAAmG;AACnG,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG,eAAe,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAkB,EAAE,OAAgB;IACxE,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5G,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Words that say a value is there without saying which concept it is. `naming/business-name`
3
+ * reports a binding named by one of them where the model speaks; the same list as the checker.
4
+ */
5
+ export declare const GENERIC_WORDS: readonly string[];
6
+ //# sourceMappingURL=generic-words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic-words.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/generic-words.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAmB1C,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Words that say a value is there without saying which concept it is. `naming/business-name`
3
+ * reports a binding named by one of them where the model speaks; the same list as the checker.
4
+ */
5
+ export const GENERIC_WORDS = [
6
+ 'target',
7
+ 'targets',
8
+ 'data',
9
+ 'item',
10
+ 'items',
11
+ 'obj',
12
+ 'object',
13
+ 'thing',
14
+ 'things',
15
+ 'stuff',
16
+ 'info',
17
+ 'element',
18
+ 'el',
19
+ 'tmp',
20
+ 'temp',
21
+ 'foo',
22
+ 'bar',
23
+ 'baz',
24
+ ];
25
+ //# sourceMappingURL=generic-words.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic-words.js","sourceRoot":"","sources":["../../../src/support/business-names/generic-words.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,OAAO;IACP,MAAM;IACN,SAAS;IACT,IAAI;IACJ,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils';
2
+ type Variable = TSESLint.Scope.Variable;
3
+ /**
4
+ * Whether `variable` can be renamed `name` without changing what any name of the code means:
5
+ * no other variable of that name in its scope, none between a use and its declaration, and no
6
+ * use of that name inside its scope that reaches another variable or a global.
7
+ */
8
+ export declare function isNameFree(variable: Variable, name: string): boolean;
9
+ export {};
10
+ //# sourceMappingURL=is-name-free.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-name-free.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/is-name-free.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,KAAK,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAUpE"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Whether `variable` can be renamed `name` without changing what any name of the code means:
3
+ * no other variable of that name in its scope, none between a use and its declaration, and no
4
+ * use of that name inside its scope that reaches another variable or a global.
5
+ */
6
+ export function isNameFree(variable, name) {
7
+ const { scope } = variable;
8
+ if (scope.set.has(name)) {
9
+ return false;
10
+ }
11
+ const shadowed = variable.references.some((reference) => declaresBetween(reference.from, scope, name));
12
+ return !shadowed && !usedInside(scope, name);
13
+ }
14
+ function declaresBetween(from, declaring, name) {
15
+ for (let current = from; current !== null && current !== declaring; current = current.upper) {
16
+ if (current.set.has(name)) {
17
+ return true;
18
+ }
19
+ }
20
+ return false;
21
+ }
22
+ function usedInside(scope, name) {
23
+ return (scope.references.some((reference) => reference.identifier.name === name) ||
24
+ scope.childScopes.some((child) => usedInside(child, name)));
25
+ }
26
+ //# sourceMappingURL=is-name-free.js.map
@@ -0,0 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 +1,7 @@
1
+ import type { LintedFile } from '../../project/linted-file.js';
2
+ /**
3
+ * Where the language of the model lives: `domain/` and `application/` of a context, and the
4
+ * shared kernel outside its `presentation/`. Specs are not judged. Same table as the checker.
5
+ */
6
+ export declare function judgesNames(file: LintedFile): boolean;
7
+ //# sourceMappingURL=judges-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judges-names.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/judges-names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAYrD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Where the language of the model lives: `domain/` and `application/` of a context, and the
3
+ * shared kernel outside its `presentation/`. Specs are not judged. Same table as the checker.
4
+ */
5
+ export function judgesNames(file) {
6
+ if (file.isTest) {
7
+ return false;
8
+ }
9
+ if (file.location.area === 'context') {
10
+ return file.location.layer === 'domain' || file.location.layer === 'application';
11
+ }
12
+ return (file.location.area === 'shared-kernel' && !file.path.startsWith(`${file.config.sharedKernelDir}/presentation/`));
13
+ }
14
+ //# sourceMappingURL=judges-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judges-names.js","sourceRoot":"","sources":["../../../src/support/business-names/judges-names.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB;IAC1C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,aAAa,CAAC;IACnF,CAAC;IAED,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,gBAAgB,CAAC,CAChH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type TSESTree } from '@typescript-eslint/utils';
2
+ /** The names a binding target declares: itself, or every name of a destructuring at any depth, defaults and rests included. */
3
+ export declare function patternIdentifiers(target: TSESTree.Node): TSESTree.Identifier[];
4
+ //# sourceMappingURL=pattern-identifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-identifiers.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/pattern-identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzE,+HAA+H;AAC/H,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,CAmB/E"}
@@ -0,0 +1,21 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ /** The names a binding target declares: itself, or every name of a destructuring at any depth, defaults and rests included. */
3
+ export function patternIdentifiers(target) {
4
+ switch (target.type) {
5
+ case AST_NODE_TYPES.Identifier:
6
+ return [target];
7
+ case AST_NODE_TYPES.AssignmentPattern:
8
+ return patternIdentifiers(target.left);
9
+ case AST_NODE_TYPES.RestElement:
10
+ return patternIdentifiers(target.argument);
11
+ case AST_NODE_TYPES.ArrayPattern:
12
+ return target.elements.flatMap((element) => (element === null ? [] : patternIdentifiers(element)));
13
+ case AST_NODE_TYPES.ObjectPattern:
14
+ return target.properties.flatMap((property) => patternIdentifiers(property.type === AST_NODE_TYPES.Property ? property.value : property));
15
+ case AST_NODE_TYPES.TSParameterProperty:
16
+ return patternIdentifiers(target.parameter);
17
+ default:
18
+ return [];
19
+ }
20
+ }
21
+ //# sourceMappingURL=pattern-identifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-identifiers.js","sourceRoot":"","sources":["../../../src/support/business-names/pattern-identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,+HAA+H;AAC/H,MAAM,UAAU,kBAAkB,CAAC,MAAqB;IACtD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,cAAc,CAAC,UAAU;YAC5B,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,KAAK,cAAc,CAAC,iBAAiB;YACnC,OAAO,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,KAAK,cAAc,CAAC,YAAY;YAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrG,KAAK,cAAc,CAAC,aAAa;YAC/B,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC5C,kBAAkB,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAC1F,CAAC;QACJ,KAAK,cAAc,CAAC,mBAAmB;YACrC,OAAO,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9C;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The plural of an English word, as the generator writes it. */
2
+ export declare function plural(word: string): string;
3
+ //# sourceMappingURL=plural.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plural.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/plural.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM3C"}
@@ -0,0 +1,8 @@
1
+ /** The plural of an English word, as the generator writes it. */
2
+ export function plural(word) {
3
+ if (/[^aeiou]y$/.test(word)) {
4
+ return `${word.slice(0, -1)}ies`;
5
+ }
6
+ return /(?:s|x|z|ch|sh)$/.test(word) ? `${word}es` : `${word}s`;
7
+ }
8
+ //# sourceMappingURL=plural.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plural.js","sourceRoot":"","sources":["../../../src/support/business-names/plural.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACnC,CAAC;IAED,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;AAClE,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** The business concept a binding holds, by the camel name of one element, and whether it holds several of them. */
2
+ export interface ProposedName {
3
+ readonly element: string;
4
+ readonly many: boolean;
5
+ }
6
+ //# sourceMappingURL=proposed-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposed-name.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/proposed-name.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=proposed-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposed-name.js","sourceRoot":"","sources":["../../../src/support/business-names/proposed-name.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { type TSESLint } from '@typescript-eslint/utils';
2
+ /**
3
+ * Renames a variable where it is declared and wherever it is used, its type annotation kept. A
4
+ * shorthand property keeps its key (`{ target }` becomes `{ target: appointment }`). Undefined
5
+ * for an exported variable, whose name other files read.
6
+ */
7
+ export declare function renameFix(variable: TSESLint.Scope.Variable, name: string): TSESLint.ReportFixFunction | undefined;
8
+ //# sourceMappingURL=rename-fix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename-fix.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/rename-fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAExF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,iBAAiB,GAAG,SAAS,CAYjH"}
@@ -0,0 +1,26 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ /**
3
+ * Renames a variable where it is declared and wherever it is used, its type annotation kept. A
4
+ * shorthand property keeps its key (`{ target }` becomes `{ target: appointment }`). Undefined
5
+ * for an exported variable, whose name other files read.
6
+ */
7
+ export function renameFix(variable, name) {
8
+ const uses = variable.references.map((reference) => reference.identifier);
9
+ if (uses.some((identifier) => identifier.parent.type === AST_NODE_TYPES.ExportSpecifier) || isExported(variable)) {
10
+ return undefined;
11
+ }
12
+ const identifiers = [...variable.identifiers, ...uses].filter((identifier, index, all) => all.findIndex((other) => other.range[0] === identifier.range[0]) === index);
13
+ return (fixer) => identifiers.map((identifier) => renamed(fixer, identifier, name));
14
+ }
15
+ function renamed(fixer, identifier, name) {
16
+ const { parent } = identifier;
17
+ const own = identifier.name;
18
+ if (parent.type === AST_NODE_TYPES.Property && parent.shorthand && parent.value === identifier) {
19
+ return fixer.replaceText(parent, `${own}: ${name}`);
20
+ }
21
+ return fixer.replaceTextRange([identifier.range[0], identifier.range[0] + own.length], name);
22
+ }
23
+ function isExported(variable) {
24
+ return variable.defs.some((definition) => definition.parent?.parent.type === AST_NODE_TYPES.ExportNamedDeclaration);
25
+ }
26
+ //# sourceMappingURL=rename-fix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename-fix.js","sourceRoot":"","sources":["../../../src/support/business-names/rename-fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgC,MAAM,0BAA0B,CAAC;AAExF;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,QAAiC,EAAE,IAAY;IACvE,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE1E,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,CAC3D,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CACvG,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,OAAO,CACd,KAAyB,EACzB,UAAwD,EACxD,IAAY;IAEZ,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAC9B,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC;IAE5B,IAAI,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAC/F,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,KAAK,CAAC,gBAAgB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,UAAU,CAAC,QAAiC;IACnD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,sBAAsB,CAAC,CAAC;AACtH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type TSESTree } from '@typescript-eslint/utils';
2
+ /** `appointment` for `this.appointmentRepository` or `appointmentRepository`: a repository named by the convention of the kit. */
3
+ export declare function repositoryConcept(object: TSESTree.Expression): string | undefined;
4
+ //# sourceMappingURL=repository-concept.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-concept.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/repository-concept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzE,kIAAkI;AAClI,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,GAAG,MAAM,GAAG,SAAS,CAOjF"}
@@ -0,0 +1,10 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ const REPOSITORY = /^([a-z][\w$]*)Repository$/;
3
+ /** `appointment` for `this.appointmentRepository` or `appointmentRepository`: a repository named by the convention of the kit. */
4
+ export function repositoryConcept(object) {
5
+ const holder = object.type === AST_NODE_TYPES.MemberExpression && object.object.type === AST_NODE_TYPES.ThisExpression
6
+ ? object.property
7
+ : object;
8
+ return holder.type === AST_NODE_TYPES.Identifier ? REPOSITORY.exec(holder.name)?.[1] : undefined;
9
+ }
10
+ //# sourceMappingURL=repository-concept.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-concept.js","sourceRoot":"","sources":["../../../src/support/business-names/repository-concept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAE/C,kIAAkI;AAClI,MAAM,UAAU,iBAAiB,CAAC,MAA2B;IAC3D,MAAM,MAAM,GACV,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc;QACrG,CAAC,CAAC,MAAM,CAAC,QAAQ;QACjB,CAAC,CAAC,MAAM,CAAC;IAEb,OAAO,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnG,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The singular of a plural English word (`reminders`, `deliveries`, `boxes`), or undefined when it does not read as one. */
2
+ export declare function singular(word: string): string | undefined;
3
+ //# sourceMappingURL=singular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singular.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/singular.ts"],"names":[],"mappings":"AAAA,6HAA6H;AAC7H,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUzD"}
@@ -0,0 +1,11 @@
1
+ /** The singular of a plural English word (`reminders`, `deliveries`, `boxes`), or undefined when it does not read as one. */
2
+ export function singular(word) {
3
+ if (/[^aeiou]ies$/.test(word)) {
4
+ return `${word.slice(0, -3)}y`;
5
+ }
6
+ if (/(?:ss|x|z|ch|sh)es$/.test(word)) {
7
+ return word.slice(0, -2);
8
+ }
9
+ return /[^su]s$/.test(word) ? word.slice(0, -1) : undefined;
10
+ }
11
+ //# sourceMappingURL=singular.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singular.js","sourceRoot":"","sources":["../../../src/support/business-names/singular.ts"],"names":[],"mappings":"AAAA,6HAA6H;AAC7H,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACjC,CAAC;IAED,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
2
+ import type { LintedFile } from '../../project/linted-file.js';
3
+ import type { ProposedName } from './proposed-name.js';
4
+ /** What the type checker tells of the project: which concept of the model an expression holds, and whether it is a repository. */
5
+ export interface TypedNames {
6
+ /** An aggregate, an entity or a value object of the project, or a list of them, once awaited and without `undefined`. */
7
+ modelOf(node: TSESTree.Node): ProposedName | undefined;
8
+ /** An instance of a repository port of `domain/repositories/`. */
9
+ isRepository(node: TSESTree.Node): boolean;
10
+ }
11
+ /** Undefined when the parser was given no program: the rule then reads the names of the code. */
12
+ export declare function typedNames(context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>, file: LintedFile): TypedNames | undefined;
13
+ //# sourceMappingURL=typed-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-names.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/typed-names.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,kIAAkI;AAClI,MAAM,WAAW,UAAU;IACzB,yHAAyH;IACzH,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,YAAY,GAAG,SAAS,CAAC;IACvD,kEAAkE;IAClE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC;CAC5C;AAUD,iGAAiG;AACjG,wBAAgB,UAAU,CACxB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,EACnE,IAAI,EAAE,UAAU,GACf,UAAU,GAAG,SAAS,CAsCxB"}
@@ -0,0 +1,53 @@
1
+ import path from 'node:path';
2
+ import { ESLintUtils } from '@typescript-eslint/utils';
3
+ import { locate } from '../../project/locate.js';
4
+ import { toPosix } from '../../project/to-posix.js';
5
+ import { camel } from './camel.js';
6
+ const MODEL_DIRECTORIES = ['aggregates', 'entities', 'value-objects'];
7
+ /** Undefined when the parser was given no program: the rule then reads the names of the code. */
8
+ export function typedNames(context, file) {
9
+ const services = ESLintUtils.getParserServices(context, true);
10
+ if (services.program === null) {
11
+ return undefined;
12
+ }
13
+ const checker = services.program.getTypeChecker();
14
+ /** The file that declares the type of `node`, the element type for a list, and the name of that type. */
15
+ const declared = (node) => {
16
+ const found = services.getTypeAtLocation(node);
17
+ const type = (checker.getAwaitedType(found) ?? found).getNonNullableType();
18
+ const many = checker.isArrayType(type);
19
+ const symbol = symbolOf(many ? type.getNumberIndexType() : type);
20
+ const source = symbol?.declarations?.[0]?.getSourceFile().fileName;
21
+ return symbol === undefined || source === undefined ? undefined : { file: source, name: symbol.getName(), many };
22
+ };
23
+ return {
24
+ modelOf(node) {
25
+ const type = declared(node);
26
+ const place = type === undefined ? undefined : placeOf(file, type.file);
27
+ if (type === undefined || place === undefined || !isModelPlace(place)) {
28
+ return undefined;
29
+ }
30
+ return { element: camel(type.name), many: type.many };
31
+ },
32
+ isRepository(node) {
33
+ const type = declared(node);
34
+ const place = type === undefined ? undefined : placeOf(file, type.file);
35
+ return place?.area === 'context' && place.layer === 'domain' && place.inside[0] === 'repositories';
36
+ },
37
+ };
38
+ }
39
+ function placeOf(file, absolute) {
40
+ const relative = toPosix(path.relative(file.root, absolute));
41
+ return relative.startsWith('../') || relative.includes('node_modules/') ? undefined : locate(file.config, relative);
42
+ }
43
+ function isModelPlace(place) {
44
+ if (place.area === 'shared-kernel') {
45
+ return true;
46
+ }
47
+ return place.area === 'context' && place.layer === 'domain' && MODEL_DIRECTORIES.includes(place.inside[0] ?? '');
48
+ }
49
+ /** The symbol a type is declared by: its class or interface, or the alias it was written with. */
50
+ function symbolOf(type) {
51
+ return type?.getSymbol() ?? type?.aliasSymbol;
52
+ }
53
+ //# sourceMappingURL=typed-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-names.js","sourceRoot":"","sources":["../../../src/support/business-names/typed-names.ts"],"names":[],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AAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACtH,CAAC;AAED,SAAS,YAAY,CAAC,KAAgC;IACpD,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACnH,CAAC;AAED,kGAAkG;AAClG,SAAS,QAAQ,CACf,IAAoF;IAEpF,OAAO,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,WAAW,CAAC;AAChD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Config } from '../../project/config.js';
2
+ /** The `words` and `allow` options of the rule, which come over `businessNames` of the config. */
3
+ export interface BusinessNameOptions {
4
+ readonly words?: readonly string[];
5
+ readonly allow?: readonly string[];
6
+ }
7
+ /** The words the rule reports: the list of the options, else of the config, else the defaults; less what either allows. */
8
+ export declare function wordsOf(config: Config, options: BusinessNameOptions): ReadonlySet<string>;
9
+ //# sourceMappingURL=words-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words-of.d.ts","sourceRoot":"","sources":["../../../src/support/business-names/words-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,kGAAkG;AAClG,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,2HAA2H;AAC3H,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAKzF"}
@@ -0,0 +1,8 @@
1
+ import { GENERIC_WORDS } from './generic-words.js';
2
+ /** The words the rule reports: the list of the options, else of the config, else the defaults; less what either allows. */
3
+ export function wordsOf(config, options) {
4
+ const listed = options.words ?? config.businessNames.words ?? GENERIC_WORDS;
5
+ const allowed = [...config.businessNames.allow, ...(options.allow ?? [])];
6
+ return new Set(listed.filter((word) => !allowed.includes(word)));
7
+ }
8
+ //# sourceMappingURL=words-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words-of.js","sourceRoot":"","sources":["../../../src/support/business-names/words-of.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,2HAA2H;AAC3H,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,OAA4B;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC;IAC5E,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAE1E,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.16.1";
1
+ export declare const VERSION = "0.17.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.16.1';
1
+ export const VERSION = '0.17.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
1
  [English](authz-declared.md) · **Français**
2
- <!-- translation-of: authz-declared.md sha256:45bde1afe67f1b4c -->
2
+ <!-- translation-of: authz-declared.md sha256:38d77053454decf3 -->
3
3
 
4
4
  # ddd-ts-kit/authz-declared
5
5
 
@@ -79,7 +79,7 @@ Aucune.
79
79
  - Un message enregistré atteint par un *barrel*, un export qui renomme, un import par défaut ou un espace de noms n'est pas suivi jusqu'à sa classe : son décorateur n'est pas vu et l'enregistrement est signalé.
80
80
  - Dans un projet de style déclaré qui garde un `<context>.module.ts`, un message qui y est enregistré avec `.requires(...)` et écrit sans décorateur est quand même signalé dans son propre fichier : mettez le décorateur sur la classe.
81
81
  - Un fichier `*.command.ts` ou `*.query.ts` qui n'exporte aucune classe n'est pas signalé ici.
82
- - Un enregistrement réparti sur plusieurs instructions (`const target = builder.command(X); target.handledBy(H);`) n'est pas suivi.
82
+ - Un enregistrement réparti sur plusieurs instructions (`const registration = builder.command(X); registration.handledBy(H);`) n'est pas suivi.
83
83
  - Un câblage écrit à la main avec `AuthorizationMap.of(requires(...), publicUseCase(...))` n'est pas lu : `authorizationMiddleware` refuse un cas d'usage non déclaré à l'exécution, et `createApplication({ authorization: 'required' })` au démarrage.
84
84
  - Un message qui étend simplement `Command` ou `Query` alors que son enregistrement appelle `.requires(...)` s'étend sur deux fichiers et n'est pas vu ici ; le compilateur le refuse, puisque `requires` n'existe que pour un message qui porte un acteur.
85
85
  - Une spécification de route qui n'est pas un littéral d'objet, ou qui étale un autre objet, n'est pas jugée.
@@ -78,7 +78,7 @@ None.
78
78
  - A registered message reached through a barrel, a renaming export, a default import or a namespace is not followed to its class: its decorator is not seen and the registration is reported.
79
79
  - In a declared-style project that keeps a `<context>.module.ts`, a message registered there with `.requires(...)` and written without a decorator is still reported in its own file: put the decorator on the class.
80
80
  - A `*.command.ts` or `*.query.ts` file that exports no class is not reported here.
81
- - A registration split over statements (`const target = builder.command(X); target.handledBy(H);`) is not followed.
81
+ - A registration split over statements (`const registration = builder.command(X); registration.handledBy(H);`) is not followed.
82
82
  - A wiring written by hand with `AuthorizationMap.of(requires(...), publicUseCase(...))` is not read: `authorizationMiddleware` refuses an undeclared use case at run time, and `createApplication({ authorization: 'required' })` at start.
83
83
  - A message extending plain `Command` or `Query` while its registration calls `.requires(...)` spans two files and is not seen here; the compiler refuses it, since `requires` only exists for a message that carries an actor.
84
84
  - A route spec that is not an object literal, or that spreads another object, is not judged.
@@ -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.