metalint 0.14.1 → 0.16.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 (90) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -8
  3. package/package.json +44 -36
  4. package/src/bin/argv.js +6 -4
  5. package/src/bin/index.js +10 -105
  6. package/src/core/configuration/flatten.js +56 -54
  7. package/src/core/configuration/normalize.js +18 -16
  8. package/src/core/configuration/override.js +1 -1
  9. package/src/core/formatter/checkstyle.js +2 -2
  10. package/src/core/formatter/console.js +10 -10
  11. package/src/core/formatter/csv.js +2 -2
  12. package/src/core/formatter/formatter.js +7 -20
  13. package/src/core/formatter/github.js +2 -2
  14. package/src/core/formatter/json.js +2 -2
  15. package/src/core/formatter/unix.js +2 -2
  16. package/src/core/index.js +194 -111
  17. package/src/core/results.js +106 -0
  18. package/src/core/wrapper/addons-linter.js +19 -20
  19. package/src/core/wrapper/ajv.js +123 -0
  20. package/src/core/wrapper/coffeelint__cli.js +16 -14
  21. package/src/core/wrapper/csslint.js +17 -20
  22. package/src/core/wrapper/depcheck.js +149 -0
  23. package/src/core/wrapper/doiuse.js +19 -17
  24. package/src/core/wrapper/eslint.js +17 -17
  25. package/src/core/wrapper/htmlhint.js +16 -20
  26. package/src/core/wrapper/htmllint.js +17 -20
  27. package/src/core/wrapper/jshint.js +16 -20
  28. package/src/core/wrapper/jsonlint-mod.js +15 -13
  29. package/src/core/wrapper/markdownlint.js +15 -14
  30. package/src/core/wrapper/markuplint.js +19 -14
  31. package/src/core/wrapper/npm-check-updates.js +15 -14
  32. package/src/core/wrapper/npm-package-json-lint.js +15 -14
  33. package/src/core/wrapper/prantlf__jsonlint.js +15 -14
  34. package/src/core/wrapper/prettier.js +15 -14
  35. package/src/core/wrapper/publint.js +137 -0
  36. package/src/core/wrapper/purgecss.js +15 -14
  37. package/src/core/wrapper/sort-package-json.js +15 -14
  38. package/src/core/wrapper/standard.js +22 -14
  39. package/src/core/wrapper/stylelint.js +16 -20
  40. package/src/core/wrapper/svglint.js +94 -0
  41. package/src/core/wrapper/wrapper.js +7 -20
  42. package/src/core/wrapper/yaml-lint.js +15 -14
  43. package/src/types/config.d.ts +6 -0
  44. package/src/types/configuration/flattened.d.ts +38 -0
  45. package/src/types/configuration/normalized.d.ts +44 -0
  46. package/src/types/configuration/partial.d.ts +54 -0
  47. package/src/types/level.d.ts +9 -0
  48. package/src/types/location.d.ts +12 -0
  49. package/src/types/notice.d.ts +26 -0
  50. package/src/types/severity.d.ts +9 -0
  51. package/src/types/typeofformatter.d.ts +13 -0
  52. package/src/types/typeofwrapper.d.ts +20 -0
  53. package/types/configuration/flatten.d.ts +26 -26
  54. package/types/configuration/normalize.d.ts +12 -12
  55. package/types/configuration/override.d.ts +1 -1
  56. package/types/formatter/checkstyle.d.ts +2 -2
  57. package/types/formatter/console.d.ts +4 -4
  58. package/types/formatter/csv.d.ts +2 -2
  59. package/types/formatter/formatter.d.ts +2 -2
  60. package/types/formatter/github.d.ts +4 -4
  61. package/types/formatter/json.d.ts +4 -4
  62. package/types/formatter/unix.d.ts +4 -4
  63. package/types/index.d.ts +82 -16
  64. package/types/results.d.ts +27 -0
  65. package/types/wrapper/addons-linter.d.ts +17 -16
  66. package/types/wrapper/ajv.d.ts +37 -0
  67. package/types/wrapper/coffeelint__cli.d.ts +17 -16
  68. package/types/wrapper/csslint.d.ts +17 -16
  69. package/types/wrapper/depcheck.d.ts +37 -0
  70. package/types/wrapper/doiuse.d.ts +19 -16
  71. package/types/wrapper/eslint.d.ts +17 -16
  72. package/types/wrapper/htmlhint.d.ts +17 -16
  73. package/types/wrapper/htmllint.d.ts +17 -16
  74. package/types/wrapper/jshint.d.ts +17 -16
  75. package/types/wrapper/jsonlint-mod.d.ts +17 -16
  76. package/types/wrapper/markdownlint.d.ts +17 -16
  77. package/types/wrapper/markuplint.d.ts +17 -16
  78. package/types/wrapper/npm-check-updates.d.ts +17 -16
  79. package/types/wrapper/npm-package-json-lint.d.ts +17 -16
  80. package/types/wrapper/prantlf__jsonlint.d.ts +17 -16
  81. package/types/wrapper/prettier.d.ts +17 -16
  82. package/types/wrapper/publint.d.ts +34 -0
  83. package/types/wrapper/purgecss.d.ts +17 -16
  84. package/types/wrapper/sort-package-json.d.ts +17 -16
  85. package/types/wrapper/standard.d.ts +17 -16
  86. package/types/wrapper/stylelint.d.ts +17 -16
  87. package/types/wrapper/svglint.d.ts +37 -0
  88. package/types/wrapper/wrapper.d.ts +2 -2
  89. package/types/wrapper/yaml-lint.d.ts +17 -16
  90. package/src/type/index.d.ts +0 -149
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,18 +102,16 @@ source) :
100
102
  <tr>
101
103
  <td>package.json</td>
102
104
  <td>
103
- <!-- markdownlint-disable no-bare-urls -->
104
- <!-- https://github.com/DavidAnson/markdownlint/issues/961 -->
105
+ <a title="depcheck"
106
+ href="https://www.npmjs.com/package/depcheck">Depcheck</a>,
105
107
  <a title="npm-check-updates"
106
108
  href="https://www.npmjs.com/package/npm-check-updates"
107
109
  >npm-check-updates</a>,
108
- <!-- markdownlint-enable no-bare-urls -->
109
- <!-- markdownlint-disable no-bare-urls -->
110
- <!-- https://github.com/DavidAnson/markdownlint/issues/961 -->
111
110
  <a title="npm-package-json-lint"
112
111
  href="https://www.npmjs.com/package/npm-package-json-lint"
113
112
  >npm-package-json-lint</a>,
114
- <!-- markdownlint-enable no-bare-urls -->
113
+ <a title="publint"
114
+ href="https://www.npmjs.com/package/publint">publint</a>,
115
115
  <a title="sort-package-json"
116
116
  href="https://www.npmjs.com/package/sort-package-json">Sort
117
117
  Package.json</a>
@@ -133,6 +133,15 @@ source) :
133
133
  href="https://www.npmjs.com/package/stylelint">Stylelint</a>
134
134
  </td>
135
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>
136
145
  <tr>
137
146
  <td>WebExtension</td>
138
147
  <td>
@@ -221,6 +230,8 @@ export default {
221
230
 
222
231
  ## Intégration
223
232
 
233
+ ### npm
234
+
224
235
  Après avoir installé Metalint et les linters dans votre projet npm, vous pouvez
225
236
  ajouter le script suivant dans votre `package.json` :
226
237
 
@@ -234,9 +245,29 @@ ajouter le script suivant dans votre `package.json` :
234
245
 
235
246
  Metalint est maintenant utilisable avec la commande : `npm run lint`
236
247
 
248
+ ### GitHub Actions
249
+
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
+ ```
267
+
237
268
  [img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=whitesmoke
238
269
  [img-build]: https://img.shields.io/github/actions/workflow/status/regseb/metalint/ci.yml?branch=main&logo=github&logoColor=whitesmoke
239
- [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
270
+ [img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain
240
271
  [img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=whitesmoke
241
272
  [link-npm]: https://www.npmjs.com/package/metalint
242
273
  [link-build]: https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metalint",
3
- "version": "0.14.1",
3
+ "version": "0.16.0",
4
4
  "description": "Un linter pour les gouverner tous.",
5
5
  "keywords": [
6
6
  "checker",
@@ -24,7 +24,7 @@
24
24
  "exports": {
25
25
  ".": {
26
26
  "types": "./types/index.d.ts",
27
- "default": "./src/code/index.js"
27
+ "default": "./src/core/index.js"
28
28
  },
29
29
  "./api/formatter": {
30
30
  "types": "./types/formatter/formatter.d.ts",
@@ -34,6 +34,9 @@
34
34
  "types": "./types/wrapper/wrapper.d.ts",
35
35
  "default": "./src/core/wrapper/wrapper.js"
36
36
  },
37
+ "./types/config": {
38
+ "types": "./src/types/config.d.ts"
39
+ },
37
40
  "./package.json": "./package.json"
38
41
  },
39
42
  "main": "./src/core/index.js",
@@ -47,7 +50,7 @@
47
50
  "lint:types": "tsc --project .tsconfig_lint.json",
48
51
  "test": "npm run test:unit",
49
52
  "test:unit": "mocha --config test/unit/mocharc.json",
50
- "test:coverage": "stryker run .stryker.config.js",
53
+ "test:coverage": "stryker run",
51
54
  "jsdocs": "typedoc --tsconfig .tsconfig_jsdocs.json",
52
55
  "prepare": "tsc --project .tsconfig_types.json",
53
56
  "clean": "node .script/clean.js"
@@ -59,51 +62,56 @@
59
62
  "devDependencies": {
60
63
  "@coffeelint/cli": "5.2.11",
61
64
  "@prantlf/jsonlint": "14.0.3",
62
- "@prettier/plugin-xml": "3.2.0",
63
- "@stryker-mutator/core": "7.1.1",
64
- "@stryker-mutator/mocha-runner": "7.1.1",
65
- "@types/eslint": "8.44.2",
66
- "@types/htmlhint": "1.1.2",
67
- "@types/jshint": "2.12.2",
68
- "@types/mocha": "10.0.1",
69
- "@types/mock-fs": "4.13.1",
70
- "@types/sinon": "10.0.16",
71
- "@types/yargs": "17.0.24",
72
- "addons-linter": "6.13.0",
65
+ "@prettier/plugin-xml": "3.4.1",
66
+ "@stryker-mutator/core": "8.2.6",
67
+ "@stryker-mutator/mocha-runner": "8.2.6",
68
+ "@types/eslint": "8.56.7",
69
+ "@types/htmlhint": "1.1.5",
70
+ "@types/jshint": "2.12.4",
71
+ "@types/mocha": "10.0.6",
72
+ "@types/sinon": "17.0.3",
73
+ "@types/yargs": "17.0.32",
74
+ "@typescript-eslint/eslint-plugin": "7.5.0",
75
+ "@typescript-eslint/parser": "7.5.0",
76
+ "addons-linter": "6.25.0",
77
+ "ajv": "8.12.0",
73
78
  "csslint": "1.0.5",
79
+ "depcheck": "1.4.7",
74
80
  "doiuse": "6.0.2",
75
- "eslint": "8.49.0",
76
- "eslint-plugin-array-func": "3.1.8",
81
+ "eslint": "8.57.0",
82
+ "eslint-plugin-array-func": "4.0.0",
77
83
  "eslint-plugin-eslint-comments": "3.2.0",
78
- "eslint-plugin-import": "2.28.1",
79
- "eslint-plugin-jsdoc": "46.5.1",
80
- "eslint-plugin-mocha": "10.1.0",
81
- "eslint-plugin-n": "16.0.2",
84
+ "eslint-plugin-import": "2.29.1",
85
+ "eslint-plugin-jsdoc": "48.2.2",
86
+ "eslint-plugin-mocha": "10.4.1",
87
+ "eslint-plugin-n": "16.6.2",
82
88
  "eslint-plugin-no-unsanitized": "4.0.2",
83
89
  "eslint-plugin-promise": "6.1.1",
84
- "eslint-plugin-regexp": "1.15.0",
85
- "eslint-plugin-unicorn": "48.0.1",
90
+ "eslint-plugin-regexp": "2.4.0",
91
+ "eslint-plugin-unicorn": "51.0.1",
86
92
  "htmlhint": "1.1.4",
87
93
  "htmllint": "0.8.0",
88
94
  "jshint": "2.13.6",
89
95
  "jsonlint-mod": "1.7.6",
90
- "markdownlint": "0.31.0",
91
- "markuplint": "3.12.1",
92
- "mocha": "10.2.0",
93
- "mock-fs": "5.2.0",
94
- "npm-check-updates": "16.13.3",
95
- "npm-package-json-lint": "7.0.0",
96
- "prettier": "3.0.3",
97
- "purgecss": "5.0.0",
98
- "sinon": "15.2.0",
99
- "sort-package-json": "2.5.1",
96
+ "jszip": "3.10.1",
97
+ "markdownlint": "0.34.0",
98
+ "markuplint": "4.5.0",
99
+ "mocha": "10.4.0",
100
+ "npm-check-updates": "16.14.18",
101
+ "npm-package-json-lint": "7.1.0",
102
+ "prettier": "3.2.5",
103
+ "publint": "0.2.7",
104
+ "purgecss": "6.0.0",
105
+ "sinon": "17.0.1",
106
+ "sort-package-json": "2.10.0",
100
107
  "standard": "17.1.0",
101
- "stylelint": "15.10.3",
102
- "typedoc": "0.25.1",
103
- "typescript": "5.2.2",
108
+ "stylelint": "16.3.1",
109
+ "svglint": "2.7.1",
110
+ "typedoc": "0.25.12",
111
+ "typescript": "5.4.3",
104
112
  "yaml-lint": "1.7.0"
105
113
  },
106
114
  "engines": {
107
- "node": ">=20.0.0"
115
+ "node": ">=20.6.0"
108
116
  }
109
117
  }
package/src/bin/argv.js CHANGED
@@ -15,8 +15,8 @@ import { FORMATTERS } from "../core/formatter/formatter.js";
15
15
  import Levels from "../core/levels.js";
16
16
 
17
17
  /**
18
- * @typedef {import("../core/formatter/formatter.js").default} TypeofFormatter
19
- * @typedef {import("../type/index.d.ts").Level} Level
18
+ * @typedef {import("../types/level.d.ts").Level} Level
19
+ * @typedef {import("../types/typeofformatter.d.ts").default} TypeofFormatter
20
20
  */
21
21
 
22
22
  /**
@@ -31,11 +31,13 @@ import Levels from "../core/levels.js";
31
31
  * @property {TypeofFormatter|undefined} formatter L'option
32
32
  * <code>--formatter</code> de
33
33
  * la ligne de commande.
34
- * @property {Level} level L'option <code>--level</code>
35
- * de la ligne de commande.
34
+ * @property {Level} level L'option
35
+ * <code>--level</code> de la
36
+ * ligne de commande.
36
37
  * @property {boolean} help L'option <code>--help</code>
37
38
  * de la ligne de commande.
38
39
  */
40
+
39
41
  /**
40
42
  * Extrait, vérifie et normalise les paramètres et les options de la ligne de
41
43
  * commande.
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 élevé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 élevé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,18 +8,18 @@ import Levels from "../levels.js";
8
8
  import { merge } from "../utils/object.js";
9
9
 
10
10
  /**
11
- * @typedef {import("../formatter/formatter.js").default} TypeofFormatter
12
- * @typedef {import("../../type/index.d.ts").FlattenedConfig} FlattenedConfig
13
- * @typedef {import("../../type/index.d.ts").FlattenedConfigChecker} FlattenedConfigChecker
14
- * @typedef {import("../../type/index.d.ts").FlattenedConfigLinter} FlattenedConfigLinter
15
- * @typedef {import("../../type/index.d.ts").FlattenedConfigOverride} FlattenedConfigOverride
16
- * @typedef {import("../../type/index.d.ts").FlattenedConfigReporter} FlattenedConfigReporter
17
- * @typedef {import("../../type/index.d.ts").Level} Level
18
- * @typedef {import("../../type/index.d.ts").NormalizedConfig} NormalizedConfig
19
- * @typedef {import("../../type/index.d.ts").NormalizedConfigChecker} NormalizedConfigChecker
20
- * @typedef {import("../../type/index.d.ts").NormalizedConfigLinter} NormalizedConfigLinter
21
- * @typedef {import("../../type/index.d.ts").NormalizedConfigOverride} NormalizedConfigOverride
22
- * @typedef {import("../../type/index.d.ts").NormalizedConfigReporter} NormalizedConfigReporter
11
+ * @typedef {import("../../types/configuration/flattened.d.ts").FlattenedConfig} FlattenedConfig
12
+ * @typedef {import("../../types/configuration/flattened.d.ts").FlattenedConfigChecker} FlattenedConfigChecker
13
+ * @typedef {import("../../types/configuration/flattened.d.ts").FlattenedConfigLinter} FlattenedConfigLinter
14
+ * @typedef {import("../../types/configuration/flattened.d.ts").FlattenedConfigOverride} FlattenedConfigOverride
15
+ * @typedef {import("../../types/configuration/flattened.d.ts").FlattenedConfigReporter} FlattenedConfigReporter
16
+ * @typedef {import("../../types/configuration/normalized.d.ts").NormalizedConfig} NormalizedConfig
17
+ * @typedef {import("../../types/configuration/normalized.d.ts").NormalizedConfigChecker} NormalizedConfigChecker
18
+ * @typedef {import("../../types/configuration/normalized.d.ts").NormalizedConfigLinter} NormalizedConfigLinter
19
+ * @typedef {import("../../types/configuration/normalized.d.ts").NormalizedConfigOverride} NormalizedConfigOverride
20
+ * @typedef {import("../../types/configuration/normalized.d.ts").NormalizedConfigReporter} NormalizedConfigReporter
21
+ * @typedef {import("../../types/level.d.ts").default} Level
22
+ * @typedef {import("../../types/typeofformatter.js").default} TypeofFormatter
23
23
  */
24
24
 
25
25
  /**
@@ -42,9 +42,9 @@ export const flattenPatterns = function (hierarchies, { patterns }) {
42
42
  * @param {boolean|undefined} hierarchy La valeur d'une des propriétés
43
43
  * <code>"fix"</code>.
44
44
  * @param {Object} context Le contexte de la fusion.
45
- * @param {boolean|undefined} context.fix La valeur de la propriété
45
+ * @param {boolean} context.fix La valeur de la propriété
46
46
  * <code>"fix"</code> parente.
47
- * @returns {boolean|undefined} La valeur fusionnée.
47
+ * @returns {boolean} La valeur fusionnée.
48
48
  */
49
49
  export const flattenFix = function (hierarchy, { fix }) {
50
50
  return hierarchy ?? fix;
@@ -67,13 +67,14 @@ export const flattenLevel = function (hierarchy, { level }) {
67
67
  /**
68
68
  * Fusionne une propriété <code>"options"</code>.
69
69
  *
70
- * @param {Record<string, any>[]} hierarchies La valeur d'une des propriétés
71
- * <code>"options"</code>.
72
- * @param {Object} context Le contexte de la fusion.
73
- * @param {Record<string, any>} context.options La valeur de la propriété
74
- * <code>"options"</code>
75
- * parente.
76
- * @returns {Record<string, any>} La valeur fusionnée.
70
+ * @param {Record<string, unknown>[]} hierarchies La valeur d'une des
71
+ * propriétés
72
+ * <code>"options"</code>.
73
+ * @param {Object} context Le contexte de la fusion.
74
+ * @param {Record<string, unknown>} context.options La valeur de la propriété
75
+ * <code>"options"</code>
76
+ * parente.
77
+ * @returns {Record<string, unknown>} La valeur fusionnée.
77
78
  */
78
79
  export const flattenOptions = function (hierarchies, { options }) {
79
80
  return [options, ...hierarchies].reduce(merge);
@@ -87,8 +88,7 @@ export const flattenOptions = function (hierarchies, { options }) {
87
88
  * <code>"reporters"</code>.
88
89
  * @param {Object} context Le contexte de la fusion.
89
90
  * @param {Level} context.level La valeur de la propriété
90
- * <code>"level"</code>
91
- * parente.
91
+ * <code>"level"</code> parente.
92
92
  * @returns {FlattenedConfigReporter} La valeur fusionnée.
93
93
  */
94
94
  export const flattenReporter = function (hierarchy, { level }) {
@@ -107,7 +107,7 @@ export const flattenReporter = function (hierarchy, { level }) {
107
107
  * <code>"reporters"</code>.
108
108
  * @param {Object} context Le contexte de la
109
109
  * fusion.
110
- * @param {TypeofFormatter} context.formatter La valeur de la
110
+ * @param {TypeofFormatter|undefined} context.formatter La valeur de la
111
111
  * propriété
112
112
  * <code>"formatter"</code>
113
113
  * parente.
@@ -134,18 +134,18 @@ export const flattenReporters = function (hierarchies, { formatter, level }) {
134
134
  /**
135
135
  * Fusionne un élément d'une propriété <code>"linters"</code>.
136
136
  *
137
- * @param {NormalizedConfigLinter} hierarchy La valeur de l'élément d'une
138
- * des propriétés
139
- * <code>"linters"</code>.
140
- * @param {Object} context Le contexte de la fusion.
141
- * @param {boolean|undefined} context.fix La valeur de la propriété
142
- * <code>"fix"</code> parente.
143
- * @param {Level} context.level La valeur de la propriété
144
- * <code>"level"</code>
145
- * parente.
146
- * @param {Record<string, any>} context.options La valeur de la propriété
147
- * <code>"options"</code>
148
- * parente.
137
+ * @param {NormalizedConfigLinter} hierarchy La valeur de l'élément d'une
138
+ * des propriétés
139
+ * <code>"linters"</code>.
140
+ * @param {Object} context Le contexte de la fusion.
141
+ * @param {boolean} context.fix La valeur de la propriété
142
+ * <code>"fix"</code> parente.
143
+ * @param {Level} context.level La valeur de la propriété
144
+ * <code>"level"</code>
145
+ * parente.
146
+ * @param {Record<string, unknown>} context.options La valeur de la propriété
147
+ * <code>"options"</code>
148
+ * parente.
149
149
  * @returns {FlattenedConfigLinter} La valeur fusionnée.
150
150
  */
151
151
  export const flattenLinter = function (hierarchy, { fix, level, options }) {
@@ -164,7 +164,7 @@ export const flattenLinter = function (hierarchy, { fix, level, options }) {
164
164
  * propriétés
165
165
  * <code>"linters"</code>.
166
166
  * @param {Object} context Le contexte de la fusion.
167
- * @param {boolean|undefined} context.fix La valeur de la propriété
167
+ * @param {boolean} context.fix La valeur de la propriété
168
168
  * <code>"fix"</code> parente.
169
169
  * @param {Level} context.level La valeur de la propriété
170
170
  * <code>"level"</code> parente.
@@ -200,15 +200,14 @@ export const flattenLinters = function (hierarchies, { fix, level }) {
200
200
  /**
201
201
  * Fusionne un élément d'une propriété <code>"overrides"</code>.
202
202
  *
203
- * @param {NormalizedConfigOverride} hierarchy La valeur de l'élément
204
- * d'une des propriétés
203
+ * @param {NormalizedConfigOverride} hierarchy La valeur de l'élément d'une
204
+ * des propriétés
205
205
  * <code>"overrides"</code>.
206
206
  * @param {Object} context Le contexte de la fusion.
207
- * @param {boolean|undefined} context.fix La valeur de la propriété
207
+ * @param {boolean} context.fix La valeur de la propriété
208
208
  * <code>"fix"</code> parente.
209
209
  * @param {Level} context.level La valeur de la propriété
210
- * <code>"level"</code>
211
- * parente.
210
+ * <code>"level"</code> parente.
212
211
  * @returns {FlattenedConfigOverride} La valeur fusionnée.
213
212
  */
214
213
  export const flattenOverride = function (hierarchy, { fix, level }) {
@@ -228,7 +227,7 @@ export const flattenOverride = function (hierarchy, { fix, level }) {
228
227
  * propriété
229
228
  * <code>"checkers"</code>.
230
229
  * @param {Object} context Le contexte de la fusion.
231
- * @param {boolean|undefined} context.fix La valeur de la propriété
230
+ * @param {boolean} context.fix La valeur de la propriété
232
231
  * <code>"fix"</code> parente.
233
232
  * @param {Level} context.level La valeur de la propriété
234
233
  * <code>"level"</code> parente.
@@ -255,16 +254,20 @@ export const flattenChecker = function (hierarchy, { fix, level }) {
255
254
  /**
256
255
  * Fusionne la configuration.
257
256
  *
258
- * @param {NormalizedConfig} hierarchy L'objet JSON normalisé contenant la
259
- * configuration.
260
- * @param {Object} argv Certaines options de la ligne de
261
- * commande.
262
- * @param {boolean|undefined} argv.fix L'option <code>--fix</code> de la
263
- * ligne de commande.
264
- * @param {TypeofFormatter} argv.formatter L'option <code>--formatter</code>
265
- * de la ligne de commande.
266
- * @param {Level} argv.level L'options <code>--level</code> de
267
- * la ligne de commande.
257
+ * @param {NormalizedConfig} hierarchy L'objet JSON normalisé
258
+ * contenant la
259
+ * configuration.
260
+ * @param {Object} argv Certaines options de la
261
+ * ligne de commande.
262
+ * @param {boolean|undefined} [argv.fix] L'option
263
+ * <code>--fix</code> de la
264
+ * ligne de commande.
265
+ * @param {TypeofFormatter|undefined} [argv.formatter] L'option
266
+ * <code>--formatter</code>
267
+ * de la ligne de commande.
268
+ * @param {Level|undefined} [argv.level] L'options
269
+ * <code>--level</code> de
270
+ * la ligne de commande.
268
271
  * @returns {FlattenedConfig} L'objet JSON fusionné.
269
272
  */
270
273
  export const flatten = function (hierarchy, argv) {
@@ -272,7 +275,6 @@ export const flatten = function (hierarchy, argv) {
272
275
  const level = flattenLevel(argv.level ?? Levels.INFO, {
273
276
  level: hierarchy.level,
274
277
  });
275
- // TODO Vérifier que checkers n'est pas vide.
276
278
  return {
277
279
  patterns: hierarchy.patterns,
278
280
  reporters: flattenReporters(hierarchy.reporters, {