@ddd-ts-kit/eslint-plugin 0.110.1 → 0.112.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.
package/README.fr.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [English](README.md) · **Français**
2
- <!-- translation-of: README.md sha256:328005b51ed4322c -->
2
+ <!-- translation-of: README.md sha256:71350248628b22c6 -->
3
3
 
4
4
  # @ddd-ts-kit/eslint-plugin
5
5
 
@@ -281,7 +281,7 @@ chaque règle à `error`.
281
281
  | [`lifecycle/status-through-machine`](docs/rules/lifecycle-status-through-machine.fr.md) | `ddd-ts-kit/lifecycle-status-through-machine` | dans un agrégat qui importe sa machine à états, le statut n'est écrit que depuis la machine (`next`, `start`) ou copié d'un statut déjà lu | `error` | maison |
282
282
  | [`process/sends-commands-only`](docs/rules/process-sends-commands-only.fr.md) | `ddd-ts-kit/process-sends-commands-only` | un gestionnaire de processus de `application/processes/` n'importe aucun agrégat, entité, *repository*, service du domaine, port ni infrastructure : il change le monde par les commandes qu'il décide | `error` | maison |
283
283
  | [`schema/presentation-only`](docs/rules/schema-presentation-only.fr.md) | `ddd-ts-kit/schema-presentation-only` | sous `stack.schemas: shared`, un schéma du contrat HTTP vit dans `presentation/` de son contexte ou du noyau partagé : le noyau partagé n'importe aucune bibliothèque de validation hors de `presentation/`, et aucun domaine, application, infrastructure ni langage publié n'importe un fichier de `presentation/` du noyau partagé | `error` | maison |
284
- | [`imports/alias-only`](docs/rules/imports-alias-only.fr.md) | `ddd-ts-kit/imports-alias-only` | un fichier du projet est importé par son alias (`@/...`, `$test/...`, `$scripts/...`), jamais par un chemin relatif, même répertoire compris ; aucun segment `.` ou `..` dans le chemin d'un alias ; corrigeable automatiquement | `error` | maison |
284
+ | [`imports/alias-only`](docs/rules/imports-alias-only.fr.md) | `ddd-ts-kit/imports-alias-only` | un fichier du projet est importé par son alias (`@/...`, `$test/...`, `$scripts/...`), jamais par un chemin relatif, même répertoire compris, sauf entre les fichiers placés directement sous `test/support/`, qu'un lanceur de tests charge avant qu'aucun alias n'existe et qui nomment leur voisin par `./<nom>`, avec son `.ts` sous `js` ; aucun segment `.` ou `..` dans le chemin d'un alias ; corrigeable automatiquement | `error` | maison |
285
285
  | [`imports/extension`](docs/rules/imports-extension.fr.md) | `ddd-ts-kit/imports-extension` | un import d'un fichier du projet se termine comme le dit `importExtension` de la config : pas d'extension sous `none`, `.js` sous `js` ; corrigeable automatiquement | `error` | maison |
286
286
 
287
287
  Les identifiants `domain/*` et `application/*` sont ajoutés par ce plugin : la forme d'une classe
@@ -432,7 +432,7 @@ propres noms de règle.
432
432
  | Préoccupation | Autorité | Pourquoi |
433
433
  |---|---|---|
434
434
  | imports et frontières (`layer/*`, `context/published-language-only`, `context/declared-relationship`, `context/published-language-is-a-contract`), `purity/*`, `clean/*`, `test/no-mocks`, les six règles sur la forme d'un test (`test/no-only-no-skip`, `test/title-states-a-rule`, `test/no-logic`, `test/assertion-present`, `test/refusal-by-code`, `test/no-snapshot`), `events/name-format`, `domain/*`, `application/*`, le côté code de `events/outbox-required`, `events/consumer-idempotent`, `context/extractable`, `authz/*`, `aspects/outside-in`, `tracing/platform-only`, `domain-events/dispatched-on-save`, `domain-events/transactional-before-commit` sur une classe déclarée, `event-sourcing/*` (sauf le verrou de `event-sourcing/upcaster-required`), `standard/no-parallel-interface`, `declarations/role-declared`, `ports/*`, `scheduling/*` (sauf l'unicité des noms de *jobs*), `language/declared-vocabulary`, `errors/through-factory`, `errors/constructor-not-public`, `errors/factory-name`, `presentation/*`, `lifecycle/*`, `process/*`, `schema/presentation-only`, `imports/alias-only`, `imports/extension` et `governance/recorded-deviation` | ce plugin | il lit l'arbre syntaxique : aucun faux positif dû à une chaîne ou à un commentaire, le masquage de variables et les fonctions fléchées sont compris |
435
- | l'arborescence (`tree/closed`, `tree/context-doc`), les noms et les fichiers (`naming/*` hormis le côté code de `naming/business-name`, que ce plugin lit sur l'arbre syntaxique et corrige, `test/spec-required`, `test/builder-required`), le langage (`language/glossary-term`, `language/no-technical-name`), les codes d'erreur (`errors/code-unique`, `errors/known-code`), `imports/alias-declared`, `schema/no-duplicate-shape`, la config (`config/*`, `context/no-cycle`), `events/defined-in-published-language`, `composition/only-in-module`, `declarations/barrel-current`, l'unicité des noms de consommateurs et de *jobs*, une seule classe déclarée par fichier de rôle, de `domain-events/transactional-before-commit` les adaptateurs d'un port de `application/ports/` et la phase d'un gestionnaire du style explicite, le côté config des identifiants ci-dessus (`stack.events`, sévérités abaissées, existence d'un enregistrement de décision) | `ddd-ts-kit check` | ils jugent le projet, le glossaire et des fichiers qui ne sont pas des sources ; ESLint juge une source à la fois |
435
+ | l'arborescence (`tree/closed`, `tree/context-doc`), les noms et les fichiers (`naming/*` hormis le côté code de `naming/business-name`, que ce plugin lit sur l'arbre syntaxique et corrige, `test/spec-required`, `test/builder-required`), le langage (`language/glossary-term`, `language/no-technical-name`), les codes d'erreur (`errors/code-unique`, `errors/known-code`), `imports/alias-declared`, `schema/no-duplicate-shape`, la config (`config/*`, `context/no-cycle`), `events/defined-in-published-language`, `composition/only-in-module`, `declarations/barrel-current`, `aspects/timeout-covers-delegate`, l'unicité des noms de consommateurs et de *jobs*, une seule classe déclarée par fichier de rôle, de `domain-events/transactional-before-commit` les adaptateurs d'un port de `application/ports/` et la phase d'un gestionnaire du style explicite, le côté config des identifiants ci-dessus (`stack.events`, sévérités abaissées, existence d'un enregistrement de décision) | `ddd-ts-kit check` | ils jugent le projet, le glossaire et des fichiers qui ne sont pas des sources ; ESLint juge une source à la fois |
436
436
  | le vrai graphe des dépendances (barrels, cycles, orphelins, dépendances de développement dans le code de production) | dependency-cruiser, configuré par le `.dependency-cruiser.cjs` que `ddd-ts-kit depcruise-config --write` génère à partir de la config | il résout les modules au lieu de classer des chemins |
437
437
 
438
438
  La CLI continue d'approcher les règles de niveau code par des expressions régulières, sans
package/README.md CHANGED
@@ -277,7 +277,7 @@ is an error whatever the configured limit). `strict` sets every rule to `error`.
277
277
  | [`lifecycle/status-through-machine`](docs/rules/lifecycle-status-through-machine.md) | `ddd-ts-kit/lifecycle-status-through-machine` | in an aggregate that imports its state machine, the status is written only from the machine (`next`, `start`) or copied from a status already read | `error` | custom |
278
278
  | [`process/sends-commands-only`](docs/rules/process-sends-commands-only.md) | `ddd-ts-kit/process-sends-commands-only` | a process manager of `application/processes/` imports no aggregate, entity, repository, domain service, port or infrastructure: it changes the world through the commands it decides | `error` | custom |
279
279
  | [`schema/presentation-only`](docs/rules/schema-presentation-only.md) | `ddd-ts-kit/schema-presentation-only` | under `stack.schemas: shared`, a schema of the HTTP contract lives in `presentation/` of its context or of the shared kernel: the shared kernel imports no validation library outside `presentation/`, and no domain, application, infrastructure or published language imports a file of `presentation/` of the shared kernel | `error` | custom |
280
- | [`imports/alias-only`](docs/rules/imports-alias-only.md) | `ddd-ts-kit/imports-alias-only` | a file of the project is imported by its alias (`@/...`, `$test/...`, `$scripts/...`), never by a relative path, the same directory included; no `.` or `..` segment in an alias path; fixable | `error` | custom |
280
+ | [`imports/alias-only`](docs/rules/imports-alias-only.md) | `ddd-ts-kit/imports-alias-only` | a file of the project is imported by its alias (`@/...`, `$test/...`, `$scripts/...`), never by a relative path, the same directory included, but between the files directly under `test/support/`, which a test runner loads before any alias exists and which name their neighbour by `./<name>`, with its `.ts` under `js`; no `.` or `..` segment in an alias path; fixable | `error` | custom |
281
281
  | [`imports/extension`](docs/rules/imports-extension.md) | `ddd-ts-kit/imports-extension` | an import of a file of the project ends as `importExtension` of the config says: no extension under `none`, `.js` under `js`; fixable | `error` | custom |
282
282
 
283
283
  `domain/*` and `application/*` ids are added by this plugin: the shape of a class needs a syntax
@@ -422,7 +422,7 @@ config: it runs on a file generated from it, with its own rule names.
422
422
  | Concern | Authority | Why |
423
423
  |---|---|---|
424
424
  | imports and boundaries (`layer/*`, `context/published-language-only`, `context/declared-relationship`, `context/published-language-is-a-contract`), `purity/*`, `clean/*`, `test/no-mocks`, the six rules on the shape of a test (`test/no-only-no-skip`, `test/title-states-a-rule`, `test/no-logic`, `test/assertion-present`, `test/refusal-by-code`, `test/no-snapshot`), `events/name-format`, `domain/*`, `application/*`, the code side of `events/outbox-required`, `events/consumer-idempotent`, `context/extractable`, `authz/*`, `aspects/outside-in`, `tracing/platform-only`, `domain-events/dispatched-on-save`, `domain-events/transactional-before-commit` on a declared class, `event-sourcing/*` (but the lock of `event-sourcing/upcaster-required`), `standard/no-parallel-interface`, `declarations/role-declared`, `ports/*`, `scheduling/*` (but the uniqueness of job names), `language/declared-vocabulary`, `errors/through-factory`, `errors/constructor-not-public`, `errors/factory-name`, `presentation/*`, `lifecycle/*`, `process/*`, `schema/presentation-only`, `imports/alias-only`, `imports/extension` and `governance/recorded-deviation` | this plugin | it reads the syntax tree: no false positive from a string or a comment, shadowing and arrow functions are understood |
425
- | the tree (`tree/closed`, `tree/context-doc`), names and files (`naming/*` but the code side of `naming/business-name`, which this plugin reads on the syntax tree and fixes, `test/spec-required`, `test/builder-required`), the language (`language/glossary-term`, `language/no-technical-name`), error codes (`errors/code-unique`, `errors/known-code`), `imports/alias-declared`, `schema/no-duplicate-shape`, the config (`config/*`, `context/no-cycle`), `events/defined-in-published-language`, `composition/only-in-module`, `declarations/barrel-current`, unique consumer names and job names, one declared class per role file, of `domain-events/transactional-before-commit` the adapters of an `application/ports/` port and the phase of an explicit-style handler, the config side of the ids above (`stack.events`, lowered severities, that a decision record exists) | `ddd-ts-kit check` | they judge the project, the glossary and files that are not sources; ESLint judges one source at a time |
425
+ | the tree (`tree/closed`, `tree/context-doc`), names and files (`naming/*` but the code side of `naming/business-name`, which this plugin reads on the syntax tree and fixes, `test/spec-required`, `test/builder-required`), the language (`language/glossary-term`, `language/no-technical-name`), error codes (`errors/code-unique`, `errors/known-code`), `imports/alias-declared`, `schema/no-duplicate-shape`, the config (`config/*`, `context/no-cycle`), `events/defined-in-published-language`, `composition/only-in-module`, `declarations/barrel-current`, `aspects/timeout-covers-delegate`, unique consumer names and job names, one declared class per role file, of `domain-events/transactional-before-commit` the adapters of an `application/ports/` port and the phase of an explicit-style handler, the config side of the ids above (`stack.events`, lowered severities, that a decision record exists) | `ddd-ts-kit check` | they judge the project, the glossary and files that are not sources; ESLint judges one source at a time |
426
426
  | the real dependency graph (barrels, cycles, orphans, dev dependencies in production code) | dependency-cruiser, configured by the `.dependency-cruiser.cjs` that `ddd-ts-kit depcruise-config --write` generates from the config | it resolves modules instead of classifying paths |
427
427
 
428
428
  The CLI keeps approximating the code-level rules with regular expressions, without dependency:
@@ -0,0 +1,7 @@
1
+ /**
2
+ * What the relative path of a file of `test/support/` to its neighbour ends with under
3
+ * "importExtension": nothing for `none`, the `.ts` of the source otherwise. Mirrors
4
+ * `neighbourSuffix` of the CLI.
5
+ */
6
+ export declare function neighbourSuffix(importExtension: string): '' | '.ts';
7
+ //# sourceMappingURL=neighbour-suffix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neighbour-suffix.d.ts","sourceRoot":"","sources":["../../src/project/neighbour-suffix.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,EAAE,GAAG,KAAK,CAEnE"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * What the relative path of a file of `test/support/` to its neighbour ends with under
3
+ * "importExtension": nothing for `none`, the `.ts` of the source otherwise. Mirrors
4
+ * `neighbourSuffix` of the CLI.
5
+ */
6
+ export function neighbourSuffix(importExtension) {
7
+ return importExtension === 'none' ? '' : '.ts';
8
+ }
9
+ //# sourceMappingURL=neighbour-suffix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neighbour-suffix.js","sourceRoot":"","sources":["../../src/project/neighbour-suffix.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,eAAuB;IACrD,OAAO,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- type MessageId = 'relative' | 'unnamed' | 'segment';
2
+ type MessageId = 'relative' | 'unnamed' | 'segment' | 'neighbourSource' | 'neighbourExtension';
3
3
  export declare const importsAliasOnly: TSESLint.RuleModule<MessageId, [], import("../index.js").RuleDocs, TSESLint.RuleListener>;
4
4
  export {};
5
5
  //# sourceMappingURL=imports-alias-only.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"imports-alias-only.d.ts","sourceRoot":"","sources":["../../src/rules/imports-alias-only.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAUnE,KAAK,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAKpD,eAAO,MAAM,gBAAgB,kFA8B3B,CAAC"}
1
+ {"version":3,"file":"imports-alias-only.d.ts","sourceRoot":"","sources":["../../src/rules/imports-alias-only.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAWnE,KAAK,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAmB/F,eAAO,MAAM,gBAAgB,kFAkC3B,CAAC"}
@@ -1,21 +1,39 @@
1
+ import fs from 'node:fs';
1
2
  import path from 'node:path';
2
3
  import { aliasRoots } from '../project/alias-roots.js';
3
4
  import { isJudged } from '../project/is-judged.js';
5
+ import { neighbourSuffix } from '../project/neighbour-suffix.js';
4
6
  import { specifierSuffix } from '../project/specifier-suffix.js';
5
7
  import { toAlias } from '../project/to-alias.js';
6
8
  import { importListener } from '../support/imports/import-listener.js';
7
9
  import { defineRule } from '../support/rule/define-rule.js';
8
10
  const RELATIVE = /^\.{1,2}(?:\/|$)/;
9
11
  const DOT_SEGMENT = /\/\.{1,2}(?:\/|$)/;
12
+ /**
13
+ * A test runner loads its global setup, and what that file imports, from the sources and before
14
+ * any alias of the project exists: the files directly under `test/support/` import one another by
15
+ * a relative path of that same directory, `./<name>`, and nothing else is spared: not the
16
+ * directory itself (`./.`), its parent (`./..`), nor a directory of it. The path names the file
17
+ * the runner finds: the source, with its `.ts` where an import carries an extension. What is on
18
+ * disk when the file is linted says which file that is.
19
+ */
20
+ const LOADED_BY_A_RUNNER = /^test\/support\/[^/]+$/;
21
+ const NEIGHBOUR = /^\.\/(?!\.{1,2}$)[^/]+$/;
22
+ /** The extensions a module of the project or the file emitted for it can bear. */
23
+ const EXTENSION = /\.(?:[cm]?js|[cm]?ts)$/;
24
+ /** The source the compiler emits a JavaScript file from, by their extensions. */
25
+ const SOURCE_OF = { '.js': '.ts', '.mjs': '.mts', '.cjs': '.cts' };
10
26
  export const importsAliasOnly = defineRule({
11
27
  id: 'imports/alias-only',
12
28
  type: 'suggestion',
13
29
  recommended: 'error',
14
30
  fixable: 'code',
15
- description: 'A file of the project is imported by its alias (`@/...`), never by a relative path, the same directory included; an alias path holds no `.` or `..` segment.',
31
+ description: 'A file of the project is imported by its alias (`@/...`), never by a relative path, the same directory included; an alias path holds no `.` or `..` segment. The files directly under `test/support/`, which a test runner loads before any alias exists, import one another by `./<name>`, ending with `.ts` under `js`.',
16
32
  messages: {
17
33
  relative: '"{{specifier}}" is a relative import. Import the file by its alias, \'{{alias}}\': the alias names the file from the root of the project, so the import reads the same from anywhere and survives a move of this file.',
18
34
  unnamed: '"{{specifier}}" is a relative import of a file no alias names. Keep what the code imports under {{directories}}; a file elsewhere (a manifest, a build product) is read at run time, not imported.',
35
+ neighbourSource: '"{{specifier}}" does not name its neighbour of test/support/ by the name of its source. Write \'{{expected}}\': a test runner loads its global setup, and what that file imports, from the sources and before any alias exists, where the file is "{{source}}". The name of the file the compiler would emit passes the type check, then stops the run on a module that cannot be found.',
36
+ neighbourExtension: '"{{specifier}}" ends with "{{extension}}" although "importExtension" is "none". Write \'{{expected}}\': a file of test/support/ names its neighbour as every import of the project names a file, without its extension.',
19
37
  segment: 'The alias import "{{specifier}}" holds a "." or ".." segment: it can leave {{directory}}/. Write the path of the file from {{directory}}/ after "{{prefix}}", with no "." or ".." segment: an alias names one file of its directory, and the build rewrites it as such.',
20
38
  },
21
39
  create({ file, report }) {
@@ -24,17 +42,70 @@ export const importsAliasOnly = defineRule({
24
42
  return {};
25
43
  }
26
44
  return importListener(file, ({ node, specifier }) => {
27
- const finding = RELATIVE.test(specifier) ? relative(file, specifier) : dotSegment(roots, specifier);
45
+ const finding = judged(roots, file, specifier);
28
46
  if (finding !== undefined) {
29
47
  report({ node, ...finding, ...fixOf(node, finding) });
30
48
  }
31
49
  });
32
50
  },
33
51
  });
34
- function relative(file, specifier) {
52
+ function judged(roots, file, specifier) {
53
+ if (LOADED_BY_A_RUNNER.test(file.path) && NEIGHBOUR.test(specifier)) {
54
+ return namesADirectory(file, specifier) ? directory(file, specifier) : neighbour(file, specifier);
55
+ }
56
+ return RELATIVE.test(specifier) ? relative(file, specifier) : dotSegment(roots, specifier);
57
+ }
58
+ /** `./parts` where test/support/parts/ is a directory and no parts.ts stands beside it, as the disk says when the file is linted. */
59
+ function namesADirectory(file, specifier) {
60
+ const named = path.join(file.root, path.posix.dirname(file.path), specifier);
61
+ return !isFile(`${named}.ts`) && fs.statSync(named, { throwIfNoEntry: false })?.isDirectory() === true;
62
+ }
63
+ /** A directory is no neighbour: its index is a file of another directory, named by its alias, which names the index file where an import carries an extension. */
64
+ function directory(file, specifier) {
65
+ const bare = specifierSuffix(file.config.importExtension) === '';
66
+ return relative(file, specifier, bare ? specifier : `${specifier}/index`);
67
+ }
68
+ /** What the runner finds on disk is judged, whatever the compiler would accept: a neighbour named as it should be, or left to the compiler, is not reported. */
69
+ function neighbour(file, specifier) {
70
+ const expected = neighbourName(file, specifier);
71
+ const extension = EXTENSION.exec(specifier)?.[0] ?? '';
72
+ const bare = neighbourSuffix(file.config.importExtension) === '';
73
+ if (expected === undefined) {
74
+ return undefined;
75
+ }
76
+ return {
77
+ messageId: bare ? 'neighbourExtension' : 'neighbourSource',
78
+ data: { specifier, extension, expected, source: expected.slice(2) },
79
+ };
80
+ }
81
+ /**
82
+ * The name a neighbour is to be imported by, when it is imported by another one. Under `none`, the
83
+ * source `<name>.ts` without its extension. Otherwise the source that exists: `<name>.ts` for
84
+ * `<name>` and `<name>.js`, `<name>.mts` for `<name>.mjs`, `<name>.cts` for `<name>.cjs`. A file
85
+ * that exists as it is named (a source, a JSON file, a JavaScript file) is left alone, and so is a
86
+ * name no source answers, which the compiler reports.
87
+ */
88
+ function neighbourName(file, specifier) {
89
+ const extension = EXTENSION.exec(specifier)?.[0] ?? '';
90
+ const bare = specifier.slice(0, specifier.length - extension.length);
91
+ const exists = (name) => isFile(path.join(file.root, path.posix.dirname(file.path), name));
92
+ const source = `${bare}${SOURCE_OF[extension] ?? '.ts'}`;
93
+ if (neighbourSuffix(file.config.importExtension) === '') {
94
+ return namedWithItsExtension(extension, exists(specifier)) && exists(`${bare}.ts`) ? bare : undefined;
95
+ }
96
+ return !exists(specifier) && exists(source) ? source : undefined;
97
+ }
98
+ /** Under `none`: a source named with its `.ts`, or by the `.js` the compiler would emit, unless a JavaScript file of that name is there. */
99
+ function namedWithItsExtension(extension, isThere) {
100
+ return extension === '.ts' || (extension === '.js' && !isThere);
101
+ }
102
+ function isFile(file) {
103
+ return fs.statSync(file, { throwIfNoEntry: false })?.isFile() === true;
104
+ }
105
+ function relative(file, specifier, target = specifier) {
35
106
  const roots = aliasRoots(file.config);
36
107
  const suffix = specifierSuffix(file.config.importExtension);
37
- const alias = toAlias(roots, path.posix.join(path.posix.dirname(file.path), specifier), suffix);
108
+ const alias = toAlias(roots, path.posix.join(path.posix.dirname(file.path), target), suffix);
38
109
  if (alias !== undefined) {
39
110
  return { messageId: 'relative', data: { specifier, alias } };
40
111
  }
@@ -52,10 +123,10 @@ function dotSegment(roots, specifier) {
52
123
  }
53
124
  /** The specifier rewritten in place, between the quotes it was written with. */
54
125
  function fixOf(node, { messageId, data }) {
55
- const alias = data['alias'];
56
- if (messageId !== 'relative' || alias === undefined) {
126
+ const rewritten = messageId === 'relative' ? data['alias'] : data['expected'];
127
+ if (rewritten === undefined) {
57
128
  return {};
58
129
  }
59
- return { fix: (fixer) => fixer.replaceTextRange([node.range[0] + 1, node.range[1] - 1], alias) };
130
+ return { fix: (fixer) => fixer.replaceTextRange([node.range[0] + 1, node.range[1] - 1], rewritten) };
60
131
  }
61
132
  //# sourceMappingURL=imports-alias-only.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"imports-alias-only.js","sourceRoot":"","sources":["../../src/rules/imports-alias-only.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAIzD,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAY;IACpD,EAAE,EAAE,oBAAoB;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,OAAO;IACpB,OAAO,EAAE,MAAM;IACf,WAAW,EACT,8JAA8J;IAChK,QAAQ,EAAE;QACR,QAAQ,EACN,wNAAwN;QAC1N,OAAO,EACL,oMAAoM;QACtM,OAAO,EACL,yQAAyQ;KAC5Q;IACD,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;QACrB,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEtC,IAAI,CAAC,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CAAC;AACzG,CAAC;AAED,gFAAgF;AAChF,SAAS,KAAK,CAAC,IAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAS;IAC5D,MAAM,SAAS,GAAG,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE9E,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;AACvG,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.110.1";
1
+ export declare const VERSION = "0.112.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.110.1';
1
+ export const VERSION = '0.112.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
1
  [English](imports-alias-only.md) · **Français**
2
- <!-- translation-of: imports-alias-only.md sha256:6ba4c7970c915372 -->
2
+ <!-- translation-of: imports-alias-only.md sha256:a3c12d183835229d -->
3
3
 
4
4
  # ddd-ts-kit/imports-alias-only
5
5
 
@@ -15,7 +15,7 @@ L'alias est déclaré une fois, sous `paths` dans `tsconfig.json`, que lisent le
15
15
 
16
16
  ## Signalé
17
17
 
18
- - un spécificateur relatif, `./x` ou `../x`, avec ou sans extension, même répertoire compris : corrigé vers l'alias du fichier
18
+ - un spécificateur relatif, `./x` ou `../x`, avec ou sans extension, même répertoire compris : corrigé vers l'alias du fichier (sauf entre deux fichiers placés directement sous `test/support/`, voir Détails)
19
19
  - un spécificateur relatif qui nomme un fichier hors de tout répertoire doté d'un alias (un manifeste, un produit de la construction) : signalé, non corrigé
20
20
  - un spécificateur d'alias avec un segment `.` ou `..`, qui pourrait nommer un fichier hors du répertoire de l'alias : signalé, non corrigé
21
21
 
@@ -56,6 +56,15 @@ Les alias d'un projet :
56
56
 
57
57
  La correction calcule l'alias à partir de l'emplacement du fichier et de la configuration : le spécificateur relatif est résolu depuis le répertoire du fichier, et le résultat est écrit depuis le répertoire que nomme son alias, avec la terminaison que dit `importExtension` de la configuration : rien sous `none`, `.js` sous `js` (une configuration sans la clé). Elle garde les guillemets du spécificateur. Un import corrigé est souvent plus long que la ligne : lancez le formateur après la correction (`npm run format`). Corriger deux fois ne change rien.
58
58
 
59
+ Un seul chemin relatif est admis : un fichier placé directement sous `test/support/` importe son voisin par `./<nom>`. Un lanceur de tests charge sa mise en place globale (*global setup*), et chaque fichier que celle-ci importe, avant qu'aucun alias du projet n'existe : Jest n'y applique aucun `moduleNameMapper`, et une mise en place qui importerait par alias ne se chargerait que depuis le script du projet, ni depuis `NODE_OPTIONS=--experimental-vm-modules npx jest` ni depuis un éditeur. Rien d'autre n'est épargné : depuis `test/support/`, `../e2e/support/start-application`, `./parts/part`, `./.` et `./..` sont signalés, de même que `./parts` quand le disque porte un répertoire de ce nom sans `parts.ts` à côté ; un fichier de tout autre répertoire importe son voisin par alias.
60
+
61
+ Le nom de ce voisin est jugé d'après les fichiers présents sur le disque, et corrigé. Sous `"importExtension": "none"`, une source `.ts` ne porte aucune extension (`./test-database-run`). Sous `"importExtension": "js"`, le voisin est nommé par le nom de sa source : le lanceur charge les sources à travers sa transformation, qui trouve le fichier sous le nom qu'il porte. Un `./test-database-run.js` à cet endroit passe la vérification des types, puis arrête l'exécution sur `Cannot find module` : la correction écrit `./test-database-run.ts`, et `./esm.mts` pour `./esm.mjs`, `./common.cts` pour `./common.cjs`. Un fichier qui existe tel qu'il est nommé n'est pas signalé (un fichier JSON, un fichier JavaScript, une source `.mts`), pas plus qu'un nom auquel aucune source ne répond, que le compilateur signale. Un répertoire nommé comme un voisin est corrigé en l'alias de son fichier d'index sous `js` (`$test/support/parts/index.js`), du répertoire sous `none`. La vérification des types lit cette terminaison grâce à `allowImportingTsExtensions` et `noEmit` dans `tsconfig.json`, tous deux remis dans `tsconfig.build.json`, ce que tient `imports/alias-declared` de `ddd-ts-kit check`. Qu'un `./parts` soit un répertoire se lit sur le disque au moment où le fichier est analysé ; `ddd-ts-kit check` le lit dans les fichiers du projet.
62
+
63
+ ```ts
64
+ // test/support/test-database-setup.ts
65
+ import { openRun } from './test-database-run';
66
+ ```
67
+
59
68
  Ne sont pas jugés : un fichier hors des trois répertoires (un fichier de configuration à la racine du projet, une migration JavaScript), le client sous `generated/`, qu'un outil écrit, et un spécificateur qui n'est ni relatif ni l'un des alias (un *package*, un module natif de Node).
60
69
 
61
70
  Un alias qui ne nomme aucun fichier n'est pas l'affaire de cette règle : le compilateur le signale (`TS2307`), et la construction le refuse (`ddd-ts-kit build-aliases`).
@@ -14,7 +14,7 @@ The alias is declared once, under `paths` in `tsconfig.json`, which the compiler
14
14
 
15
15
  ## Reported
16
16
 
17
- - a relative specifier, `./x` or `../x`, with or without an extension, the same directory included: fixed to the alias of the file
17
+ - a relative specifier, `./x` or `../x`, with or without an extension, the same directory included: fixed to the alias of the file (but between two files directly under `test/support/`, see Details)
18
18
  - a relative specifier that names a file under no aliased directory (a manifest, a build product): reported, not fixed
19
19
  - an alias specifier with a `.` or `..` segment, which could name a file outside the directory of the alias: reported, not fixed
20
20
 
@@ -55,6 +55,15 @@ The aliases of a project:
55
55
 
56
56
  The fix computes the alias from the place of the file and the config: the relative specifier is resolved from the directory of the file, and the result is written from the directory its alias names, ending as `importExtension` of the config says: with nothing under `none`, with `.js` under `js` (a config without the key). It keeps the quotes of the specifier. A fixed import is often longer than the line: run the formatter after the fix (`npm run format`). Fixing twice changes nothing.
57
57
 
58
+ One relative path stands: a file directly under `test/support/` imports its neighbour by `./<name>`. A test runner loads its global setup, and every file that one imports, before any alias of the project exists: Jest applies no `moduleNameMapper` there, and a setup that imported by alias would load from the script of the project only, not from `NODE_OPTIONS=--experimental-vm-modules npx jest` nor from an editor. Nothing else is spared: from `test/support/`, `../e2e/support/start-application`, `./parts/part`, `./.` and `./..` are reported, and so is `./parts` when the disk holds a directory of that name and no `parts.ts` beside it; a file of any other directory imports its neighbour by alias.
59
+
60
+ The name of that neighbour is judged against the files on disk, and fixed. Under `"importExtension": "none"` a `.ts` source carries no extension (`./test-database-run`). Under `"importExtension": "js"` the neighbour is named by the name of its source: the runner loads the sources through its transform, which finds the file under the name it has. A `./test-database-run.js` there passes the type check, then stops the run on `Cannot find module`: the fix writes `./test-database-run.ts`, and `./esm.mts` for `./esm.mjs`, `./common.cts` for `./common.cjs`. A file that exists as it is named is not reported (a JSON file, a JavaScript file, an `.mts` source), nor is a name no source answers, which the compiler reports. A directory named as a neighbour is fixed to the alias of its index file under `js` (`$test/support/parts/index.js`), of the directory under `none`. The type check reads that ending with `allowImportingTsExtensions` and `noEmit` in `tsconfig.json`, both set back in `tsconfig.build.json`, which `imports/alias-declared` of `ddd-ts-kit check` holds. Whether `./parts` is a directory is read on the disk when the file is linted; `ddd-ts-kit check` reads it from the files of the project.
61
+
62
+ ```ts
63
+ // test/support/test-database-setup.ts
64
+ import { openRun } from './test-database-run';
65
+ ```
66
+
58
67
  Not judged: a file outside the three directories (a config file at the project root, a JavaScript migration), the client under `generated/`, which a tool writes, and a specifier that is neither relative nor one of the aliases (a package, a Node built-in).
59
68
 
60
69
  An alias that names no file is not this rule's concern: the compiler reports it (`TS2307`), and the build refuses it (`ddd-ts-kit build-aliases`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/eslint-plugin",
3
- "version": "0.110.1",
3
+ "version": "0.112.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
  "keywords": [
6
6
  "ddd",