@ddd-ts-kit/eslint-plugin 0.88.0 → 0.90.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 (58) hide show
  1. package/README.fr.md +8 -2
  2. package/README.md +7 -1
  3. package/dist/rules/rules.d.ts.map +1 -1
  4. package/dist/rules/rules.js +12 -0
  5. package/dist/rules/rules.js.map +1 -1
  6. package/dist/rules/test-assertion-present.d.ts +2 -0
  7. package/dist/rules/test-assertion-present.d.ts.map +1 -0
  8. package/dist/rules/test-assertion-present.js +69 -0
  9. package/dist/rules/test-assertion-present.js.map +1 -0
  10. package/dist/rules/test-no-logic.d.ts +2 -0
  11. package/dist/rules/test-no-logic.d.ts.map +1 -0
  12. package/dist/rules/test-no-logic.js +45 -0
  13. package/dist/rules/test-no-logic.js.map +1 -0
  14. package/dist/rules/test-no-only-no-skip.d.ts +2 -0
  15. package/dist/rules/test-no-only-no-skip.d.ts.map +1 -0
  16. package/dist/rules/test-no-only-no-skip.js +53 -0
  17. package/dist/rules/test-no-only-no-skip.js.map +1 -0
  18. package/dist/rules/test-no-snapshot.d.ts +2 -0
  19. package/dist/rules/test-no-snapshot.d.ts.map +1 -0
  20. package/dist/rules/test-no-snapshot.js +37 -0
  21. package/dist/rules/test-no-snapshot.js.map +1 -0
  22. package/dist/rules/test-refusal-by-code.d.ts +2 -0
  23. package/dist/rules/test-refusal-by-code.d.ts.map +1 -0
  24. package/dist/rules/test-refusal-by-code.js +70 -0
  25. package/dist/rules/test-refusal-by-code.js.map +1 -0
  26. package/dist/rules/test-title-states-a-rule.d.ts +4 -0
  27. package/dist/rules/test-title-states-a-rule.d.ts.map +1 -0
  28. package/dist/rules/test-title-states-a-rule.js +67 -0
  29. package/dist/rules/test-title-states-a-rule.js.map +1 -0
  30. package/dist/support/descendants.d.ts +5 -2
  31. package/dist/support/descendants.d.ts.map +1 -1
  32. package/dist/support/descendants.js +7 -1
  33. package/dist/support/descendants.js.map +1 -1
  34. package/dist/support/stepdown/misplaced-functions.js +9 -1
  35. package/dist/support/stepdown/misplaced-functions.js.map +1 -1
  36. package/dist/support/tests/test-call.d.ts +20 -0
  37. package/dist/support/tests/test-call.d.ts.map +1 -0
  38. package/dist/support/tests/test-call.js +77 -0
  39. package/dist/support/tests/test-call.js.map +1 -0
  40. package/dist/support/tests/title-text.d.ts +7 -0
  41. package/dist/support/tests/title-text.d.ts.map +1 -0
  42. package/dist/support/tests/title-text.js +22 -0
  43. package/dist/support/tests/title-text.js.map +1 -0
  44. package/dist/version.d.ts +1 -1
  45. package/dist/version.js +1 -1
  46. package/docs/rules/test-assertion-present.fr.md +58 -0
  47. package/docs/rules/test-assertion-present.md +57 -0
  48. package/docs/rules/test-no-logic.fr.md +71 -0
  49. package/docs/rules/test-no-logic.md +70 -0
  50. package/docs/rules/test-no-only-no-skip.fr.md +56 -0
  51. package/docs/rules/test-no-only-no-skip.md +55 -0
  52. package/docs/rules/test-no-snapshot.fr.md +52 -0
  53. package/docs/rules/test-no-snapshot.md +51 -0
  54. package/docs/rules/test-refusal-by-code.fr.md +65 -0
  55. package/docs/rules/test-refusal-by-code.md +64 -0
  56. package/docs/rules/test-title-states-a-rule.fr.md +63 -0
  57. package/docs/rules/test-title-states-a-rule.md +62 -0
  58. package/package.json +1 -1
@@ -36,12 +36,20 @@ function describe(declared, sourceCode) {
36
36
  const variable = sourceCode
37
37
  .getDeclaredVariables(declared.extent)
38
38
  .find((candidate) => candidate.identifiers.includes(declared.id));
39
- const references = variable?.references.filter((reference) => !reference.init && reference.isValueReference) ?? [];
39
+ const references = variable?.references.filter((reference) => !reference.init && isValue(reference)) ?? [];
40
40
  return {
41
41
  ...declared,
42
42
  uses: references.map((reference) => reference.identifier).filter((use) => !isInside(use, declared.extent)),
43
43
  };
44
44
  }
45
+ /**
46
+ * A reference to the value of the function, not to its type. The scope manager of typescript-eslint
47
+ * says which is which; the one of the default parser of ESLint, which lints a script, says nothing,
48
+ * and a script has no types: every reference it holds is a value.
49
+ */
50
+ function isValue(reference) {
51
+ return Reflect.has(reference, 'isValueReference') ? reference.isValueReference : true;
52
+ }
45
53
  function callGraph(declared) {
46
54
  const graph = new CallGraph();
47
55
  for (const callee of declared) {
@@ -1 +1 @@
1
- {"version":3,"file":"misplaced-functions.js","sourceRoot":"","sources":["../../../src/support/stepdown/misplaced-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgC,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAiBpD,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB,CAChC,OAAyB,EACzB,UAAyC;IAEzC,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACxF,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAElC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YACvG,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAE5F,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAC1B,CAAC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,CAAC,GAAkB;IAClC,OAAO,CACL,GAAG,CAAC,MAAM,EAAE,IAAI,KAAK,cAAc,CAAC,eAAe,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,KAAK,cAAc,CAAC,wBAAwB,CACpH,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,SAAS,UAAU,CAAC,GAAkB;IACpC,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,mBAAmB,EAAE,CAAC;YACjF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,kBAAkB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC5E,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,IAAmB,EAAE,SAAwB;IAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
2
+ /** A test or a group of tests a call declares. */
3
+ export interface TestCall {
4
+ readonly kind: 'test' | 'group';
5
+ /** The function of the runner the call is made under: `it`, `test`, `describe`, `suite`, `fit`, `xit`, `xdescribe`. */
6
+ readonly root: string;
7
+ /** The modifiers chained on it, in order: `['concurrent', 'only']`, `['each']`. */
8
+ readonly modifiers: readonly string[];
9
+ /** Where a report on the declaration points: `it.only`, `describe.each(rows)`. */
10
+ readonly head: TSESTree.Node;
11
+ readonly title: TSESTree.CallExpressionArgument | undefined;
12
+ readonly body: TSESTree.CallExpressionArgument | undefined;
13
+ }
14
+ /**
15
+ * The test or the group `node` declares, when it is one: `it(title, fn)`, `describe.each(rows)(title, fn)`,
16
+ * `test.todo(title)`, `xit(title, fn)`. Nothing for `it.each(rows)` alone, whose own call declares
17
+ * the test, nor when `it` is a local of the file instead of the runner's.
18
+ */
19
+ export declare function testCall(sourceCode: Readonly<TSESLint.SourceCode>, node: TSESTree.CallExpression): TestCall | undefined;
20
+ //# sourceMappingURL=test-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-call.d.ts","sourceRoot":"","sources":["../../../src/support/tests/test-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AA+BxF,kDAAkD;AAClD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,uHAAuH;IACvH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,sBAAsB,GAAG,SAAS,CAAC;CAC5D;AAOD;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzC,IAAI,EAAE,QAAQ,CAAC,cAAc,GAC5B,QAAQ,GAAG,SAAS,CAiBtB"}
@@ -0,0 +1,77 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import { ambientName } from '../globals/ambient-name.js';
3
+ import { propertyName } from '../globals/property-name.js';
4
+ /** The functions of a test runner that declare a test, Vitest and Jest alike. */
5
+ const TESTS = new Set(['it', 'test']);
6
+ /** The functions that declare a group of tests. */
7
+ const GROUPS = new Set(['describe', 'suite']);
8
+ /** The focused and the skipped forms Jest kept from Jasmine: `fit`, `xit`, `xdescribe`. */
9
+ const PREFIXED = /^[fx](it|test|describe)$/;
10
+ /** What a runner chains on `it` or `describe` before the title: `it.each(rows)(title, fn)`, `describe.skip(title, fn)`. */
11
+ const MODIFIERS = new Set([
12
+ 'each',
13
+ 'for',
14
+ 'skip',
15
+ 'only',
16
+ 'todo',
17
+ 'concurrent',
18
+ 'sequential',
19
+ 'shuffle',
20
+ 'skipIf',
21
+ 'runIf',
22
+ 'fails',
23
+ ]);
24
+ /** The modifiers that take their own arguments first, the title and the body coming in a second call. */
25
+ const CURRIED = new Set(['each', 'for', 'skipIf', 'runIf']);
26
+ /**
27
+ * The test or the group `node` declares, when it is one: `it(title, fn)`, `describe.each(rows)(title, fn)`,
28
+ * `test.todo(title)`, `xit(title, fn)`. Nothing for `it.each(rows)` alone, whose own call declares
29
+ * the test, nor when `it` is a local of the file instead of the runner's.
30
+ */
31
+ export function testCall(sourceCode, node) {
32
+ const head = headOf(node.callee);
33
+ if (head === undefined) {
34
+ return undefined;
35
+ }
36
+ const { root, modifiers } = head;
37
+ const kind = kindOf(root.name);
38
+ if (kind === undefined || ambientName(sourceCode, root) !== root.name) {
39
+ return undefined;
40
+ }
41
+ const [title, body] = node.arguments;
42
+ return { kind, root: root.name, modifiers, head: node.callee, title, body };
43
+ }
44
+ /** The runner function and the modifiers a callee chains, or nothing when the chain holds anything else. */
45
+ function headOf(callee) {
46
+ if (callee.type === AST_NODE_TYPES.Identifier) {
47
+ return { root: callee, modifiers: [] };
48
+ }
49
+ if (callee.type === AST_NODE_TYPES.CallExpression) {
50
+ const inner = chainOf(callee.callee);
51
+ return inner !== undefined && CURRIED.has(inner.modifiers.at(-1) ?? '') ? inner : undefined;
52
+ }
53
+ const chain = chainOf(callee);
54
+ return chain !== undefined && !CURRIED.has(chain.modifiers.at(-1) ?? '') ? chain : undefined;
55
+ }
56
+ /** `it.concurrent.only` read as its root and its modifiers. */
57
+ function chainOf(callee) {
58
+ const modifiers = [];
59
+ let current = callee;
60
+ while (current.type === AST_NODE_TYPES.MemberExpression) {
61
+ const name = propertyName(current);
62
+ if (name === undefined || !MODIFIERS.has(name)) {
63
+ return undefined;
64
+ }
65
+ modifiers.unshift(name);
66
+ current = current.object;
67
+ }
68
+ return current.type === AST_NODE_TYPES.Identifier ? { root: current, modifiers } : undefined;
69
+ }
70
+ function kindOf(root) {
71
+ const bare = PREFIXED.exec(root)?.[1] ?? root;
72
+ if (TESTS.has(bare)) {
73
+ return 'test';
74
+ }
75
+ return GROUPS.has(bare) ? 'group' : undefined;
76
+ }
77
+ //# sourceMappingURL=test-call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-call.js","sourceRoot":"","sources":["../../../src/support/tests/test-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgC,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,iFAAiF;AACjF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtC,mDAAmD;AACnD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9C,2FAA2F;AAC3F,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C,2HAA2H;AAC3H,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAEH,yGAAyG;AACzG,MAAM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;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type TSESTree } from '@typescript-eslint/utils';
2
+ /**
3
+ * The text of a title: a string literal, or a template whose expressions read as placeholders, the way
4
+ * `it.each` fills `%s` and `$name`. Nothing for a title held in a variable, which is not judged.
5
+ */
6
+ export declare function titleText(node: TSESTree.CallExpressionArgument | undefined): string | undefined;
7
+ //# sourceMappingURL=title-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title-text.d.ts","sourceRoot":"","sources":["../../../src/support/tests/title-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAKzE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,sBAAsB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAgB/F"}
@@ -0,0 +1,22 @@
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ /** How an expression of a template title is read: as the placeholder of a table-driven title. */
3
+ const PLACEHOLDER = '$value';
4
+ /**
5
+ * The text of a title: a string literal, or a template whose expressions read as placeholders, the way
6
+ * `it.each` fills `%s` and `$name`. Nothing for a title held in a variable, which is not judged.
7
+ */
8
+ export function titleText(node) {
9
+ if (node === undefined) {
10
+ return undefined;
11
+ }
12
+ if (node.type === AST_NODE_TYPES.Literal) {
13
+ return typeof node.value === 'string' ? node.value : undefined;
14
+ }
15
+ if (node.type !== AST_NODE_TYPES.TemplateLiteral) {
16
+ return undefined;
17
+ }
18
+ return node.quasis
19
+ .map((quasi, index) => (quasi.value.cooked ?? '') + (index < node.expressions.length ? PLACEHOLDER : ''))
20
+ .join('');
21
+ }
22
+ //# sourceMappingURL=title-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title-text.js","sourceRoot":"","sources":["../../../src/support/tests/title-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,iGAAiG;AACjG,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAiD;IACzE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,OAAO,EAAE,CAAC;QACzC,OAAO,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,MAAM;SACf,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACxG,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.88.0";
1
+ export declare const VERSION = "0.90.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.88.0';
1
+ export const VERSION = '0.90.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -0,0 +1,58 @@
1
+ [English](test-assertion-present.md) · **Français**
2
+ <!-- translation-of: test-assertion-present.md sha256:9048f6705cb85910 -->
3
+
4
+ # ddd-ts-kit/test-assertion-present
5
+
6
+ Identifiant d'architecture : `test/assertion-present` (ajouté par ce *plugin*). Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : chaque fichier de test du projet (`*.spec.ts`, `*.test.ts`, le `test/` d'un contexte).
9
+
10
+ ## Pourquoi
11
+
12
+ Un test qui ne vérifie rien passe quoi que fasse le code, et fait monter le taux de couverture sans rien prouver : c'est le trou que `test/coverage-governed` ne peut pas voir. Le kit vérifie des résultats : l'état d'un *fake*, les faits enregistrés, le refus par son code, la réponse d'une route.
13
+
14
+ ## Signalé
15
+
16
+ - un `it` ou un `test` dont le corps ne contient aucun appel à `expect`, à une fonction nommée `expect...` ou `assert...` (`expectRefusal`, `expectProblem`, `expectStatus`, `expectSpanTree`, un *helper* du projet), ni au résultat d'un scénario de `@ddd-ts-kit/testing` (`thenEvents`, `thenEventNames`, `thenError`, `thenState`, `thenNoEvent`)
17
+ - un `it` ou un `test` avec un titre et sans corps, que Vitest compte comme un *todo* et que Jest refuse
18
+
19
+ Incorrect :
20
+
21
+ ```ts
22
+ it('issues the invoice', async () => {
23
+ await application.commandBus.execute(new IssueInvoiceCommand(holder, 'customer-1'));
24
+ });
25
+
26
+ it('refuses a second payment');
27
+ ```
28
+
29
+ Correct :
30
+
31
+ ```ts
32
+ it('issues the invoice and answers its identifier', async () => {
33
+ const id = await application.commandBus.execute(new IssueInvoiceCommand(holder, 'customer-1'));
34
+
35
+ expect(await invoiceRepository.findById(id)).toBeDefined();
36
+ });
37
+
38
+ it.todo('refuses a second payment');
39
+ ```
40
+
41
+ ## Détails
42
+
43
+ Le corps est lu en entier, scénario enveloppé par `pending(...)` compris, de sorte qu'un scénario d'acceptation qui attend son code est jugé comme les autres. Un *helper* qui vérifie pour plusieurs tests se nomme `expect...` ou `assert...` : la règle le voit alors, et le lecteur aussi.
44
+
45
+ ## Options
46
+
47
+ Aucune.
48
+
49
+ `rules."test/assertion-present"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line test/assertion-present -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
50
+
51
+ ## Limites
52
+
53
+ - La règle voit qu'une vérification est faite, pas qu'elle porte sur le résultat : `expect(true).toBe(true)` passe. La revue lit ce qui est vérifié.
54
+ - Un `.then(...)` sur une promesse n'est pas le résultat d'un scénario.
55
+
56
+ ## Avec le checker de la CLI
57
+
58
+ Nouveau avec ce *plugin* : le *checker* de la CLI n'a pas d'équivalent, car lire un test demande un arbre syntaxique.
@@ -0,0 +1,57 @@
1
+ **English** · [Français](test-assertion-present.fr.md)
2
+
3
+ # ddd-ts-kit/test-assertion-present
4
+
5
+ Architecture id: `test/assertion-present` (added by this plugin). Default severity: `error` in `recommended`, `error` in `strict`.
6
+
7
+ Applies to: every test file of the project (`*.spec.ts`, `*.test.ts`, the `test/` of a context).
8
+
9
+ ## Why
10
+
11
+ A test that asserts nothing passes whatever the code does, and raises the coverage rate while proving nothing: it is the gap `test/coverage-governed` cannot see. The kit asserts outcomes: the state of a fake, the facts recorded, the refusal by its code, the answer of a route.
12
+
13
+ ## Reported
14
+
15
+ - an `it` or a `test` whose body holds no call to `expect`, to a function named `expect...` or `assert...` (`expectRefusal`, `expectProblem`, `expectStatus`, `expectSpanTree`, a helper of the project), or to the outcome of a scenario of `@ddd-ts-kit/testing` (`thenEvents`, `thenEventNames`, `thenError`, `thenState`, `thenNoEvent`)
16
+ - an `it` or a `test` with a title and no body, which Vitest counts as a todo and Jest refuses
17
+
18
+ Incorrect:
19
+
20
+ ```ts
21
+ it('issues the invoice', async () => {
22
+ await application.commandBus.execute(new IssueInvoiceCommand(holder, 'customer-1'));
23
+ });
24
+
25
+ it('refuses a second payment');
26
+ ```
27
+
28
+ Correct:
29
+
30
+ ```ts
31
+ it('issues the invoice and answers its identifier', async () => {
32
+ const id = await application.commandBus.execute(new IssueInvoiceCommand(holder, 'customer-1'));
33
+
34
+ expect(await invoiceRepository.findById(id)).toBeDefined();
35
+ });
36
+
37
+ it.todo('refuses a second payment');
38
+ ```
39
+
40
+ ## Details
41
+
42
+ The body is read whole, the scenario `pending(...)` wraps included, so an acceptance scenario waiting for its code is judged like any other. A helper that asserts for several tests is named `expect...` or `assert...`: the rule then sees it, and so does the reader.
43
+
44
+ ## Options
45
+
46
+ None.
47
+
48
+ `rules."test/assertion-present"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line test/assertion-present -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
49
+
50
+ ## Limits
51
+
52
+ - The rule sees that an assertion is made, not that it bears on the outcome: `expect(true).toBe(true)` passes. The review reads what is asserted.
53
+ - A `.then(...)` on a promise is not an outcome of a scenario.
54
+
55
+ ## With the CLI checker
56
+
57
+ New with this plugin: the CLI checker has no equivalent, because reading a test needs a syntax tree.
@@ -0,0 +1,71 @@
1
+ [English](test-no-logic.md) · **Français**
2
+ <!-- translation-of: test-no-logic.md sha256:32c6e7bc125f7cc7 -->
3
+
4
+ # ddd-ts-kit/test-no-logic
5
+
6
+ Identifiant d'architecture : `test/no-logic` (ajouté par ce *plugin*). Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : chaque fichier de test du projet (`*.spec.ts`, `*.test.ts`, le `test/` d'un contexte).
9
+
10
+ ## Pourquoi
11
+
12
+ Un test se lit sans être exécuté : il prépare un état, agit une fois, vérifie ce qui est vrai ensuite, et échoue pour une seule raison. Un `if` dans un test est un second test caché dans le premier, ou un chemin que le test prend sans dire lequel ; une boucle vérifie plusieurs cas sous un seul titre, et le rapport n'en nomme aucun ; un `try` attrape ce que le lanceur aurait signalé avec sa pile. La logique qu'un test semble demander appartient à ce qu'il utilise : un *builder* décide comment se construit une facture payée, un *fake* décide quand le *mailer* échoue, un *helper* décide ce que contient une page.
13
+
14
+ ## Signalé
15
+
16
+ Dans le corps d'un `it` ou d'un `test`, scénario enveloppé par `pending(...)` compris :
17
+
18
+ - `if`, `switch`, un ternaire
19
+ - `for`, `for ... of`, `for ... in`, `while`, `do`
20
+ - `try`
21
+
22
+ Incorrect :
23
+
24
+ ```ts
25
+ it('accepts every kind', () => {
26
+ for (const kind of kinds) {
27
+ expect(NotificationKind.create(kind).value).toBe(kind);
28
+ }
29
+ });
30
+
31
+ it('refuses a second payment', () => {
32
+ try {
33
+ invoice.pay(at);
34
+ } catch (error) {
35
+ expect(error).toMatchObject({ code: 'INVOICE_ALREADY_PAID' });
36
+ }
37
+ });
38
+ ```
39
+
40
+ Correct :
41
+
42
+ ```ts
43
+ it.each(kinds)('accepts the kind %s', (kind) => {
44
+ expect(NotificationKind.create(kind).value).toBe(kind);
45
+ });
46
+
47
+ it('refuses a second payment', () => {
48
+ given(anInvoice().paid())
49
+ .when((invoice) => invoice.pay(at))
50
+ .thenError('INVOICE_ALREADY_PAID');
51
+ });
52
+ ```
53
+
54
+ ## Détails
55
+
56
+ Les *hooks* (`beforeEach`, `beforeAll`) et les fonctions déclarées à côté des tests ne sont pas jugés : une boucle qui alimente une table dans un *hook*, un *helper* de `test/e2e/support/` qui décide, sont la place de la logique. Un cas par ligne est un `it.each` dont la table est les lignes : le rapport nomme alors chacune.
57
+
58
+ ## Options
59
+
60
+ Aucune.
61
+
62
+ `rules."test/no-logic"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line test/no-logic -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
63
+
64
+ ## Limites
65
+
66
+ - `&&`, `||` et `??` ne sont pas signalés : `expect(a && b)` est une vérification faible, pas une branche.
67
+ - Une fonction appelée depuis le test et déclarée ailleurs peut contenir n'importe quelle logique : la règle lit le corps du test, la revue lit le *helper*.
68
+
69
+ ## Avec le checker de la CLI
70
+
71
+ Nouveau avec ce *plugin* : le *checker* de la CLI n'a pas d'équivalent, car lire un test demande un arbre syntaxique.
@@ -0,0 +1,70 @@
1
+ **English** · [Français](test-no-logic.fr.md)
2
+
3
+ # ddd-ts-kit/test-no-logic
4
+
5
+ Architecture id: `test/no-logic` (added by this plugin). Default severity: `error` in `recommended`, `error` in `strict`.
6
+
7
+ Applies to: every test file of the project (`*.spec.ts`, `*.test.ts`, the `test/` of a context).
8
+
9
+ ## Why
10
+
11
+ A test is read without being run: it arranges a state, acts once, asserts what is true afterwards, and fails for one reason. An `if` in a test is a second test hiding in the first, or a path the test takes without saying which; a loop asserts several cases under one title, and the report names none of them; a `try` catches what the runner would have reported with its stack. The logic a test seems to need belongs to what it uses: a builder decides how a paid invoice is built, a fake decides when the mailer fails, a helper decides what a page holds.
12
+
13
+ ## Reported
14
+
15
+ Inside the body of an `it` or a `test`, the scenario `pending(...)` wraps included:
16
+
17
+ - `if`, `switch`, a ternary
18
+ - `for`, `for ... of`, `for ... in`, `while`, `do`
19
+ - `try`
20
+
21
+ Incorrect:
22
+
23
+ ```ts
24
+ it('accepts every kind', () => {
25
+ for (const kind of kinds) {
26
+ expect(NotificationKind.create(kind).value).toBe(kind);
27
+ }
28
+ });
29
+
30
+ it('refuses a second payment', () => {
31
+ try {
32
+ invoice.pay(at);
33
+ } catch (error) {
34
+ expect(error).toMatchObject({ code: 'INVOICE_ALREADY_PAID' });
35
+ }
36
+ });
37
+ ```
38
+
39
+ Correct:
40
+
41
+ ```ts
42
+ it.each(kinds)('accepts the kind %s', (kind) => {
43
+ expect(NotificationKind.create(kind).value).toBe(kind);
44
+ });
45
+
46
+ it('refuses a second payment', () => {
47
+ given(anInvoice().paid())
48
+ .when((invoice) => invoice.pay(at))
49
+ .thenError('INVOICE_ALREADY_PAID');
50
+ });
51
+ ```
52
+
53
+ ## Details
54
+
55
+ The hooks (`beforeEach`, `beforeAll`) and the functions declared next to the tests are not judged: a loop that seeds a table in a hook, a helper of `test/e2e/support/` that decides, are where the logic goes. A case per row is an `it.each` whose table is the rows: the report then names each one.
56
+
57
+ ## Options
58
+
59
+ None.
60
+
61
+ `rules."test/no-logic"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line test/no-logic -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
62
+
63
+ ## Limits
64
+
65
+ - `&&`, `||` and `??` are not reported: `expect(a && b)` is a weak assertion, not a branch.
66
+ - A function called from the test and declared elsewhere may hold any logic: the rule reads the body of the test, the review reads the helper.
67
+
68
+ ## With the CLI checker
69
+
70
+ New with this plugin: the CLI checker has no equivalent, because reading a test needs a syntax tree.
@@ -0,0 +1,56 @@
1
+ [English](test-no-only-no-skip.md) · **Français**
2
+ <!-- translation-of: test-no-only-no-skip.md sha256:f7350957fb15faab -->
3
+
4
+ # ddd-ts-kit/test-no-only-no-skip
5
+
6
+ Identifiant d'architecture : `test/no-only-no-skip` (ajouté par ce *plugin*). Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : chaque fichier de test du projet (`*.spec.ts`, `*.test.ts`, le `test/` d'un contexte).
9
+
10
+ ## Pourquoi
11
+
12
+ Un test laissé de côté rend l'exécution verte alors que quelque chose n'est pas prouvé. Le `.only` a été écrit pour déboguer un test et oublié : les autres ne tournent plus. `.skip` garde un test dans le fichier alors que rien ne le tient, et le jour où il aurait échoué personne n'est prévenu ; `.skipIf(true)` et `.runIf(false)` sont la même chose avec une condition qui ne change jamais. Le kit nomme plutôt ce qui n'est pas encore prouvé : un `it.todo` dont le titre est le comportement, que `ddd-ts-kit todo` liste et que `story --gate close` refuse tant qu'il appartient à la *story*.
13
+
14
+ ## Signalé
15
+
16
+ - `it.only`, `test.only`, `describe.only`, seul ou après un autre modificateur (`it.concurrent.only`)
17
+ - `it.skip`, `test.skip`, `describe.skip`
18
+ - `it.skipIf`, `it.runIf`, `describe.skipIf`, `describe.runIf` sur une constante (`true`, `false`, une chaîne) ou sur rien
19
+ - `fit`, `xit`, `xtest`, `fdescribe`, `xdescribe`
20
+
21
+ Incorrect :
22
+
23
+ ```ts
24
+ it.only('refuses to pay an invoice twice', () => { ... });
25
+ describe.skip('Invoice', () => { ... });
26
+ it.skipIf(true)('records the payment', () => { ... });
27
+ ```
28
+
29
+ Correct :
30
+
31
+ ```ts
32
+ it('refuses to pay an invoice twice', () => { ... });
33
+ it.todo('refuses to pay an invoice whose customer is closed');
34
+ describe.runIf(process.env['VARNISH_URL'] !== undefined)('through Varnish', () => { ... });
35
+ ```
36
+
37
+ ## Détails
38
+
39
+ `it.todo`, `it.each`, `it.concurrent` et `it.sequential` ne sont pas signalés : ils s'exécutent, ou nomment ce qui reste à écrire. `skipIf` et `runIf` sur une expression ne le sont pas non plus : ils disent où un test s'exécute, comme les tests à travers un cache HTTP s'exécutent là où le *pipeline* en démarre un ; le test y est alors exécuté, pas laissé de côté. Un test faux pour de bon est supprimé, avec la raison dans le *commit*.
40
+
41
+ La règle lit les `it`, `test` et `describe` du lanceur, importés de `vitest` ou de `@jest/globals` ou globaux ; une variable locale du même nom n'est pas jugée.
42
+
43
+ ## Options
44
+
45
+ Aucune.
46
+
47
+ `rules."test/no-only-no-skip"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line test/no-only-no-skip -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
48
+
49
+ ## Limites
50
+
51
+ - Une fonction du lanceur renommée (`const only = it.only`) ou tirée de `it.extend(...)` n'est pas suivie.
52
+ - Une condition constante sans être un littéral (`const NEVER = false; it.skipIf(!NEVER)`) est lue comme une condition.
53
+
54
+ ## Avec le checker de la CLI
55
+
56
+ Nouveau avec ce *plugin* : le *checker* de la CLI n'a pas d'équivalent, car lire un test demande un arbre syntaxique.
@@ -0,0 +1,55 @@
1
+ **English** · [Français](test-no-only-no-skip.fr.md)
2
+
3
+ # ddd-ts-kit/test-no-only-no-skip
4
+
5
+ Architecture id: `test/no-only-no-skip` (added by this plugin). Default severity: `error` in `recommended`, `error` in `strict`.
6
+
7
+ Applies to: every test file of the project (`*.spec.ts`, `*.test.ts`, the `test/` of a context).
8
+
9
+ ## Why
10
+
11
+ A test left aside makes the run green while something is not proven. `.only` was written to debug one test and forgotten: the others no longer run. `.skip` keeps a test in the file while nothing holds it, and the day it would have failed nobody is told; `.skipIf(true)` and `.runIf(false)` are the same thing with a condition that never changes. The kit names what is not proven yet instead: an `it.todo` with the behaviour as its title, which `ddd-ts-kit todo` lists and `story --gate close` refuses while one belongs to the story.
12
+
13
+ ## Reported
14
+
15
+ - `it.only`, `test.only`, `describe.only`, alone or after another modifier (`it.concurrent.only`)
16
+ - `it.skip`, `test.skip`, `describe.skip`
17
+ - `it.skipIf`, `it.runIf`, `describe.skipIf`, `describe.runIf` on a constant (`true`, `false`, a string) or on nothing
18
+ - `fit`, `xit`, `xtest`, `fdescribe`, `xdescribe`
19
+
20
+ Incorrect:
21
+
22
+ ```ts
23
+ it.only('refuses to pay an invoice twice', () => { ... });
24
+ describe.skip('Invoice', () => { ... });
25
+ it.skipIf(true)('records the payment', () => { ... });
26
+ ```
27
+
28
+ Correct:
29
+
30
+ ```ts
31
+ it('refuses to pay an invoice twice', () => { ... });
32
+ it.todo('refuses to pay an invoice whose customer is closed');
33
+ describe.runIf(process.env['VARNISH_URL'] !== undefined)('through Varnish', () => { ... });
34
+ ```
35
+
36
+ ## Details
37
+
38
+ `it.todo`, `it.each`, `it.concurrent` and `it.sequential` are not reported: they run, or they name what is to be written. `skipIf` and `runIf` on an expression are not reported either: they say where a test runs, as the tests through an HTTP cache run where the pipeline starts one; the test is then run there, not left aside. A test that is wrong for good is deleted, with the reason in the commit.
39
+
40
+ The rule reads `it`, `test` and `describe` of the runner, imported from `vitest` or `@jest/globals` or global; a local of the same name is not judged.
41
+
42
+ ## Options
43
+
44
+ None.
45
+
46
+ `rules."test/no-only-no-skip"` in `ddd-ts-kit.config.json` set to `off` silences the rule, and `// ddd-ts-kit-disable-next-line test/no-only-no-skip -- <reason>` silences one line, exactly as for `ddd-ts-kit check`.
47
+
48
+ ## Limits
49
+
50
+ - A runner function renamed (`const only = it.only`) or taken from `it.extend(...)` is not followed.
51
+ - A condition that is constant without being a literal (`const NEVER = false; it.skipIf(!NEVER)`) is read as a condition.
52
+
53
+ ## With the CLI checker
54
+
55
+ New with this plugin: the CLI checker has no equivalent, because reading a test needs a syntax tree.
@@ -0,0 +1,52 @@
1
+ [English](test-no-snapshot.md) · **Français**
2
+ <!-- translation-of: test-no-snapshot.md sha256:40cd387b2b3fb2ba -->
3
+
4
+ # ddd-ts-kit/test-no-snapshot
5
+
6
+ Identifiant d'architecture : `test/no-snapshot` (ajouté par ce *plugin*). Sévérité par défaut : `error` dans `recommended`, `error` dans `strict`.
7
+
8
+ S'applique à : chaque fichier de test du projet (`*.spec.ts`, `*.test.ts`, le `test/` d'un contexte).
9
+
10
+ ## Pourquoi
11
+
12
+ Un *snapshot* enregistre ce que le code a produit la première fois, et se renouvelle d'un seul drapeau la fois suivante où il diffère : il ne vérifie rien qu'un lecteur puisse confronter à la règle, et il échoue sur chaque champ dont la règle ne dépend pas. Un test énonce les champs qui comptent, construits dans le test, pour que le lecteur voie la cause du résultat.
13
+
14
+ ## Signalé
15
+
16
+ - `toMatchSnapshot`, `toMatchInlineSnapshot`, `toMatchFileSnapshot`
17
+ - `toThrowErrorMatchingSnapshot`, `toThrowErrorMatchingInlineSnapshot`
18
+
19
+ Incorrect :
20
+
21
+ ```ts
22
+ expect(invoice.toState()).toMatchSnapshot();
23
+ expect(() => invoice.pay(at)).toThrowErrorMatchingInlineSnapshot();
24
+ ```
25
+
26
+ Correct :
27
+
28
+ ```ts
29
+ expect(invoice.toState()).toMatchObject({ status: 'paid', paidAt: at });
30
+
31
+ given(anInvoice().paid())
32
+ .when((invoice) => invoice.pay(at))
33
+ .thenError('INVOICE_ALREADY_PAID');
34
+ ```
35
+
36
+ ## Détails
37
+
38
+ Les contrats que le kit génère (OpenAPI, AsyncAPI, le catalogue d'événements) sont tenus par `ddd-ts-kit docs --check`, qui compare le document généré avec celui qui est *commité* : c'est le seul endroit où un document entier est comparé, et ce n'est pas un test.
39
+
40
+ ## Options
41
+
42
+ Aucune.
43
+
44
+ `rules."test/no-snapshot"` à `off` dans `ddd-ts-kit.config.json` désactive la règle, et `// ddd-ts-kit-disable-next-line test/no-snapshot -- <reason>` désactive une ligne, exactement comme pour `ddd-ts-kit check`.
45
+
46
+ ## Limites
47
+
48
+ - Un `toEqual` sur un gros objet lu dans un fichier de *fixture* est un *snapshot* sous un autre nom, et n'est pas signalé.
49
+
50
+ ## Avec le checker de la CLI
51
+
52
+ Nouveau avec ce *plugin* : le *checker* de la CLI n'a pas d'équivalent, car lire un test demande un arbre syntaxique.