metalint 0.13.0 → 0.15.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 (49) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +42 -9
  3. package/package.json +51 -35
  4. package/src/bin/argv.js +1 -1
  5. package/src/bin/index.js +10 -105
  6. package/src/core/configuration/flatten.js +12 -12
  7. package/src/core/configuration/normalize.js +2 -3
  8. package/src/core/formatter/checkstyle.js +9 -10
  9. package/src/core/formatter/console.js +31 -34
  10. package/src/core/formatter/csv.js +7 -7
  11. package/src/core/formatter/formatter.js +5 -18
  12. package/src/core/formatter/github.js +6 -6
  13. package/src/core/formatter/json.js +9 -9
  14. package/src/core/formatter/unix.js +6 -6
  15. package/src/core/index.js +128 -118
  16. package/src/core/results.js +86 -0
  17. package/src/core/utils/array.js +1 -1
  18. package/src/core/utils/glob.js +1 -1
  19. package/src/core/wrapper/addons-linter.js +3 -6
  20. package/src/core/wrapper/ajv.js +122 -0
  21. package/src/core/wrapper/csslint.js +1 -6
  22. package/src/core/wrapper/depcheck.js +148 -0
  23. package/src/core/wrapper/doiuse.js +3 -4
  24. package/src/core/wrapper/eslint.js +25 -7
  25. package/src/core/wrapper/htmlhint.js +1 -6
  26. package/src/core/wrapper/htmllint.js +1 -6
  27. package/src/core/wrapper/jshint.js +1 -6
  28. package/src/core/wrapper/npm-package-json-lint.js +1 -4
  29. package/src/core/wrapper/publint.js +136 -0
  30. package/src/core/wrapper/standard.js +7 -1
  31. package/src/core/wrapper/stylelint.js +4 -11
  32. package/src/core/wrapper/svglint.js +92 -0
  33. package/src/core/wrapper/wrapper.js +5 -18
  34. package/src/core/wrapper/yaml-lint.js +1 -1
  35. package/types/configuration/flatten.d.ts +2 -3
  36. package/types/configuration/normalize.d.ts +0 -1
  37. package/types/formatter/checkstyle.d.ts +9 -10
  38. package/types/formatter/console.d.ts +13 -16
  39. package/types/formatter/csv.d.ts +6 -6
  40. package/types/formatter/github.d.ts +7 -7
  41. package/types/formatter/json.d.ts +10 -10
  42. package/types/formatter/unix.d.ts +7 -7
  43. package/types/index.d.ts +20 -14
  44. package/types/results.d.ts +7 -0
  45. package/types/wrapper/ajv.d.ts +36 -0
  46. package/types/wrapper/depcheck.d.ts +36 -0
  47. package/types/wrapper/publint.d.ts +33 -0
  48. package/types/wrapper/stylelint.d.ts +2 -2
  49. package/types/wrapper/svglint.d.ts +36 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2023 Sébastien Règne
3
+ Copyright (c) 2020-2024 Sébastien Règne
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Metalint
2
2
 
3
- <!-- Utiliser du HTML pour faire flotter l'image à droite. -->
3
+ <!-- Utiliser du HTML (avec l'attribut "align" obsolète) pour faire flotter
4
+ l'image à droite. -->
4
5
  <!-- markdownlint-disable-next-line no-inline-html-->
5
6
  <img src="asset/logo.svg" align="right" alt="">
6
7
 
@@ -72,6 +73,7 @@ source) :
72
73
  <tr>
73
74
  <td>JSON</td>
74
75
  <td>
76
+ <a title="ajv" href="https://www.npmjs.com/package/ajv">Ajv</a>,
75
77
  <a title="@prantlf/jsonlint"
76
78
  href="https://www.npmjs.com/package/@prantlf/jsonlint">@prantlf/JSON
77
79
  Lint</a>,
@@ -100,15 +102,19 @@ source) :
100
102
  <tr>
101
103
  <td>package.json</td>
102
104
  <td>
105
+ <a title="depcheck"
106
+ href="https://www.npmjs.com/package/depcheck">Depcheck</a>
103
107
  <a title="npm-check-updates"
104
108
  href="https://www.npmjs.com/package/npm-check-updates"
105
109
  >npm-check-updates</a>,
106
110
  <a title="npm-package-json-lint"
107
111
  href="https://www.npmjs.com/package/npm-package-json-lint"
108
112
  >npm-package-json-lint</a>,
113
+ <a title="publint"
114
+ href="https://www.npmjs.com/package/publint">publint</a>,
109
115
  <a title="sort-package-json"
110
- href="https://www.npmjs.com/package/sort-package-json"
111
- >Sort Package.json</a>
116
+ href="https://www.npmjs.com/package/sort-package-json">Sort
117
+ Package.json</a>
112
118
  </td>
113
119
  </tr>
114
120
  <tr>
@@ -127,6 +133,15 @@ source) :
127
133
  href="https://www.npmjs.com/package/stylelint">Stylelint</a>
128
134
  </td>
129
135
  </tr>
136
+ <tr>
137
+ <td>SVG</td>
138
+ <td>
139
+ <a title="prettier"
140
+ href="https://www.npmjs.com/package/prettier">Prettier</a>,
141
+ <a title="svglint"
142
+ href="https://www.npmjs.com/package/svglint">SVGLint</a>
143
+ </td>
144
+ </tr>
130
145
  <tr>
131
146
  <td>WebExtension</td>
132
147
  <td>
@@ -215,6 +230,8 @@ export default {
215
230
 
216
231
  ## Intégration
217
232
 
233
+ ### npm
234
+
218
235
  Après avoir installé Metalint et les linters dans votre projet npm, vous pouvez
219
236
  ajouter le script suivant dans votre `package.json` :
220
237
 
@@ -228,14 +245,30 @@ ajouter le script suivant dans votre `package.json` :
228
245
 
229
246
  Metalint est maintenant utilisable avec la commande : `npm run lint`
230
247
 
231
- [img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=white
232
- [img-build]: https://img.shields.io/github/actions/workflow/status/regseb/metalint/ci.yml?branch=main&logo=github&logoColor=white
248
+ ### GitHub Actions
233
249
 
234
- <!-- Attendre que le logo de Stryker soit accepté.
235
- https://github.com/simple-icons/simple-icons/pull/7388 -->
250
+ Pour lancer Metalint dans vos GitHub Actions, vous pouvez utiliser le formateur
251
+ `github` pour rapporter les problèmes dans les pull requests.
252
+
253
+ ```YAML
254
+ jobs:
255
+ lint:
256
+ runs-on: ubuntu-latest
257
+ steps:
258
+ - uses: actions/setup-node@v4
259
+ - uses: actions/checkout@v4
260
+ with:
261
+ persist-credentials: false
262
+ - name: Install dependencies
263
+ run: npm ci
264
+ - name: Lint files
265
+ run: npm run lint -- --formatter github
266
+ ```
236
267
 
237
- [img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain
238
- [img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=white
268
+ [img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=whitesmoke
269
+ [img-build]: https://img.shields.io/github/actions/workflow/status/regseb/metalint/ci.yml?branch=main&logo=github&logoColor=whitesmoke
270
+ [img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain&logo=stryker&logoColor=whitesmoke
271
+ [img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=whitesmoke
239
272
  [link-npm]: https://www.npmjs.com/package/metalint
240
273
  [link-build]: https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
241
274
  [link-coverage]: https://dashboard.stryker-mutator.io/reports/github.com/regseb/metalint/main
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metalint",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Un linter pour les gouverner tous.",
5
5
  "keywords": [
6
6
  "checker",
@@ -21,6 +21,21 @@
21
21
  "./src/",
22
22
  "./types/"
23
23
  ],
24
+ "exports": {
25
+ ".": {
26
+ "types": "./types/index.d.ts",
27
+ "default": "./src/core/index.js"
28
+ },
29
+ "./api/formatter": {
30
+ "types": "./types/formatter/formatter.d.ts",
31
+ "default": "./src/core/formatter/formatter.js"
32
+ },
33
+ "./api/wrapper": {
34
+ "types": "./types/wrapper/wrapper.d.ts",
35
+ "default": "./src/core/wrapper/wrapper.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
24
39
  "main": "./src/core/index.js",
25
40
  "types": "./types/index.d.ts",
26
41
  "bin": "./src/bin/index.js",
@@ -32,10 +47,9 @@
32
47
  "lint:types": "tsc --project .tsconfig_lint.json",
33
48
  "test": "npm run test:unit",
34
49
  "test:unit": "mocha --config test/unit/mocharc.json",
35
- "test:coverage": "stryker run .stryker.config.js",
50
+ "test:coverage": "stryker run",
36
51
  "jsdocs": "typedoc --tsconfig .tsconfig_jsdocs.json",
37
52
  "prepare": "tsc --project .tsconfig_types.json",
38
- "release": "standard-version",
39
53
  "clean": "node .script/clean.js"
40
54
  },
41
55
  "dependencies": {
@@ -45,52 +59,54 @@
45
59
  "devDependencies": {
46
60
  "@coffeelint/cli": "5.2.11",
47
61
  "@prantlf/jsonlint": "14.0.3",
48
- "@prettier/plugin-xml": "3.1.1",
49
- "@stryker-mutator/core": "7.1.1",
50
- "@stryker-mutator/mocha-runner": "7.1.1",
51
- "@types/eslint": "8.44.0",
52
- "@types/htmlhint": "1.1.2",
53
- "@types/mocha": "10.0.1",
54
- "@types/mock-fs": "4.13.1",
55
- "@types/prettier": "2.7.3",
56
- "@types/sinon": "10.0.15",
57
- "@types/yargs": "17.0.24",
58
- "addons-linter": "6.10.0",
62
+ "@prettier/plugin-xml": "3.2.2",
63
+ "@stryker-mutator/core": "8.0.0",
64
+ "@stryker-mutator/mocha-runner": "8.0.0",
65
+ "@types/eslint": "8.56.1",
66
+ "@types/htmlhint": "1.1.5",
67
+ "@types/jshint": "2.12.4",
68
+ "@types/mocha": "10.0.6",
69
+ "@types/sinon": "17.0.2",
70
+ "@types/yargs": "17.0.32",
71
+ "addons-linter": "6.19.0",
72
+ "ajv": "8.12.0",
59
73
  "csslint": "1.0.5",
74
+ "depcheck": "1.4.7",
60
75
  "doiuse": "6.0.2",
61
- "eslint": "8.45.0",
62
- "eslint-plugin-array-func": "3.1.8",
76
+ "eslint": "8.56.0",
77
+ "eslint-plugin-array-func": "4.0.0",
63
78
  "eslint-plugin-eslint-comments": "3.2.0",
64
- "eslint-plugin-import": "2.27.5",
65
- "eslint-plugin-jsdoc": "46.4.4",
66
- "eslint-plugin-mocha": "10.1.0",
67
- "eslint-plugin-n": "16.0.1",
79
+ "eslint-plugin-import": "2.29.1",
80
+ "eslint-plugin-jsdoc": "48.0.2",
81
+ "eslint-plugin-mocha": "10.2.0",
82
+ "eslint-plugin-n": "16.6.1",
68
83
  "eslint-plugin-no-unsanitized": "4.0.2",
69
84
  "eslint-plugin-promise": "6.1.1",
70
- "eslint-plugin-regexp": "1.15.0",
71
- "eslint-plugin-unicorn": "48.0.0",
85
+ "eslint-plugin-regexp": "2.1.2",
86
+ "eslint-plugin-unicorn": "50.0.1",
72
87
  "htmlhint": "1.1.4",
73
88
  "htmllint": "0.8.0",
74
89
  "jshint": "2.13.6",
75
90
  "jsonlint-mod": "1.7.6",
76
- "markdownlint": "0.29.0",
77
- "markuplint": "3.12.0",
91
+ "jszip": "3.10.1",
92
+ "markdownlint": "0.32.1",
93
+ "markuplint": "3.15.0",
78
94
  "mocha": "10.2.0",
79
- "mock-fs": "5.2.0",
80
- "npm-check-updates": "16.10.16",
81
- "npm-package-json-lint": "7.0.0",
82
- "prettier": "3.0.0",
95
+ "npm-check-updates": "16.14.12",
96
+ "npm-package-json-lint": "7.1.0",
97
+ "prettier": "3.1.1",
98
+ "publint": "0.2.7",
83
99
  "purgecss": "5.0.0",
84
- "sinon": "15.2.0",
85
- "sort-package-json": "2.5.1",
100
+ "sinon": "17.0.1",
101
+ "sort-package-json": "2.6.0",
86
102
  "standard": "17.1.0",
87
- "standard-version": "9.5.0",
88
- "stylelint": "15.10.2",
89
- "typedoc": "0.24.8",
90
- "typescript": "5.1.6",
103
+ "stylelint": "16.1.0",
104
+ "svglint": "2.6.0",
105
+ "typedoc": "0.25.6",
106
+ "typescript": "5.3.3",
91
107
  "yaml-lint": "1.7.0"
92
108
  },
93
109
  "engines": {
94
- "node": ">=18.12.0"
110
+ "node": ">=20.6.0"
95
111
  }
96
112
  }
package/src/bin/argv.js CHANGED
@@ -90,7 +90,7 @@ export const parse = async function (argv = process.argv.slice(2)) {
90
90
  ),
91
91
  config: args.config,
92
92
  fix: args.fix,
93
- // Ne pas utiliser yargs.coerce() pour convertir les données car cette
93
+ // Ne pas utiliser yargs.coerce() pour convertir les données, car cette
94
94
  // méthode est incompatible avec yargs.choices().
95
95
  // https://github.com/yargs/yargs/issues/1379
96
96
  formatter:
package/src/bin/index.js CHANGED
@@ -1,86 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // Désactiver cette règle car elle ne supporte pas les valeurs de la propriété
4
- // "files" (du package.json) commençant par "./".
5
- // https://github.com/eslint-community/eslint-plugin-n/issues/99
6
- // eslint-disable-next-line n/no-unpublished-bin
7
3
  import fs from "node:fs/promises";
8
- import path from "node:path";
9
4
  import process from "node:process";
10
- import { fileURLToPath, pathToFileURL } from "node:url";
11
- import flatten from "../core/configuration/flatten.js";
12
- import normalize from "../core/configuration/normalize.js";
13
- import metalint from "../core/index.js";
5
+ import { fileURLToPath } from "node:url";
6
+ import Metalint from "../core/index.js";
14
7
  import Severities from "../core/severities.js";
15
- import { exists } from "../core/utils/file.js";
16
- import Glob from "../core/utils/glob.js";
17
8
  import { parse } from "./argv.js";
18
9
 
19
- /**
20
- * @typedef {import("../core/formatter/formatter.js")} Formatter
21
- * @typedef {import("../type/index.d.ts").FlattenedConfigChecker} FlattenedConfigChecker
22
- * @typedef {import("../type/index.d.ts").FlattenedConfigReporter} FlattenedConfigReporter
23
- * @typedef {import("../type/index.d.ts").Severity} Severity
24
- */
25
-
26
- if (undefined === import.meta.resolve) {
27
- /**
28
- * Résous un chemin relatif à partir du module.
29
- *
30
- * @param {string} specifier Le chemin relatif vers un fichier ou un
31
- * répertoire.
32
- * @returns {string} L'URL absolue vers le fichier ou le répertoire.
33
- * @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
34
- */
35
- import.meta.resolve = (specifier) => {
36
- return new URL(specifier, import.meta.url).href;
37
- };
38
- }
39
-
40
- /**
41
- * Vérifie (en appelant des linters) une liste de fichiers.
42
- *
43
- * @param {string[]} files La liste des fichiers.
44
- * @param {FlattenedConfigChecker[]} checkers La liste des vérifications
45
- * faites sur les fichiers.
46
- * @param {string} root L'adresse du répertoire où se
47
- * trouve le répertoire
48
- * <code>.metalint/</code>.
49
- * @param {FlattenedConfigReporter[]} reporters La liste des rapporteurs
50
- * utilisés pour afficher les
51
- * résultats.
52
- * @returns {Promise<Severity|undefined>} La sévérité la plus élévée des
53
- * résultats.
54
- */
55
- const check = async function (files, checkers, root, reporters) {
56
- let severity;
57
-
58
- const formatters = reporters.map((reporter) => {
59
- // eslint-disable-next-line new-cap
60
- return new reporter.formatter(reporter.level, reporter.options);
61
- });
62
- const results = await metalint(files, checkers, root);
63
- for (const [file, notices] of Object.entries(results)) {
64
- // Déterminer la sévérité la plus élévée des résultats.
65
- if (undefined !== notices) {
66
- for (const notice of notices) {
67
- if (undefined === severity || severity > notice.severity) {
68
- severity = notice.severity;
69
- }
70
- }
71
- }
72
-
73
- // Afficher les notifications avec chaque rapporteur.
74
- for (const formatter of formatters) {
75
- await formatter.notify(file, notices);
76
- }
77
- }
78
-
79
- // Attendre tous les rapporteurs.
80
- await Promise.all(formatters.map((f) => f.finalize()));
81
- return severity;
82
- };
83
-
84
10
  const argv = await parse();
85
11
  if (argv.help) {
86
12
  process.stdout.write(
@@ -89,37 +15,16 @@ if (argv.help) {
89
15
  process.exit(0);
90
16
  }
91
17
 
92
- let root = process.cwd();
93
- // Rechercher le fichier de configuration dans le répertoire courant, puis dans
94
- // les parents, grands-parents...
95
- while (!(await exists(path.join(root, argv.config)))) {
96
- // Si on est remonté à la racine.
97
- if (path.join(root, "..") === root) {
98
- process.stderr.write("metalint: no such config file.\n");
99
- process.exit(10);
100
- }
101
- root = path.join(root, "..");
102
- }
103
-
104
18
  try {
105
- // eslint-disable-next-line no-unsanitized/method
106
- const { default: config } = await import(
107
- pathToFileURL(path.join(root, argv.config))
108
- );
109
- const { patterns, reporters, checkers } = flatten(
110
- await normalize(config, {
111
- dir: path.dirname(path.join(root, argv.config)),
112
- }),
113
- argv,
114
- );
115
-
116
- const glob = new Glob(patterns, { root });
117
- const files = [];
118
- for (const base of argv._) {
119
- files.push(...(await glob.walk(base)));
120
- }
19
+ const metalint = await Metalint.fromFileSystem({
20
+ config: argv.config,
21
+ fix: argv.fix,
22
+ formatter: argv.formatter,
23
+ level: argv.level,
24
+ });
25
+ const results = await metalint.lintFiles(argv._);
26
+ const severity = await metalint.report(results);
121
27
 
122
- const severity = await check(files, checkers, root, reporters);
123
28
  let code;
124
29
  switch (severity) {
125
30
  case Severities.FATAL:
@@ -8,7 +8,6 @@ import Levels from "../levels.js";
8
8
  import { merge } from "../utils/object.js";
9
9
 
10
10
  /**
11
- * @typedef {NodeJS.WritableStream} WritableStream
12
11
  * @typedef {import("../formatter/formatter.js").default} TypeofFormatter
13
12
  * @typedef {import("../../type/index.d.ts").FlattenedConfig} FlattenedConfig
14
13
  * @typedef {import("../../type/index.d.ts").FlattenedConfigChecker} FlattenedConfigChecker
@@ -256,16 +255,18 @@ export const flattenChecker = function (hierarchy, { fix, level }) {
256
255
  /**
257
256
  * Fusionne la configuration.
258
257
  *
259
- * @param {NormalizedConfig} hierarchy L'objet JSON normalisé contenant la
260
- * configuration.
261
- * @param {Object} argv Certaines options de la ligne de
262
- * commande.
263
- * @param {boolean|undefined} argv.fix L'option <code>--fix</code> de la
264
- * ligne de commande.
265
- * @param {TypeofFormatter} argv.formatter L'option <code>--formatter</code>
266
- * de la ligne de commande.
267
- * @param {Level} argv.level L'options <code>--level</code> de
268
- * la ligne de commande.
258
+ * @param {NormalizedConfig} hierarchy L'objet JSON normalisé
259
+ * contenant la configuration.
260
+ * @param {Object} argv Certaines options de la
261
+ * ligne de commande.
262
+ * @param {boolean|undefined} argv.fix L'option <code>--fix</code>
263
+ * de la ligne de commande.
264
+ * @param {TypeofFormatter|undefined} argv.formatter L'option
265
+ * <code>--formatter</code> de
266
+ * la ligne de commande.
267
+ * @param {Level|undefined} argv.level L'options
268
+ * <code>--level</code> de la
269
+ * ligne de commande.
269
270
  * @returns {FlattenedConfig} L'objet JSON fusionné.
270
271
  */
271
272
  export const flatten = function (hierarchy, argv) {
@@ -273,7 +274,6 @@ export const flatten = function (hierarchy, argv) {
273
274
  const level = flattenLevel(argv.level ?? Levels.INFO, {
274
275
  level: hierarchy.level,
275
276
  });
276
- // TODO Vérifier que checkers n'est pas vide.
277
277
  return {
278
278
  patterns: hierarchy.patterns,
279
279
  reporters: flattenReporters(hierarchy.reporters, {
@@ -11,7 +11,6 @@ import Levels from "../levels.js";
11
11
  import Wrapper, { WRAPPERS } from "../wrapper/wrapper.js";
12
12
 
13
13
  /**
14
- * @typedef {NodeJS.WritableStream} WritableStream
15
14
  * @typedef {import("../../type/index.d.ts").Level} Level
16
15
  * @typedef {import("../../type/index.d.ts").NormalizedConfig} NormalizedConfig
17
16
  * @typedef {import("../../type/index.d.ts").NormalizedConfigChecker} NormalizedConfigChecker
@@ -481,8 +480,8 @@ export const normalizeCheckers = async function (partials, { dir }) {
481
480
 
482
481
  /**
483
482
  * Normalise la configuration. La structure de l'objet JSON contenant la
484
- * configuration est souple pour rendre le fichier moins verbeuse. Cette
485
- * fonction renseigne les valeurs par défaut pour les propriétes non-présentes.
483
+ * configuration est souple pour rendre le fichier moins verbeux. Cette fonction
484
+ * renseigne les valeurs par défaut pour les propriétés non-présentes.
486
485
  *
487
486
  * @param {*} partial L'objet JSON contenant la configuration.
488
487
  * @param {Object} context Le context de la propriété.
@@ -9,7 +9,7 @@ import Severities from "../severities.js";
9
9
  import Formatter from "./formatter.js";
10
10
 
11
11
  /**
12
- * @typedef {NodeJS.WritableStream} WritableStream
12
+ * @typedef {import("node:stream").Writable} Writable
13
13
  * @typedef {import("../../type/index.js").Level} Level
14
14
  * @typedef {import("../../type/index.js").Notice} Notice
15
15
  */
@@ -46,7 +46,7 @@ export default class CheckstyleFormatter extends Formatter {
46
46
  /**
47
47
  * Le flux où écrire les résultats.
48
48
  *
49
- * @type {WritableStream}
49
+ * @type {Writable}
50
50
  */
51
51
  #writer;
52
52
 
@@ -61,14 +61,13 @@ export default class CheckstyleFormatter extends Formatter {
61
61
  /**
62
62
  * Crée un formateur.
63
63
  *
64
- * @param {Level} level Le niveau de sévérité minimum
65
- * des notifications affichées.
66
- * @param {Object} options Les options du formateur.
67
- * @param {WritableStream} [options.writer] Le flux où écrire les résultats.
68
- * @param {number} [options.indent] La taille des indentations (en
69
- * espace) ou <code>-1</code> (par
70
- * défaut) pour ne pas mettre de
71
- * retour à la ligne.
64
+ * @param {Level} level Le niveau de sévérité minimum des
65
+ * notifications affichées.
66
+ * @param {Object} options Les options du formateur.
67
+ * @param {Writable} [options.writer] Le flux où écrire les résultats.
68
+ * @param {number} [options.indent] La taille des indentations (en espace)
69
+ * ou <code>-1</code> (par défaut) pour
70
+ * ne pas mettre de retour à la ligne.
72
71
  */
73
72
  constructor(level, options) {
74
73
  super(level);
@@ -11,7 +11,7 @@ import Severities from "../severities.js";
11
11
  import Formatter from "./formatter.js";
12
12
 
13
13
  /**
14
- * @typedef {NodeJS.WritableStream} WritableStream
14
+ * @typedef {import("node:stream").Writable} Writable
15
15
  * @typedef {import("../../type/index.js").Level} Level
16
16
  * @typedef {import("../../type/index.js").Location} Location
17
17
  * @typedef {import("../../type/index.js").Notice} Notice
@@ -21,9 +21,9 @@ import Formatter from "./formatter.js";
21
21
  /**
22
22
  * Écrit un message avec un style / couleur.
23
23
  *
24
- * @param {WritableStream} writer Le flux où afficher le message.
25
- * @param {string} message Le message qui sera affiché.
26
- * @param {string} [style] Le code du style.
24
+ * @param {Writable} writer Le flux où afficher le message.
25
+ * @param {string} message Le message qui sera affiché.
26
+ * @param {string} [style] Le code du style.
27
27
  */
28
28
  const print = function (writer, message, style) {
29
29
  let line;
@@ -56,11 +56,11 @@ const print = function (writer, message, style) {
56
56
  /**
57
57
  * Écrit une ligne du code source.
58
58
  *
59
- * @param {number} line Le numéro de la ligne.
60
- * @param {string[]} content Toutes les lignes du fichiers.
61
- * @param {boolean} active La marque indiquant si la problème est dans
62
- * cette ligne.
63
- * @param {WritableStream} writer Le flux où afficher la ligne.
59
+ * @param {number} line Le numéro de la ligne.
60
+ * @param {string[]} content Toutes les lignes du fichier.
61
+ * @param {boolean} active La marque indiquant si le problème est dans cette
62
+ * ligne.
63
+ * @param {Writable} writer Le flux où afficher la ligne.
64
64
  */
65
65
  const printCodeSourceLine = function (line, content, active, writer) {
66
66
  // Vérifier que le numéro de la ligne demandée existe dans le fichier.
@@ -76,10 +76,10 @@ const printCodeSourceLine = function (line, content, active, writer) {
76
76
  /**
77
77
  * Écrit le code source proche des lieux où le problème a été trouvé.
78
78
  *
79
- * @param {Location[]} locations Les positions, dans le code source, du
80
- * problème.
81
- * @param {string[]} content Toutes les lignes du fichiers.
82
- * @param {WritableStream} writer Le flux où afficher les lignes incriminées.
79
+ * @param {Location[]} locations Les positions, dans le code source, du
80
+ * problème.
81
+ * @param {string[]} content Toutes les lignes du fichier.
82
+ * @param {Writable} writer Le flux où afficher les lignes incriminées.
83
83
  */
84
84
  const printCodeSource = function (locations, content, writer) {
85
85
  const characters = [];
@@ -112,14 +112,14 @@ const printCodeSource = function (locations, content, writer) {
112
112
  printCodeSourceLine(line - 1, content, false, writer);
113
113
  printCodeSourceLine(line, content, true, writer);
114
114
  if (0 !== columns.length) {
115
- let dashs = "-".repeat(6 + columns.at(-1));
115
+ let dashes = "-".repeat(6 + columns.at(-1));
116
116
  for (const column of columns) {
117
- dashs =
118
- dashs.slice(0, 6 + column) +
117
+ dashes =
118
+ dashes.slice(0, 6 + column) +
119
119
  "^" +
120
- dashs.slice(6 + column + 1);
120
+ dashes.slice(6 + column + 1);
121
121
  }
122
- print(writer, dashs + "\n");
122
+ print(writer, dashes + "\n");
123
123
  }
124
124
  printCodeSourceLine(line + 1, content, false, writer);
125
125
  printCodeSourceLine(line + 2, content, false, writer);
@@ -133,7 +133,7 @@ export default class ConsoleFormatter extends Formatter {
133
133
  /**
134
134
  * Le flux où écrire les résultats.
135
135
  *
136
- * @type {WritableStream}
136
+ * @type {Writable}
137
137
  */
138
138
  #writer;
139
139
 
@@ -145,7 +145,7 @@ export default class ConsoleFormatter extends Formatter {
145
145
  #showZeroNotice;
146
146
 
147
147
  /**
148
- * Le marque indiquant s'il faut afficher les fichiers non-analysés.
148
+ * La marque indiquant s'il faut afficher les fichiers non-analysés.
149
149
  *
150
150
  * @type {boolean}
151
151
  */
@@ -154,20 +154,17 @@ export default class ConsoleFormatter extends Formatter {
154
154
  /**
155
155
  * Crée un formateur.
156
156
  *
157
- * @param {Level} level Le niveau de sévérité
158
- * minimum des
159
- * notifications affichées.
160
- * @param {Object} options Les options du
161
- * formateur.
162
- * @param {WritableStream} [options.writer] Le flux écrire les
163
- * résultats.
164
- * @param {boolean} [options.showZeroNotice] La marque indiquant s'il
165
- * faut afficher les
166
- * fichiers sans
167
- * notification.
168
- * @param {boolean} [options.showNoChecked] Le marque indiquant s'il
169
- * faut afficher les
170
- * fichiers non-analysés.
157
+ * @param {Level} level Le niveau de sévérité minimum
158
+ * des notifications affichées.
159
+ * @param {Object} options Les options du formateur.
160
+ * @param {Writable} [options.writer] Le flux où écrire les
161
+ * résultats.
162
+ * @param {boolean} [options.showZeroNotice] La marque indiquant s'il faut
163
+ * afficher les fichiers sans
164
+ * notification.
165
+ * @param {boolean} [options.showNoChecked] Le marque indiquant s'il faut
166
+ * afficher les fichiers
167
+ * non-analysés.
171
168
  */
172
169
  constructor(level, options) {
173
170
  super(level);
@@ -8,7 +8,7 @@ import process from "node:process";
8
8
  import Formatter from "./formatter.js";
9
9
 
10
10
  /**
11
- * @typedef {NodeJS.WritableStream} WritableStream
11
+ * @typedef {import("node:stream").Writable} Writable
12
12
  * @typedef {import("../../type/index.js").Level} Level
13
13
  * @typedef {import("../../type/index.js").Notice} Notice
14
14
  */
@@ -33,23 +33,23 @@ export default class CSVFormatter extends Formatter {
33
33
  /**
34
34
  * Le flux où écrire les résultats.
35
35
  *
36
- * @type {WritableStream}
36
+ * @type {Writable}
37
37
  */
38
38
  #writer;
39
39
 
40
40
  /**
41
41
  * Crée un formateur.
42
42
  *
43
- * @param {Level} level Le niveau de sévérité minimum
44
- * des notifications affichées.
45
- * @param {Object} options Les options du formateur.
46
- * @param {WritableStream} [options.writer] Le flux où écrire les résultats.
43
+ * @param {Level} level Le niveau de sévérité minimum des
44
+ * notifications affichées.
45
+ * @param {Object} options Les options du formateur.
46
+ * @param {Writable} [options.writer] Le flux où écrire les résultats.
47
47
  */
48
48
  constructor(level, options) {
49
49
  super(level);
50
50
  this.#writer = options.writer ?? process.stdout;
51
51
 
52
- // Ecrire la ligne des titres.
52
+ // Écrire la ligne des titres.
53
53
  this.#writer.write("file,line,column,message,linter,rule\r\n");
54
54
  }
55
55