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.
- package/LICENSE +1 -1
- package/README.md +42 -9
- package/package.json +51 -35
- package/src/bin/argv.js +1 -1
- package/src/bin/index.js +10 -105
- package/src/core/configuration/flatten.js +12 -12
- package/src/core/configuration/normalize.js +2 -3
- package/src/core/formatter/checkstyle.js +9 -10
- package/src/core/formatter/console.js +31 -34
- package/src/core/formatter/csv.js +7 -7
- package/src/core/formatter/formatter.js +5 -18
- package/src/core/formatter/github.js +6 -6
- package/src/core/formatter/json.js +9 -9
- package/src/core/formatter/unix.js +6 -6
- package/src/core/index.js +128 -118
- package/src/core/results.js +86 -0
- package/src/core/utils/array.js +1 -1
- package/src/core/utils/glob.js +1 -1
- package/src/core/wrapper/addons-linter.js +3 -6
- package/src/core/wrapper/ajv.js +122 -0
- package/src/core/wrapper/csslint.js +1 -6
- package/src/core/wrapper/depcheck.js +148 -0
- package/src/core/wrapper/doiuse.js +3 -4
- package/src/core/wrapper/eslint.js +25 -7
- package/src/core/wrapper/htmlhint.js +1 -6
- package/src/core/wrapper/htmllint.js +1 -6
- package/src/core/wrapper/jshint.js +1 -6
- package/src/core/wrapper/npm-package-json-lint.js +1 -4
- package/src/core/wrapper/publint.js +136 -0
- package/src/core/wrapper/standard.js +7 -1
- package/src/core/wrapper/stylelint.js +4 -11
- package/src/core/wrapper/svglint.js +92 -0
- package/src/core/wrapper/wrapper.js +5 -18
- package/src/core/wrapper/yaml-lint.js +1 -1
- package/types/configuration/flatten.d.ts +2 -3
- package/types/configuration/normalize.d.ts +0 -1
- package/types/formatter/checkstyle.d.ts +9 -10
- package/types/formatter/console.d.ts +13 -16
- package/types/formatter/csv.d.ts +6 -6
- package/types/formatter/github.d.ts +7 -7
- package/types/formatter/json.d.ts +10 -10
- package/types/formatter/unix.d.ts +7 -7
- package/types/index.d.ts +20 -14
- package/types/results.d.ts +7 -0
- package/types/wrapper/ajv.d.ts +36 -0
- package/types/wrapper/depcheck.d.ts +36 -0
- package/types/wrapper/publint.d.ts +33 -0
- package/types/wrapper/stylelint.d.ts +2 -2
- package/types/wrapper/svglint.d.ts +36 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Metalint
|
|
2
2
|
|
|
3
|
-
<!-- Utiliser du HTML
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
235
|
-
|
|
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-
|
|
238
|
-
[img-
|
|
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.
|
|
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
|
|
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.
|
|
49
|
-
"@stryker-mutator/core": "
|
|
50
|
-
"@stryker-mutator/mocha-runner": "
|
|
51
|
-
"@types/eslint": "8.
|
|
52
|
-
"@types/htmlhint": "1.1.
|
|
53
|
-
"@types/
|
|
54
|
-
"@types/
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/
|
|
57
|
-
"
|
|
58
|
-
"
|
|
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.
|
|
62
|
-
"eslint-plugin-array-func": "
|
|
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.
|
|
65
|
-
"eslint-plugin-jsdoc": "
|
|
66
|
-
"eslint-plugin-mocha": "10.
|
|
67
|
-
"eslint-plugin-n": "16.
|
|
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.
|
|
71
|
-
"eslint-plugin-unicorn": "
|
|
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
|
-
"
|
|
77
|
-
"
|
|
91
|
+
"jszip": "3.10.1",
|
|
92
|
+
"markdownlint": "0.32.1",
|
|
93
|
+
"markuplint": "3.15.0",
|
|
78
94
|
"mocha": "10.2.0",
|
|
79
|
-
"
|
|
80
|
-
"npm-
|
|
81
|
-
"
|
|
82
|
-
"
|
|
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": "
|
|
85
|
-
"sort-package-json": "2.
|
|
100
|
+
"sinon": "17.0.1",
|
|
101
|
+
"sort-package-json": "2.6.0",
|
|
86
102
|
"standard": "17.1.0",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"typedoc": "0.
|
|
90
|
-
"typescript": "5.
|
|
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": ">=
|
|
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
|
|
11
|
-
import
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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}
|
|
260
|
-
*
|
|
261
|
-
* @param {Object}
|
|
262
|
-
*
|
|
263
|
-
* @param {boolean|undefined}
|
|
264
|
-
*
|
|
265
|
-
* @param {TypeofFormatter}
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
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
|
|
485
|
-
*
|
|
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 {
|
|
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 {
|
|
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}
|
|
65
|
-
*
|
|
66
|
-
* @param {Object}
|
|
67
|
-
* @param {
|
|
68
|
-
* @param {number}
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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 {
|
|
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 {
|
|
25
|
-
* @param {string}
|
|
26
|
-
* @param {string}
|
|
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}
|
|
60
|
-
* @param {string[]}
|
|
61
|
-
* @param {boolean}
|
|
62
|
-
*
|
|
63
|
-
* @param {
|
|
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[]}
|
|
80
|
-
*
|
|
81
|
-
* @param {string[]}
|
|
82
|
-
* @param {
|
|
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
|
|
115
|
+
let dashes = "-".repeat(6 + columns.at(-1));
|
|
116
116
|
for (const column of columns) {
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
dashes =
|
|
118
|
+
dashes.slice(0, 6 + column) +
|
|
119
119
|
"^" +
|
|
120
|
-
|
|
120
|
+
dashes.slice(6 + column + 1);
|
|
121
121
|
}
|
|
122
|
-
print(writer,
|
|
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 {
|
|
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
|
-
*
|
|
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}
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* @param {
|
|
161
|
-
*
|
|
162
|
-
* @param {
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
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 {
|
|
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 {
|
|
36
|
+
* @type {Writable}
|
|
37
37
|
*/
|
|
38
38
|
#writer;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Crée un formateur.
|
|
42
42
|
*
|
|
43
|
-
* @param {Level}
|
|
44
|
-
*
|
|
45
|
-
* @param {Object}
|
|
46
|
-
* @param {
|
|
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
|
-
//
|
|
52
|
+
// Écrire la ligne des titres.
|
|
53
53
|
this.#writer.write("file,line,column,message,linter,rule\r\n");
|
|
54
54
|
}
|
|
55
55
|
|