metalint 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -33
- package/package.json +39 -31
- package/src/bin/argv.js +38 -34
- package/src/core/configuration/flatten.js +115 -76
- package/src/core/configuration/normalize.js +100 -33
- package/src/core/configuration/override.js +1 -1
- package/src/core/configuration/partial.js +136 -0
- package/src/core/formatter/checkstyle.js +5 -5
- package/src/core/formatter/console.js +8 -8
- package/src/core/formatter/csv.js +5 -5
- package/src/core/formatter/formatter.js +10 -5
- package/src/core/formatter/github.js +5 -5
- package/src/core/formatter/json.js +5 -5
- package/src/core/formatter/unix.js +5 -5
- package/src/core/index.js +102 -29
- package/src/core/levels.js +9 -2
- package/src/core/results.js +54 -5
- package/src/core/severities.js +5 -2
- package/src/core/types.js +9 -0
- package/src/core/utils/glob.js +1 -1
- package/src/core/wrapper/addons-linter.js +23 -14
- package/src/core/wrapper/ajv.js +23 -15
- package/src/core/wrapper/coffeelint__cli.js +23 -14
- package/src/core/wrapper/csslint.js +23 -14
- package/src/core/wrapper/depcheck.js +22 -14
- package/src/core/wrapper/doiuse.js +24 -14
- package/src/core/wrapper/eslint.js +24 -20
- package/src/core/wrapper/htmlhint.js +22 -14
- package/src/core/wrapper/htmllint.js +23 -14
- package/src/core/wrapper/jshint.js +22 -14
- package/src/core/wrapper/jsonlint-mod.js +22 -13
- package/src/core/wrapper/mapbox__jsonlint-lines-primitives.js +81 -0
- package/src/core/wrapper/markdownlint.js +22 -14
- package/src/core/wrapper/markuplint.js +26 -14
- package/src/core/wrapper/npm-check-updates.js +22 -14
- package/src/core/wrapper/npm-package-json-lint.js +22 -14
- package/src/core/wrapper/prantlf__jsonlint.js +22 -14
- package/src/core/wrapper/prettier.js +22 -14
- package/src/core/wrapper/publint.js +24 -16
- package/src/core/wrapper/purgecss.js +22 -14
- package/src/core/wrapper/sort-package-json.js +22 -14
- package/src/core/wrapper/standard.js +24 -19
- package/src/core/wrapper/stylelint.js +22 -14
- package/src/core/wrapper/svglint.js +23 -14
- package/src/core/wrapper/wrapper.js +20 -10
- package/src/core/wrapper/yaml-lint.js +25 -14
- package/types/bin/argv.d.ts +34 -0
- package/types/bin/index.d.ts +2 -0
- package/types/core/configuration/flatten.d.ts +146 -0
- package/types/core/configuration/normalize.d.ts +168 -0
- package/types/{configuration → core/configuration}/override.d.ts +1 -1
- package/types/core/configuration/partial.d.ts +196 -0
- package/types/{formatter → core/formatter}/checkstyle.d.ts +2 -2
- package/types/{formatter → core/formatter}/console.d.ts +4 -4
- package/types/{formatter → core/formatter}/csv.d.ts +2 -2
- package/types/{formatter → core/formatter}/formatter.d.ts +16 -7
- package/types/{formatter → core/formatter}/github.d.ts +4 -4
- package/types/{formatter → core/formatter}/json.d.ts +4 -4
- package/types/{formatter → core/formatter}/unix.d.ts +4 -4
- package/types/core/index.d.ts +84 -0
- package/types/core/levels.d.ts +9 -0
- package/types/core/results.d.ts +105 -0
- package/types/core/severities.d.ts +8 -0
- package/types/core/types.d.ts +1 -0
- package/types/core/wrapper/addons-linter.d.ts +43 -0
- package/types/core/wrapper/ajv.d.ts +43 -0
- package/types/core/wrapper/coffeelint__cli.d.ts +43 -0
- package/types/core/wrapper/csslint.d.ts +43 -0
- package/types/core/wrapper/depcheck.d.ts +43 -0
- package/types/core/wrapper/doiuse.d.ts +45 -0
- package/types/core/wrapper/eslint.d.ts +43 -0
- package/types/core/wrapper/htmlhint.d.ts +43 -0
- package/types/core/wrapper/htmllint.d.ts +43 -0
- package/types/core/wrapper/jshint.d.ts +43 -0
- package/types/core/wrapper/jsonlint-mod.d.ts +42 -0
- package/types/core/wrapper/mapbox__jsonlint-lines-primitives.d.ts +44 -0
- package/types/core/wrapper/markdownlint.d.ts +43 -0
- package/types/core/wrapper/markuplint.d.ts +43 -0
- package/types/core/wrapper/npm-check-updates.d.ts +43 -0
- package/types/core/wrapper/npm-package-json-lint.d.ts +43 -0
- package/types/core/wrapper/prantlf__jsonlint.d.ts +44 -0
- package/types/core/wrapper/prettier.d.ts +43 -0
- package/types/core/wrapper/publint.d.ts +40 -0
- package/types/core/wrapper/purgecss.d.ts +43 -0
- package/types/core/wrapper/sort-package-json.d.ts +43 -0
- package/types/core/wrapper/standard.d.ts +43 -0
- package/types/core/wrapper/stylelint.d.ts +43 -0
- package/types/core/wrapper/svglint.d.ts +43 -0
- package/types/{wrapper → core/wrapper}/wrapper.d.ts +42 -17
- package/types/core/wrapper/yaml-lint.d.ts +43 -0
- package/src/type/index.d.ts +0 -149
- package/types/configuration/flatten.d.ts +0 -54
- package/types/configuration/normalize.d.ts +0 -49
- package/types/index.d.ts +0 -24
- package/types/levels.d.ts +0 -8
- package/types/results.d.ts +0 -7
- package/types/severities.d.ts +0 -7
- package/types/wrapper/addons-linter.d.ts +0 -36
- package/types/wrapper/ajv.d.ts +0 -36
- package/types/wrapper/coffeelint__cli.d.ts +0 -36
- package/types/wrapper/csslint.d.ts +0 -36
- package/types/wrapper/depcheck.d.ts +0 -36
- package/types/wrapper/doiuse.d.ts +0 -36
- package/types/wrapper/eslint.d.ts +0 -36
- package/types/wrapper/htmlhint.d.ts +0 -36
- package/types/wrapper/htmllint.d.ts +0 -36
- package/types/wrapper/jshint.d.ts +0 -36
- package/types/wrapper/jsonlint-mod.d.ts +0 -35
- package/types/wrapper/markdownlint.d.ts +0 -36
- package/types/wrapper/markuplint.d.ts +0 -36
- package/types/wrapper/npm-check-updates.d.ts +0 -36
- package/types/wrapper/npm-package-json-lint.d.ts +0 -36
- package/types/wrapper/prantlf__jsonlint.d.ts +0 -37
- package/types/wrapper/prettier.d.ts +0 -36
- package/types/wrapper/publint.d.ts +0 -33
- package/types/wrapper/purgecss.d.ts +0 -36
- package/types/wrapper/sort-package-json.d.ts +0 -36
- package/types/wrapper/standard.d.ts +0 -36
- package/types/wrapper/stylelint.d.ts +0 -36
- package/types/wrapper/svglint.d.ts +0 -36
- package/types/wrapper/yaml-lint.d.ts +0 -36
- /package/types/{utils → core/utils}/array.d.ts +0 -0
- /package/types/{utils → core/utils}/file.d.ts +0 -0
- /package/types/{utils → core/utils}/glob.d.ts +0 -0
- /package/types/{utils → core/utils}/object.d.ts +0 -0
package/README.md
CHANGED
|
@@ -74,6 +74,9 @@ source) :
|
|
|
74
74
|
<td>JSON</td>
|
|
75
75
|
<td>
|
|
76
76
|
<a title="ajv" href="https://www.npmjs.com/package/ajv">Ajv</a>,
|
|
77
|
+
<a title="@mapbox/jsonlint-lines-primitives"
|
|
78
|
+
href="https://www.npmjs.com/package/@mapbox/jsonlint-lines-primitives">@mapbox/JSON
|
|
79
|
+
Lint lines-primitives</a>,
|
|
77
80
|
<a title="@prantlf/jsonlint"
|
|
78
81
|
href="https://www.npmjs.com/package/@prantlf/jsonlint">@prantlf/JSON
|
|
79
82
|
Lint</a>,
|
|
@@ -103,7 +106,7 @@ source) :
|
|
|
103
106
|
<td>package.json</td>
|
|
104
107
|
<td>
|
|
105
108
|
<a title="depcheck"
|
|
106
|
-
href="https://www.npmjs.com/package/depcheck">Depcheck</a
|
|
109
|
+
href="https://www.npmjs.com/package/depcheck">Depcheck</a>,
|
|
107
110
|
<a title="npm-check-updates"
|
|
108
111
|
href="https://www.npmjs.com/package/npm-check-updates"
|
|
109
112
|
>npm-check-updates</a>,
|
|
@@ -165,7 +168,7 @@ source) :
|
|
|
165
168
|
|
|
166
169
|
Vous pouvez installer Metalint en utilisant [npm][link-npm] :
|
|
167
170
|
|
|
168
|
-
```
|
|
171
|
+
```shell
|
|
169
172
|
npm install --save-dev --save-exact metalint
|
|
170
173
|
```
|
|
171
174
|
|
|
@@ -183,48 +186,50 @@ Dans cet exemple des fichiers de configuration, Metalint analyse les fichiers
|
|
|
183
186
|
JavaScript (non-minifiés), HTML et CSS ; avec respectivement les linters ESLint,
|
|
184
187
|
HTMLHint et Stylelint.
|
|
185
188
|
|
|
186
|
-
```
|
|
189
|
+
```javascript
|
|
187
190
|
// .metalint/metalint.config.js
|
|
188
191
|
export default {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
patterns: ["**", "!/.git/**", "!/node_modules/**"],
|
|
193
|
+
checkers: [
|
|
194
|
+
{
|
|
195
|
+
patterns: ["*.js", "!*.min.js"],
|
|
196
|
+
linters: "eslint",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
patterns: "*.html",
|
|
200
|
+
linters: "htmlhint",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
patterns: "*.css",
|
|
204
|
+
linters: "stylelint",
|
|
205
|
+
},
|
|
206
|
+
],
|
|
202
207
|
};
|
|
203
208
|
```
|
|
204
209
|
|
|
205
|
-
```
|
|
210
|
+
```javascript
|
|
206
211
|
// .metalint/eslint.config.js
|
|
207
212
|
export default {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
rules: {
|
|
214
|
+
quotes: ["error", "double"],
|
|
215
|
+
semi: ["error", "always"],
|
|
216
|
+
},
|
|
212
217
|
};
|
|
213
218
|
```
|
|
214
219
|
|
|
215
|
-
```
|
|
220
|
+
```javascript
|
|
216
221
|
// .metalint/htmlhint.config.js
|
|
217
222
|
export default {
|
|
218
|
-
|
|
223
|
+
"attr-value-not-empty": false,
|
|
219
224
|
};
|
|
220
225
|
```
|
|
221
226
|
|
|
222
|
-
```
|
|
227
|
+
```javascript
|
|
223
228
|
// .metalint/stylelint.config.js
|
|
224
229
|
export default {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
rules: {
|
|
231
|
+
"color-no-invalid-hex": true,
|
|
232
|
+
},
|
|
228
233
|
};
|
|
229
234
|
```
|
|
230
235
|
|
|
@@ -235,11 +240,11 @@ export default {
|
|
|
235
240
|
Après avoir installé Metalint et les linters dans votre projet npm, vous pouvez
|
|
236
241
|
ajouter le script suivant dans votre `package.json` :
|
|
237
242
|
|
|
238
|
-
```
|
|
243
|
+
```json
|
|
239
244
|
{
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
245
|
+
"scripts": {
|
|
246
|
+
"lint": "metalint"
|
|
247
|
+
}
|
|
243
248
|
}
|
|
244
249
|
```
|
|
245
250
|
|
|
@@ -250,7 +255,7 @@ Metalint est maintenant utilisable avec la commande : `npm run lint`
|
|
|
250
255
|
Pour lancer Metalint dans vos GitHub Actions, vous pouvez utiliser le formateur
|
|
251
256
|
`github` pour rapporter les problèmes dans les pull requests.
|
|
252
257
|
|
|
253
|
-
```
|
|
258
|
+
```yaml
|
|
254
259
|
jobs:
|
|
255
260
|
lint:
|
|
256
261
|
runs-on: ubuntu-latest
|
|
@@ -267,7 +272,7 @@ jobs:
|
|
|
267
272
|
|
|
268
273
|
[img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=whitesmoke
|
|
269
274
|
[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
|
|
275
|
+
[img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain
|
|
271
276
|
[img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=whitesmoke
|
|
272
277
|
[link-npm]: https://www.npmjs.com/package/metalint
|
|
273
278
|
[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.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Un linter pour les gouverner tous.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checker",
|
|
@@ -16,28 +16,34 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "Sébastien Règne <regseb@gmail.com> (https://github.com/regseb)",
|
|
19
|
-
"funding":
|
|
19
|
+
"funding": [
|
|
20
|
+
"https://buymeacoffee.com/regseb",
|
|
21
|
+
"https://www.paypal.me/sebastienregne"
|
|
22
|
+
],
|
|
20
23
|
"files": [
|
|
21
24
|
"./src/",
|
|
22
25
|
"./types/"
|
|
23
26
|
],
|
|
24
27
|
"exports": {
|
|
25
28
|
".": {
|
|
26
|
-
"types": "./types/index.d.ts",
|
|
29
|
+
"types": "./types/core/index.d.ts",
|
|
27
30
|
"default": "./src/core/index.js"
|
|
28
31
|
},
|
|
29
32
|
"./api/formatter": {
|
|
30
|
-
"types": "./types/formatter/formatter.d.ts",
|
|
33
|
+
"types": "./types/core/formatter/formatter.d.ts",
|
|
31
34
|
"default": "./src/core/formatter/formatter.js"
|
|
32
35
|
},
|
|
33
36
|
"./api/wrapper": {
|
|
34
|
-
"types": "./types/wrapper/wrapper.d.ts",
|
|
37
|
+
"types": "./types/core/wrapper/wrapper.d.ts",
|
|
35
38
|
"default": "./src/core/wrapper/wrapper.js"
|
|
36
39
|
},
|
|
40
|
+
"./types": {
|
|
41
|
+
"types": "./types/core/types.d.ts"
|
|
42
|
+
},
|
|
37
43
|
"./package.json": "./package.json"
|
|
38
44
|
},
|
|
39
45
|
"main": "./src/core/index.js",
|
|
40
|
-
"types": "./types/index.d.ts",
|
|
46
|
+
"types": "./types/core/index.d.ts",
|
|
41
47
|
"bin": "./src/bin/index.js",
|
|
42
48
|
"repository": "regseb/metalint",
|
|
43
49
|
"type": "module",
|
|
@@ -58,52 +64,54 @@
|
|
|
58
64
|
},
|
|
59
65
|
"devDependencies": {
|
|
60
66
|
"@coffeelint/cli": "5.2.11",
|
|
67
|
+
"@mapbox/jsonlint-lines-primitives": "2.0.2",
|
|
61
68
|
"@prantlf/jsonlint": "14.0.3",
|
|
62
|
-
"@prettier/plugin-xml": "3.
|
|
63
|
-
"@stryker-mutator/core": "8.
|
|
64
|
-
"@stryker-mutator/mocha-runner": "8.
|
|
65
|
-
"@types/eslint": "8.56.
|
|
69
|
+
"@prettier/plugin-xml": "3.4.1",
|
|
70
|
+
"@stryker-mutator/core": "8.2.6",
|
|
71
|
+
"@stryker-mutator/mocha-runner": "8.2.6",
|
|
72
|
+
"@types/eslint": "8.56.10",
|
|
66
73
|
"@types/htmlhint": "1.1.5",
|
|
74
|
+
"@types/js-yaml": "4.0.9",
|
|
67
75
|
"@types/jshint": "2.12.4",
|
|
68
76
|
"@types/mocha": "10.0.6",
|
|
69
|
-
"@types/sinon": "17.0.
|
|
77
|
+
"@types/sinon": "17.0.3",
|
|
70
78
|
"@types/yargs": "17.0.32",
|
|
71
|
-
"addons-linter": "6.
|
|
72
|
-
"ajv": "8.
|
|
79
|
+
"addons-linter": "6.26.0",
|
|
80
|
+
"ajv": "8.13.0",
|
|
73
81
|
"csslint": "1.0.5",
|
|
74
82
|
"depcheck": "1.4.7",
|
|
75
83
|
"doiuse": "6.0.2",
|
|
76
|
-
"eslint": "8.
|
|
84
|
+
"eslint": "8.57.0",
|
|
77
85
|
"eslint-plugin-array-func": "4.0.0",
|
|
78
86
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
79
87
|
"eslint-plugin-import": "2.29.1",
|
|
80
|
-
"eslint-plugin-jsdoc": "48.
|
|
81
|
-
"eslint-plugin-mocha": "10.
|
|
82
|
-
"eslint-plugin-n": "
|
|
88
|
+
"eslint-plugin-jsdoc": "48.2.4",
|
|
89
|
+
"eslint-plugin-mocha": "10.4.3",
|
|
90
|
+
"eslint-plugin-n": "17.6.0",
|
|
83
91
|
"eslint-plugin-no-unsanitized": "4.0.2",
|
|
84
92
|
"eslint-plugin-promise": "6.1.1",
|
|
85
|
-
"eslint-plugin-regexp": "2.
|
|
86
|
-
"eslint-plugin-unicorn": "
|
|
93
|
+
"eslint-plugin-regexp": "2.5.0",
|
|
94
|
+
"eslint-plugin-unicorn": "53.0.0",
|
|
87
95
|
"htmlhint": "1.1.4",
|
|
88
96
|
"htmllint": "0.8.0",
|
|
89
97
|
"jshint": "2.13.6",
|
|
90
98
|
"jsonlint-mod": "1.7.6",
|
|
91
99
|
"jszip": "3.10.1",
|
|
92
|
-
"markdownlint": "0.
|
|
93
|
-
"markuplint": "
|
|
94
|
-
"mocha": "10.
|
|
95
|
-
"npm-check-updates": "16.14.
|
|
100
|
+
"markdownlint": "0.34.0",
|
|
101
|
+
"markuplint": "4.8.1",
|
|
102
|
+
"mocha": "10.4.0",
|
|
103
|
+
"npm-check-updates": "16.14.20",
|
|
96
104
|
"npm-package-json-lint": "7.1.0",
|
|
97
|
-
"prettier": "3.
|
|
105
|
+
"prettier": "3.2.5",
|
|
98
106
|
"publint": "0.2.7",
|
|
99
|
-
"purgecss": "
|
|
100
|
-
"sinon": "17.0.
|
|
101
|
-
"sort-package-json": "2.
|
|
107
|
+
"purgecss": "6.0.0",
|
|
108
|
+
"sinon": "17.0.2",
|
|
109
|
+
"sort-package-json": "2.10.0",
|
|
102
110
|
"standard": "17.1.0",
|
|
103
|
-
"stylelint": "16.
|
|
104
|
-
"svglint": "2.
|
|
105
|
-
"typedoc": "0.25.
|
|
106
|
-
"typescript": "5.
|
|
111
|
+
"stylelint": "16.5.0",
|
|
112
|
+
"svglint": "2.7.1",
|
|
113
|
+
"typedoc": "0.25.13",
|
|
114
|
+
"typescript": "5.4.5",
|
|
107
115
|
"yaml-lint": "1.7.0"
|
|
108
116
|
},
|
|
109
117
|
"engines": {
|
package/src/bin/argv.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import process from "node:process";
|
|
9
9
|
import yargs from "yargs";
|
|
10
|
+
import { hideBin } from "yargs/helpers";
|
|
10
11
|
import {
|
|
12
|
+
normalizeFix,
|
|
11
13
|
normalizeFormatter,
|
|
12
14
|
normalizeLevel,
|
|
13
15
|
} from "../core/configuration/normalize.js";
|
|
@@ -15,27 +17,25 @@ import { FORMATTERS } from "../core/formatter/formatter.js";
|
|
|
15
17
|
import Levels from "../core/levels.js";
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
|
-
* @typedef {import("../core/
|
|
19
|
-
* @typedef {import("../
|
|
20
|
+
* @typedef {import("../core/levels.js").Level} Level
|
|
21
|
+
* @typedef {import("../core/formatter/formatter.js").TypeofFormatter} TypeofFormatter
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* @typedef {Object} Argv
|
|
24
|
-
* @
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* de la ligne de commande.
|
|
36
|
-
* @property {boolean} help L'option <code>--help</code>
|
|
37
|
-
* de la ligne de commande.
|
|
26
|
+
* @prop {string[]} _ Les paramètress de la ligne de commande.
|
|
27
|
+
* @prop {string} config L'option <code>--config</code> de la
|
|
28
|
+
* ligne de commande.
|
|
29
|
+
* @prop {boolean} [fix] L'option <code>--fix</code> de la ligne
|
|
30
|
+
* de commande.
|
|
31
|
+
* @prop {TypeofFormatter} [formatter] L'option <code>--formatter</code> de la
|
|
32
|
+
* ligne de commande.
|
|
33
|
+
* @prop {Level} [level] L'option <code>--level</code> de la ligne
|
|
34
|
+
* de commande.
|
|
35
|
+
* @prop {boolean} help L'option <code>--help</code> de la ligne
|
|
36
|
+
* de commande.
|
|
38
37
|
*/
|
|
38
|
+
|
|
39
39
|
/**
|
|
40
40
|
* Extrait, vérifie et normalise les paramètres et les options de la ligne de
|
|
41
41
|
* commande.
|
|
@@ -43,39 +43,41 @@ import Levels from "../core/levels.js";
|
|
|
43
43
|
* @param {string[]} argv Les paramètres et les options de la ligne de commande.
|
|
44
44
|
* @returns {Promise<Argv>} Les paramètres et les options normalisés.
|
|
45
45
|
*/
|
|
46
|
-
export const parse = async function (argv = process.argv
|
|
46
|
+
export const parse = async function (argv = hideBin(process.argv)) {
|
|
47
|
+
// Désactiver cette règle, car il y a un faux-positif avec la méthode
|
|
48
|
+
// yargs.parseSync().
|
|
49
|
+
// eslint-disable-next-line n/no-sync
|
|
47
50
|
const args = yargs(argv)
|
|
48
51
|
.options({
|
|
49
|
-
|
|
50
|
-
alias: "
|
|
52
|
+
config: {
|
|
53
|
+
alias: "c",
|
|
51
54
|
default: ".metalint/metalint.config.js",
|
|
52
55
|
requiresArg: true,
|
|
53
56
|
type: "string",
|
|
54
57
|
},
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
fix: {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
},
|
|
61
|
+
formatter: {
|
|
62
|
+
alias: "f",
|
|
57
63
|
choices: FORMATTERS,
|
|
58
64
|
requiresArg: true,
|
|
59
65
|
type: "string",
|
|
60
66
|
},
|
|
61
|
-
|
|
62
|
-
alias: "
|
|
63
|
-
type: "boolean",
|
|
64
|
-
},
|
|
65
|
-
l: {
|
|
66
|
-
alias: "level",
|
|
67
|
+
level: {
|
|
68
|
+
alias: "l",
|
|
67
69
|
choices: Object.keys(Levels).map((l) => l.toLowerCase()),
|
|
68
|
-
default:
|
|
70
|
+
default: undefined,
|
|
69
71
|
requiresArg: true,
|
|
70
72
|
type: "string",
|
|
71
73
|
},
|
|
72
74
|
help: {
|
|
73
|
-
|
|
75
|
+
default: false,
|
|
74
76
|
type: "boolean",
|
|
75
77
|
},
|
|
76
78
|
})
|
|
77
79
|
.help(false)
|
|
78
|
-
.
|
|
80
|
+
.parseSync();
|
|
79
81
|
|
|
80
82
|
return {
|
|
81
83
|
// Ajouter une barre oblique à la fin pour les répertoires.
|
|
@@ -84,12 +86,14 @@ export const parse = async function (argv = process.argv.slice(2)) {
|
|
|
84
86
|
? ["./"]
|
|
85
87
|
: await Promise.all(
|
|
86
88
|
args._.map(async (base) => {
|
|
87
|
-
const stats = await fs.lstat(base);
|
|
88
|
-
return
|
|
89
|
+
const stats = await fs.lstat(base.toString());
|
|
90
|
+
return (
|
|
91
|
+
base.toString() + (stats.isDirectory() ? "/" : "")
|
|
92
|
+
);
|
|
89
93
|
}),
|
|
90
94
|
),
|
|
91
95
|
config: args.config,
|
|
92
|
-
fix: args.fix,
|
|
96
|
+
fix: normalizeFix(args.fix),
|
|
93
97
|
// Ne pas utiliser yargs.coerce() pour convertir les données, car cette
|
|
94
98
|
// méthode est incompatible avec yargs.choices().
|
|
95
99
|
// https://github.com/yargs/yargs/issues/1379
|
|
@@ -98,6 +102,6 @@ export const parse = async function (argv = process.argv.slice(2)) {
|
|
|
98
102
|
? undefined
|
|
99
103
|
: await normalizeFormatter(args.formatter),
|
|
100
104
|
level: normalizeLevel(args.level),
|
|
101
|
-
help: args.help
|
|
105
|
+
help: args.help,
|
|
102
106
|
};
|
|
103
107
|
};
|