metalint 0.12.0 → 0.14.1
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.md +19 -11
- package/package.json +48 -33
- package/src/bin/argv.js +2 -1
- package/src/bin/index.js +7 -2
- package/src/core/configuration/flatten.js +0 -1
- package/src/core/configuration/normalize.js +2 -3
- package/src/core/formatter/checkstyle.js +10 -10
- package/src/core/formatter/console.js +27 -29
- package/src/core/formatter/csv.js +8 -7
- package/src/core/formatter/github.js +7 -6
- package/src/core/formatter/json.js +10 -9
- package/src/core/formatter/unix.js +7 -6
- package/src/core/index.js +4 -4
- package/src/core/utils/array.js +1 -1
- package/src/core/utils/glob.js +2 -1
- package/src/core/wrapper/doiuse.js +14 -9
- package/src/core/wrapper/eslint.js +27 -8
- package/src/core/wrapper/npm-check-updates.js +87 -0
- package/src/core/wrapper/npm-package-json-lint.js +1 -4
- package/src/core/wrapper/prettier.js +33 -41
- package/src/core/wrapper/purgecss.js +1 -1
- package/src/core/wrapper/sort-package-json.js +95 -0
- package/src/core/wrapper/stylelint.js +5 -6
- package/src/core/wrapper/yaml-lint.js +1 -1
- package/types/configuration/flatten.d.ts +0 -1
- 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/severities.d.ts +4 -4
- package/types/wrapper/doiuse.d.ts +1 -1
- package/types/wrapper/npm-check-updates.d.ts +36 -0
- package/types/wrapper/prettier.d.ts +1 -1
- package/types/wrapper/purgecss.d.ts +1 -1
- package/types/wrapper/sort-package-json.d.ts +36 -0
- package/types/wrapper/stylelint.d.ts +2 -2
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ source) :
|
|
|
35
35
|
<td>
|
|
36
36
|
<a title="csslint"
|
|
37
37
|
href="https://www.npmjs.com/package/csslint">CSSLint</a>,
|
|
38
|
-
<a title="doiuse" href="https://www.npmjs.com/package/doiuse">
|
|
38
|
+
<a title="doiuse" href="https://www.npmjs.com/package/doiuse">DoIUse</a>,
|
|
39
39
|
<a title="prettier"
|
|
40
40
|
href="https://www.npmjs.com/package/prettier">Prettier</a>,
|
|
41
41
|
<a title="purgecss"
|
|
@@ -100,9 +100,21 @@ source) :
|
|
|
100
100
|
<tr>
|
|
101
101
|
<td>package.json</td>
|
|
102
102
|
<td>
|
|
103
|
+
<!-- markdownlint-disable no-bare-urls -->
|
|
104
|
+
<!-- https://github.com/DavidAnson/markdownlint/issues/961 -->
|
|
105
|
+
<a title="npm-check-updates"
|
|
106
|
+
href="https://www.npmjs.com/package/npm-check-updates"
|
|
107
|
+
>npm-check-updates</a>,
|
|
108
|
+
<!-- markdownlint-enable no-bare-urls -->
|
|
109
|
+
<!-- markdownlint-disable no-bare-urls -->
|
|
110
|
+
<!-- https://github.com/DavidAnson/markdownlint/issues/961 -->
|
|
103
111
|
<a title="npm-package-json-lint"
|
|
104
112
|
href="https://www.npmjs.com/package/npm-package-json-lint"
|
|
105
|
-
>npm-package-json-lint</a
|
|
113
|
+
>npm-package-json-lint</a>,
|
|
114
|
+
<!-- markdownlint-enable no-bare-urls -->
|
|
115
|
+
<a title="sort-package-json"
|
|
116
|
+
href="https://www.npmjs.com/package/sort-package-json">Sort
|
|
117
|
+
Package.json</a>
|
|
106
118
|
</td>
|
|
107
119
|
</tr>
|
|
108
120
|
<tr>
|
|
@@ -145,7 +157,7 @@ source) :
|
|
|
145
157
|
Vous pouvez installer Metalint en utilisant [npm][link-npm] :
|
|
146
158
|
|
|
147
159
|
```Shell
|
|
148
|
-
npm install --save-dev metalint
|
|
160
|
+
npm install --save-dev --save-exact metalint
|
|
149
161
|
```
|
|
150
162
|
|
|
151
163
|
## Configuration
|
|
@@ -222,14 +234,10 @@ ajouter le script suivant dans votre `package.json` :
|
|
|
222
234
|
|
|
223
235
|
Metalint est maintenant utilisable avec la commande : `npm run lint`
|
|
224
236
|
|
|
225
|
-
[img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=
|
|
226
|
-
[img-build]: https://img.shields.io/github/actions/workflow/status/regseb/metalint/ci.yml?branch=main&logo=github&logoColor=
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
https://github.com/simple-icons/simple-icons/pull/7388 -->
|
|
230
|
-
|
|
231
|
-
[img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain
|
|
232
|
-
[img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=white
|
|
237
|
+
[img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=whitesmoke
|
|
238
|
+
[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
|
|
240
|
+
[img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=whitesmoke
|
|
233
241
|
[link-npm]: https://www.npmjs.com/package/metalint
|
|
234
242
|
[link-build]: https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
|
|
235
243
|
[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.14.1",
|
|
4
4
|
"description": "Un linter pour les gouverner tous.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checker",
|
|
@@ -18,12 +18,27 @@
|
|
|
18
18
|
"author": "Sébastien Règne <regseb@gmail.com> (https://github.com/regseb)",
|
|
19
19
|
"funding": "https://www.paypal.me/sebastienregne",
|
|
20
20
|
"files": [
|
|
21
|
-
"src/",
|
|
22
|
-
"types/"
|
|
21
|
+
"./src/",
|
|
22
|
+
"./types/"
|
|
23
23
|
],
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./types/index.d.ts",
|
|
27
|
+
"default": "./src/code/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
|
+
},
|
|
39
|
+
"main": "./src/core/index.js",
|
|
40
|
+
"types": "./types/index.d.ts",
|
|
41
|
+
"bin": "./src/bin/index.js",
|
|
27
42
|
"repository": "regseb/metalint",
|
|
28
43
|
"type": "module",
|
|
29
44
|
"scripts": {
|
|
@@ -35,60 +50,60 @@
|
|
|
35
50
|
"test:coverage": "stryker run .stryker.config.js",
|
|
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": {
|
|
42
|
-
"chalk": "5.
|
|
56
|
+
"chalk": "5.3.0",
|
|
43
57
|
"yargs": "17.7.2"
|
|
44
58
|
},
|
|
45
59
|
"devDependencies": {
|
|
46
60
|
"@coffeelint/cli": "5.2.11",
|
|
47
61
|
"@prantlf/jsonlint": "14.0.3",
|
|
48
|
-
"@prettier/plugin-xml": "
|
|
49
|
-
"@stryker-mutator/core": "
|
|
50
|
-
"@stryker-mutator/mocha-runner": "
|
|
51
|
-
"@types/eslint": "8.
|
|
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",
|
|
52
66
|
"@types/htmlhint": "1.1.2",
|
|
67
|
+
"@types/jshint": "2.12.2",
|
|
53
68
|
"@types/mocha": "10.0.1",
|
|
54
69
|
"@types/mock-fs": "4.13.1",
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/sinon": "10.0.14",
|
|
70
|
+
"@types/sinon": "10.0.16",
|
|
57
71
|
"@types/yargs": "17.0.24",
|
|
58
|
-
"addons-linter": "6.
|
|
72
|
+
"addons-linter": "6.13.0",
|
|
59
73
|
"csslint": "1.0.5",
|
|
60
|
-
"doiuse": "
|
|
61
|
-
"eslint": "8.
|
|
74
|
+
"doiuse": "6.0.2",
|
|
75
|
+
"eslint": "8.49.0",
|
|
62
76
|
"eslint-plugin-array-func": "3.1.8",
|
|
63
77
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
64
|
-
"eslint-plugin-import": "2.
|
|
65
|
-
"eslint-plugin-jsdoc": "
|
|
78
|
+
"eslint-plugin-import": "2.28.1",
|
|
79
|
+
"eslint-plugin-jsdoc": "46.5.1",
|
|
66
80
|
"eslint-plugin-mocha": "10.1.0",
|
|
67
|
-
"eslint-plugin-n": "
|
|
81
|
+
"eslint-plugin-n": "16.0.2",
|
|
68
82
|
"eslint-plugin-no-unsanitized": "4.0.2",
|
|
69
83
|
"eslint-plugin-promise": "6.1.1",
|
|
70
|
-
"eslint-plugin-regexp": "1.
|
|
71
|
-
"eslint-plugin-unicorn": "
|
|
84
|
+
"eslint-plugin-regexp": "1.15.0",
|
|
85
|
+
"eslint-plugin-unicorn": "48.0.1",
|
|
72
86
|
"htmlhint": "1.1.4",
|
|
73
87
|
"htmllint": "0.8.0",
|
|
74
88
|
"jshint": "2.13.6",
|
|
75
89
|
"jsonlint-mod": "1.7.6",
|
|
76
|
-
"markdownlint": "0.
|
|
77
|
-
"markuplint": "3.
|
|
90
|
+
"markdownlint": "0.31.0",
|
|
91
|
+
"markuplint": "3.12.1",
|
|
78
92
|
"mocha": "10.2.0",
|
|
79
93
|
"mock-fs": "5.2.0",
|
|
80
|
-
"npm-
|
|
81
|
-
"
|
|
94
|
+
"npm-check-updates": "16.13.3",
|
|
95
|
+
"npm-package-json-lint": "7.0.0",
|
|
96
|
+
"prettier": "3.0.3",
|
|
82
97
|
"purgecss": "5.0.0",
|
|
83
|
-
"sinon": "15.0
|
|
84
|
-
"
|
|
85
|
-
"standard
|
|
86
|
-
"stylelint": "15.
|
|
87
|
-
"typedoc": "0.
|
|
88
|
-
"typescript": "5.
|
|
98
|
+
"sinon": "15.2.0",
|
|
99
|
+
"sort-package-json": "2.5.1",
|
|
100
|
+
"standard": "17.1.0",
|
|
101
|
+
"stylelint": "15.10.3",
|
|
102
|
+
"typedoc": "0.25.1",
|
|
103
|
+
"typescript": "5.2.2",
|
|
89
104
|
"yaml-lint": "1.7.0"
|
|
90
105
|
},
|
|
91
106
|
"engines": {
|
|
92
|
-
"node": ">=
|
|
107
|
+
"node": ">=20.0.0"
|
|
93
108
|
}
|
|
94
109
|
}
|
package/src/bin/argv.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
|
+
import process from "node:process";
|
|
8
9
|
import yargs from "yargs";
|
|
9
10
|
import {
|
|
10
11
|
normalizeFormatter,
|
|
@@ -89,7 +90,7 @@ export const parse = async function (argv = process.argv.slice(2)) {
|
|
|
89
90
|
),
|
|
90
91
|
config: args.config,
|
|
91
92
|
fix: args.fix,
|
|
92
|
-
// 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
|
|
93
94
|
// méthode est incompatible avec yargs.choices().
|
|
94
95
|
// https://github.com/yargs/yargs/issues/1379
|
|
95
96
|
formatter:
|
package/src/bin/index.js
CHANGED
|
@@ -1,7 +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
|
|
3
7
|
import fs from "node:fs/promises";
|
|
4
8
|
import path from "node:path";
|
|
9
|
+
import process from "node:process";
|
|
5
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
11
|
import flatten from "../core/configuration/flatten.js";
|
|
7
12
|
import normalize from "../core/configuration/normalize.js";
|
|
@@ -44,7 +49,7 @@ if (undefined === import.meta.resolve) {
|
|
|
44
49
|
* @param {FlattenedConfigReporter[]} reporters La liste des rapporteurs
|
|
45
50
|
* utilisés pour afficher les
|
|
46
51
|
* résultats.
|
|
47
|
-
* @returns {Promise<Severity|undefined>} La sévérité la plus
|
|
52
|
+
* @returns {Promise<Severity|undefined>} La sévérité la plus élevée des
|
|
48
53
|
* résultats.
|
|
49
54
|
*/
|
|
50
55
|
const check = async function (files, checkers, root, reporters) {
|
|
@@ -56,7 +61,7 @@ const check = async function (files, checkers, root, reporters) {
|
|
|
56
61
|
});
|
|
57
62
|
const results = await metalint(files, checkers, root);
|
|
58
63
|
for (const [file, notices] of Object.entries(results)) {
|
|
59
|
-
// Déterminer la sévérité la plus
|
|
64
|
+
// Déterminer la sévérité la plus élevée des résultats.
|
|
60
65
|
if (undefined !== notices) {
|
|
61
66
|
for (const notice of notices) {
|
|
62
67
|
if (undefined === severity || severity > notice.severity) {
|
|
@@ -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
|
|
@@ -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é.
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* @author Sébastien Règne
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import process from "node:process";
|
|
7
8
|
import Severities from "../severities.js";
|
|
8
9
|
import Formatter from "./formatter.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* @typedef {
|
|
12
|
+
* @typedef {import("node:stream").Writable} Writable
|
|
12
13
|
* @typedef {import("../../type/index.js").Level} Level
|
|
13
14
|
* @typedef {import("../../type/index.js").Notice} Notice
|
|
14
15
|
*/
|
|
@@ -45,7 +46,7 @@ export default class CheckstyleFormatter extends Formatter {
|
|
|
45
46
|
/**
|
|
46
47
|
* Le flux où écrire les résultats.
|
|
47
48
|
*
|
|
48
|
-
* @type {
|
|
49
|
+
* @type {Writable}
|
|
49
50
|
*/
|
|
50
51
|
#writer;
|
|
51
52
|
|
|
@@ -60,14 +61,13 @@ export default class CheckstyleFormatter extends Formatter {
|
|
|
60
61
|
/**
|
|
61
62
|
* Crée un formateur.
|
|
62
63
|
*
|
|
63
|
-
* @param {Level}
|
|
64
|
-
*
|
|
65
|
-
* @param {Object}
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {number}
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* 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.
|
|
71
71
|
*/
|
|
72
72
|
constructor(level, options) {
|
|
73
73
|
super(level);
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
|
+
import process from "node:process";
|
|
8
9
|
import chalk from "chalk";
|
|
9
10
|
import Severities from "../severities.js";
|
|
10
11
|
import Formatter from "./formatter.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @typedef {
|
|
14
|
+
* @typedef {import("node:stream").Writable} Writable
|
|
14
15
|
* @typedef {import("../../type/index.js").Level} Level
|
|
15
16
|
* @typedef {import("../../type/index.js").Location} Location
|
|
16
17
|
* @typedef {import("../../type/index.js").Notice} Notice
|
|
@@ -20,9 +21,9 @@ import Formatter from "./formatter.js";
|
|
|
20
21
|
/**
|
|
21
22
|
* Écrit un message avec un style / couleur.
|
|
22
23
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {string}
|
|
25
|
-
* @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.
|
|
26
27
|
*/
|
|
27
28
|
const print = function (writer, message, style) {
|
|
28
29
|
let line;
|
|
@@ -55,11 +56,11 @@ const print = function (writer, message, style) {
|
|
|
55
56
|
/**
|
|
56
57
|
* Écrit une ligne du code source.
|
|
57
58
|
*
|
|
58
|
-
* @param {number}
|
|
59
|
-
* @param {string[]}
|
|
60
|
-
* @param {boolean}
|
|
61
|
-
*
|
|
62
|
-
* @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.
|
|
63
64
|
*/
|
|
64
65
|
const printCodeSourceLine = function (line, content, active, writer) {
|
|
65
66
|
// Vérifier que le numéro de la ligne demandée existe dans le fichier.
|
|
@@ -75,10 +76,10 @@ const printCodeSourceLine = function (line, content, active, writer) {
|
|
|
75
76
|
/**
|
|
76
77
|
* Écrit le code source proche des lieux où le problème a été trouvé.
|
|
77
78
|
*
|
|
78
|
-
* @param {Location[]}
|
|
79
|
-
*
|
|
80
|
-
* @param {string[]}
|
|
81
|
-
* @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.
|
|
82
83
|
*/
|
|
83
84
|
const printCodeSource = function (locations, content, writer) {
|
|
84
85
|
const characters = [];
|
|
@@ -132,7 +133,7 @@ export default class ConsoleFormatter extends Formatter {
|
|
|
132
133
|
/**
|
|
133
134
|
* Le flux où écrire les résultats.
|
|
134
135
|
*
|
|
135
|
-
* @type {
|
|
136
|
+
* @type {Writable}
|
|
136
137
|
*/
|
|
137
138
|
#writer;
|
|
138
139
|
|
|
@@ -144,7 +145,7 @@ export default class ConsoleFormatter extends Formatter {
|
|
|
144
145
|
#showZeroNotice;
|
|
145
146
|
|
|
146
147
|
/**
|
|
147
|
-
*
|
|
148
|
+
* La marque indiquant s'il faut afficher les fichiers non-analysés.
|
|
148
149
|
*
|
|
149
150
|
* @type {boolean}
|
|
150
151
|
*/
|
|
@@ -153,20 +154,17 @@ export default class ConsoleFormatter extends Formatter {
|
|
|
153
154
|
/**
|
|
154
155
|
* Crée un formateur.
|
|
155
156
|
*
|
|
156
|
-
* @param {Level}
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* @param {
|
|
160
|
-
*
|
|
161
|
-
* @param {
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* @param {boolean} [options.showNoChecked] Le marque indiquant s'il
|
|
168
|
-
* faut afficher les
|
|
169
|
-
* 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.
|
|
170
168
|
*/
|
|
171
169
|
constructor(level, options) {
|
|
172
170
|
super(level);
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* @author Sébastien Règne
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import process from "node:process";
|
|
7
8
|
import Formatter from "./formatter.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* @typedef {
|
|
11
|
+
* @typedef {import("node:stream").Writable} Writable
|
|
11
12
|
* @typedef {import("../../type/index.js").Level} Level
|
|
12
13
|
* @typedef {import("../../type/index.js").Notice} Notice
|
|
13
14
|
*/
|
|
@@ -32,23 +33,23 @@ export default class CSVFormatter extends Formatter {
|
|
|
32
33
|
/**
|
|
33
34
|
* Le flux où écrire les résultats.
|
|
34
35
|
*
|
|
35
|
-
* @type {
|
|
36
|
+
* @type {Writable}
|
|
36
37
|
*/
|
|
37
38
|
#writer;
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Crée un formateur.
|
|
41
42
|
*
|
|
42
|
-
* @param {Level}
|
|
43
|
-
*
|
|
44
|
-
* @param {Object}
|
|
45
|
-
* @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.
|
|
46
47
|
*/
|
|
47
48
|
constructor(level, options) {
|
|
48
49
|
super(level);
|
|
49
50
|
this.#writer = options.writer ?? process.stdout;
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
+
// Écrire la ligne des titres.
|
|
52
53
|
this.#writer.write("file,line,column,message,linter,rule\r\n");
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* @author Sébastien Règne
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import process from "node:process";
|
|
7
8
|
import Severities from "../severities.js";
|
|
8
9
|
import Formatter from "./formatter.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* @typedef {
|
|
12
|
+
* @typedef {import("node:stream").Writable} Writable
|
|
12
13
|
* @typedef {import("../../type/index.js").Level} Level
|
|
13
14
|
* @typedef {import("../../type/index.js").Notice} Notice
|
|
14
15
|
*/
|
|
@@ -22,17 +23,17 @@ export default class GitHubFormatter extends Formatter {
|
|
|
22
23
|
/**
|
|
23
24
|
* Le flux où écrire les résultats.
|
|
24
25
|
*
|
|
25
|
-
* @type {
|
|
26
|
+
* @type {Writable}
|
|
26
27
|
*/
|
|
27
28
|
#writer;
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Crée un formateur.
|
|
31
32
|
*
|
|
32
|
-
* @param {Level}
|
|
33
|
-
*
|
|
34
|
-
* @param {Object}
|
|
35
|
-
* @param {
|
|
33
|
+
* @param {Level} level Le niveau de sévérité minimum des
|
|
34
|
+
* notifications affichées.
|
|
35
|
+
* @param {Object} options Les options du formateur.
|
|
36
|
+
* @param {Writable} [options.writer] Le flux où écrire les résultats.
|
|
36
37
|
*/
|
|
37
38
|
constructor(level, options) {
|
|
38
39
|
super(level);
|
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
* @author Sébastien Règne
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import process from "node:process";
|
|
7
8
|
import Formatter from "./formatter.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* @typedef {
|
|
11
|
+
* @typedef {import("node:stream").Writable} Writable
|
|
11
12
|
* @typedef {import("../../type/index.js").Level} Level
|
|
12
13
|
* @typedef {import("../../type/index.js").Notice} Notice
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Le formateur qui écrit les résultats
|
|
17
|
+
* Le formateur qui écrit les résultats bruts (au format JSON). La seule
|
|
17
18
|
* altération des résultats est le remplacement des <code>undefined</code> par
|
|
18
19
|
* des <code>null</code>.
|
|
19
20
|
*
|
|
@@ -23,7 +24,7 @@ export default class JSONFormatter extends Formatter {
|
|
|
23
24
|
/**
|
|
24
25
|
* Le flux où écrire les résultats.
|
|
25
26
|
*
|
|
26
|
-
* @type {
|
|
27
|
+
* @type {Writable}
|
|
27
28
|
*/
|
|
28
29
|
#writer;
|
|
29
30
|
|
|
@@ -45,12 +46,12 @@ export default class JSONFormatter extends Formatter {
|
|
|
45
46
|
/**
|
|
46
47
|
* Crée un formateur.
|
|
47
48
|
*
|
|
48
|
-
* @param {Level}
|
|
49
|
-
*
|
|
50
|
-
* @param {Object}
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {number}
|
|
53
|
-
*
|
|
49
|
+
* @param {Level} level Le niveau de sévérité minimum des
|
|
50
|
+
* notifications affichées.
|
|
51
|
+
* @param {Object} options Les options du formateur.
|
|
52
|
+
* @param {Writable} [options.writer] Le flux où écrire les résultats.
|
|
53
|
+
* @param {number} [options.indent] La taille des indentations (en
|
|
54
|
+
* espace).
|
|
54
55
|
*/
|
|
55
56
|
constructor(level, options) {
|
|
56
57
|
super(level);
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* @author Sébastien Règne
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import process from "node:process";
|
|
7
8
|
import Formatter from "./formatter.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* @typedef {
|
|
11
|
+
* @typedef {import("node:stream").Writable} Writable
|
|
11
12
|
* @typedef {import("../../type/index.js").Level} Level
|
|
12
13
|
* @typedef {import("../../type/index.js").Notice} Notice
|
|
13
14
|
*/
|
|
@@ -20,7 +21,7 @@ export default class UnixFormatter extends Formatter {
|
|
|
20
21
|
/**
|
|
21
22
|
* Le flux où écrire les résultats.
|
|
22
23
|
*
|
|
23
|
-
* @type {
|
|
24
|
+
* @type {Writable}
|
|
24
25
|
*/
|
|
25
26
|
#writer;
|
|
26
27
|
|
|
@@ -34,10 +35,10 @@ export default class UnixFormatter extends Formatter {
|
|
|
34
35
|
/**
|
|
35
36
|
* Crée un formateur.
|
|
36
37
|
*
|
|
37
|
-
* @param {Level}
|
|
38
|
-
*
|
|
39
|
-
* @param {Object}
|
|
40
|
-
* @param {
|
|
38
|
+
* @param {Level} level Le niveau de sévérité minimum des
|
|
39
|
+
* notifications affichées.
|
|
40
|
+
* @param {Object} options Les options du formateur.
|
|
41
|
+
* @param {Writable} [options.writer] Le flux où écrire les résultats.
|
|
41
42
|
*/
|
|
42
43
|
constructor(level, options) {
|
|
43
44
|
super(level);
|
package/src/core/index.js
CHANGED
|
@@ -64,8 +64,8 @@ const Results = class {
|
|
|
64
64
|
this.#data[file] = [];
|
|
65
65
|
}
|
|
66
66
|
for (const notice of notices) {
|
|
67
|
-
// Vérifier aussi le fichier de la notification car il peut être
|
|
68
|
-
// différent du fichier d'origine (qui est peut
|
|
67
|
+
// Vérifier aussi le fichier de la notification, car il peut être
|
|
68
|
+
// différent du fichier d'origine (qui est peut-être un répertoire
|
|
69
69
|
// ou une archive).
|
|
70
70
|
if (undefined === this.#data[notice.file]) {
|
|
71
71
|
this.#data[notice.file] = [];
|
|
@@ -110,12 +110,12 @@ export default async function metalint(files, checkers, root) {
|
|
|
110
110
|
for (const checker of checkers) {
|
|
111
111
|
const glob = new Glob(checker.patterns, { root });
|
|
112
112
|
if (glob.test(file)) {
|
|
113
|
-
|
|
113
|
+
let key = checker.patterns.join();
|
|
114
114
|
const values = [checker.linters];
|
|
115
115
|
for (const override of checker.overrides) {
|
|
116
116
|
const subglob = new Glob(override.patterns, { root });
|
|
117
117
|
if (subglob.test(file)) {
|
|
118
|
-
key.
|
|
118
|
+
key += "|" + override.patterns.join();
|
|
119
119
|
values.push(override.linters);
|
|
120
120
|
}
|
|
121
121
|
}
|
package/src/core/utils/array.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @template T
|
|
11
11
|
* @param {T|T[]} value L'élément.
|
|
12
|
-
* @returns {T[]} Un avec seulement l'élément d'
|
|
12
|
+
* @returns {T[]} Un tableau avec seulement l'élément d'entrée ou l'élément.
|
|
13
13
|
*/
|
|
14
14
|
export const wrap = function (value) {
|
|
15
15
|
return Array.isArray(value) ? value : [value];
|
package/src/core/utils/glob.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import path from "node:path/posix";
|
|
9
|
+
import process from "node:process";
|
|
9
10
|
import { wrap } from "./array.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -179,7 +180,7 @@ export default class Glob {
|
|
|
179
180
|
/**
|
|
180
181
|
* Teste si un fichier / répertoire respecte les patrons.
|
|
181
182
|
*
|
|
182
|
-
* @param {string} file Le chemin du fichier / répertoire
|
|
183
|
+
* @param {string} file Le chemin du fichier / répertoire qui sera vérifié.
|
|
183
184
|
* @returns {string} <code>"DEEP_NEGATIVE"</code> pour un répertoire ne
|
|
184
185
|
* respectant pas un patron qui exclue aussi ses
|
|
185
186
|
* fichiers ; <code>"NEGATIVE"</code> si le fichier /
|