metalint 0.19.0 → 0.21.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 +45 -30
- package/package.json +155 -37
- package/src/bin/argv.js +28 -42
- package/src/bin/index.js +1 -1
- package/src/core/configuration/flatten.js +14 -14
- package/src/core/configuration/normalize.js +28 -28
- package/src/core/configuration/override.js +2 -2
- package/src/core/configuration/partial.js +1 -1
- package/src/core/formatter/checkstyle.js +2 -2
- package/src/core/formatter/console.js +19 -43
- package/src/core/formatter/csv.js +2 -2
- package/src/core/index.js +2 -2
- package/src/core/levels.js +8 -10
- package/src/core/results.js +10 -4
- package/src/core/severities.js +8 -6
- package/src/core/utils/array.js +4 -3
- package/src/core/utils/file.js +1 -1
- package/src/core/utils/glob.js +23 -19
- package/src/core/utils/object.js +1 -1
- package/src/core/wrapper/addons-linter.js +4 -3
- package/src/core/wrapper/ajv.js +2 -2
- package/src/core/wrapper/biomejs__js-api.js +271 -0
- package/src/core/wrapper/coffeelint__cli.js +1 -1
- package/src/core/wrapper/depcheck.js +1 -1
- package/src/core/wrapper/doiuse.js +1 -1
- package/src/core/wrapper/eslint.js +1 -1
- package/src/core/wrapper/htmlhint.js +1 -1
- package/src/core/wrapper/htmllint.js +1 -1
- package/src/core/wrapper/jshint.js +1 -1
- package/src/core/wrapper/jsonlint-mod.js +1 -1
- package/src/core/wrapper/mapbox__jsonlint-lines-primitives.js +1 -1
- package/src/core/wrapper/markdownlint.js +5 -2
- package/src/core/wrapper/markuplint.js +12 -1
- package/src/core/wrapper/npm-check-updates.js +1 -1
- package/src/core/wrapper/npm-package-json-lint.js +16 -3
- package/src/core/wrapper/prantlf__jsonlint.js +1 -1
- package/src/core/wrapper/prettier.js +1 -1
- package/src/core/wrapper/publint.js +7 -7
- package/src/core/wrapper/purgecss.js +29 -17
- package/src/core/wrapper/secretlint.js +138 -0
- package/src/core/wrapper/sort-package-json.js +1 -1
- package/src/core/wrapper/standard.js +1 -1
- package/src/core/wrapper/stylelint.js +1 -1
- package/src/core/wrapper/svglint.js +1 -1
- package/src/core/wrapper/wrapper.js +1 -1
- package/src/core/wrapper/yaml-lint.js +1 -1
- package/types/bin/argv.d.ts +1 -1
- package/types/core/configuration/override.d.ts +0 -1
- package/types/core/index.d.ts +1 -1
- package/types/core/levels.d.ts +10 -6
- package/types/core/results.d.ts +3 -2
- package/types/core/severities.d.ts +15 -8
- package/types/core/wrapper/addons-linter.d.ts +1 -1
- package/types/core/wrapper/ajv.d.ts +1 -1
- package/types/core/wrapper/biomejs__js-api.d.ts +38 -0
- package/types/core/wrapper/coffeelint__cli.d.ts +1 -1
- package/types/core/wrapper/depcheck.d.ts +1 -1
- package/types/core/wrapper/doiuse.d.ts +1 -1
- package/types/core/wrapper/eslint.d.ts +1 -1
- package/types/core/wrapper/htmlhint.d.ts +1 -1
- package/types/core/wrapper/htmllint.d.ts +1 -1
- package/types/core/wrapper/jshint.d.ts +1 -1
- package/types/core/wrapper/jsonlint-mod.d.ts +1 -1
- package/types/core/wrapper/mapbox__jsonlint-lines-primitives.d.ts +1 -1
- package/types/core/wrapper/markdownlint.d.ts +1 -1
- package/types/core/wrapper/markuplint.d.ts +1 -1
- package/types/core/wrapper/npm-check-updates.d.ts +1 -1
- package/types/core/wrapper/npm-package-json-lint.d.ts +1 -1
- package/types/core/wrapper/prantlf__jsonlint.d.ts +1 -1
- package/types/core/wrapper/prettier.d.ts +1 -1
- package/types/core/wrapper/purgecss.d.ts +1 -1
- package/types/core/wrapper/secretlint.d.ts +42 -0
- package/types/core/wrapper/sort-package-json.d.ts +1 -1
- package/types/core/wrapper/standard.d.ts +1 -1
- package/types/core/wrapper/stylelint.d.ts +1 -1
- package/types/core/wrapper/svglint.d.ts +1 -1
- package/types/core/wrapper/yaml-lint.d.ts +1 -1
package/README.md
CHANGED
|
@@ -2,24 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- Utiliser du HTML (avec l'attribut "align" obsolète) pour faire flotter
|
|
4
4
|
l'image à droite. -->
|
|
5
|
-
<!-- markdownlint-disable-next-line no-inline-html-->
|
|
6
|
-
<img src="asset/logo.svg" align="right" alt="">
|
|
5
|
+
<!-- markdownlint-disable-next-line no-inline-html -->
|
|
6
|
+
<img src="asset/logo.svg" align="right" width="100" height="100" alt="">
|
|
7
7
|
|
|
8
8
|
[![npm][img-npm]][link-npm] [![build][img-build]][link-build]
|
|
9
9
|
[![coverage][img-coverage]][link-coverage] [![semver][img-semver]][link-semver]
|
|
10
10
|
|
|
11
|
-
>
|
|
11
|
+
> _One linter to rule them all._
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
**Metalint** est un outil pour analyser tous les fichiers de votre projet.
|
|
16
|
-
L'analyse est déléguée à des linters (outils d'analyse statique de code source)
|
|
17
|
-
:
|
|
13
|
+
**Metalint** is a tool for analyzing all the files in your project. Analysis is
|
|
14
|
+
delegated to linters (static source code analysis tools):
|
|
18
15
|
|
|
19
16
|
<!-- markdownlint-disable no-inline-html -->
|
|
20
17
|
<table>
|
|
21
18
|
<tr>
|
|
22
|
-
<th>
|
|
19
|
+
<th>Language / Technology</th>
|
|
23
20
|
<th>Linters</th>
|
|
24
21
|
</tr>
|
|
25
22
|
<tr>
|
|
@@ -32,6 +29,8 @@ L'analyse est déléguée à des linters (outils d'analyse statique de code sour
|
|
|
32
29
|
<tr>
|
|
33
30
|
<td>CSS</td>
|
|
34
31
|
<td>
|
|
32
|
+
<a title="@biomejs/js-api"
|
|
33
|
+
href="https://www.npmjs.com/package/@biomejs/js-api">Biome</a>,
|
|
35
34
|
<a title="doiuse" href="https://www.npmjs.com/package/doiuse">DoIUse</a>,
|
|
36
35
|
<a title="prettier"
|
|
37
36
|
href="https://www.npmjs.com/package/prettier">Prettier</a>,
|
|
@@ -57,6 +56,8 @@ L'analyse est déléguée à des linters (outils d'analyse statique de code sour
|
|
|
57
56
|
<tr>
|
|
58
57
|
<td>JavaScript</td>
|
|
59
58
|
<td>
|
|
59
|
+
<a title="@biomejs/js-api"
|
|
60
|
+
href="https://www.npmjs.com/package/@biomejs/js-api">Biome</a>,
|
|
60
61
|
<a title="eslint" href="https://www.npmjs.com/package/eslint">ESLint</a>,
|
|
61
62
|
<a title="jshint" href="https://www.npmjs.com/package/jshint">JSHint</a>,
|
|
62
63
|
<a title="standard"
|
|
@@ -70,6 +71,8 @@ L'analyse est déléguée à des linters (outils d'analyse statique de code sour
|
|
|
70
71
|
<td>JSON</td>
|
|
71
72
|
<td>
|
|
72
73
|
<a title="ajv" href="https://www.npmjs.com/package/ajv">Ajv</a>,
|
|
74
|
+
<a title="@biomejs/js-api"
|
|
75
|
+
href="https://www.npmjs.com/package/@biomejs/js-api">Biome</a>,
|
|
73
76
|
<a title="@mapbox/jsonlint-lines-primitives"
|
|
74
77
|
href="https://www.npmjs.com/package/@mapbox/jsonlint-lines-primitives">@mapbox/JSON
|
|
75
78
|
Lint lines-primitives</a>,
|
|
@@ -157,30 +160,36 @@ L'analyse est déléguée à des linters (outils d'analyse statique de code sour
|
|
|
157
160
|
href="https://www.npmjs.com/package/prettier">Prettier</a>
|
|
158
161
|
</td>
|
|
159
162
|
</tr>
|
|
163
|
+
<tr>
|
|
164
|
+
<td></td>
|
|
165
|
+
<td>
|
|
166
|
+
<a title="secretlint"
|
|
167
|
+
href="https://www.npmjs.com/package/secretlint">Secretlint</a>
|
|
168
|
+
</td>
|
|
169
|
+
</tr>
|
|
160
170
|
</table>
|
|
161
171
|
<!-- markdownlint-enable no-inline-html -->
|
|
162
172
|
|
|
163
|
-
##
|
|
173
|
+
## Install
|
|
164
174
|
|
|
165
|
-
|
|
175
|
+
You can install Metalint using [npm][link-npm]:
|
|
166
176
|
|
|
167
177
|
```shell
|
|
168
|
-
npm install --save-dev
|
|
178
|
+
npm install --save-dev metalint
|
|
169
179
|
```
|
|
170
180
|
|
|
171
181
|
## Configuration
|
|
172
182
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
linters.
|
|
183
|
+
All configuration files are grouped together in the `.metalint/` directory,
|
|
184
|
+
which should be placed at the root of the project. The `metalint.config.js` file
|
|
185
|
+
exports a JSON object indicating the linters to be used for each file. The other
|
|
186
|
+
files contain the specific options for the linters.
|
|
178
187
|
|
|
179
|
-
##
|
|
188
|
+
## Example
|
|
180
189
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
In this example of configuration files, Metalint analyzes JavaScript
|
|
191
|
+
(non-minified), HTML and CSS files; with ESLint, HTMLHint and Stylelint linters
|
|
192
|
+
respectively.
|
|
184
193
|
|
|
185
194
|
```javascript
|
|
186
195
|
// .metalint/metalint.config.js
|
|
@@ -229,12 +238,18 @@ export default {
|
|
|
229
238
|
};
|
|
230
239
|
```
|
|
231
240
|
|
|
232
|
-
|
|
241
|
+
If you want to see real configurations, you've got the
|
|
242
|
+
[Metalint configuration](https://github.com/regseb/metalint/tree/HEAD/.metalint)
|
|
243
|
+
itself; or the
|
|
244
|
+
[Cast Kodi configuration](https://github.com/regseb/castkodi/tree/HEAD/.metalint)
|
|
245
|
+
(a browser WebExtension developed in JavaScript, HTML, CSS).
|
|
246
|
+
|
|
247
|
+
## Integration
|
|
233
248
|
|
|
234
249
|
### npm
|
|
235
250
|
|
|
236
|
-
|
|
237
|
-
|
|
251
|
+
After installing Metalint and the linters in your npm project, you can add the
|
|
252
|
+
following script to your `package.json`:
|
|
238
253
|
|
|
239
254
|
```json
|
|
240
255
|
{
|
|
@@ -245,23 +260,23 @@ ajouter le script suivant dans votre `package.json` :
|
|
|
245
260
|
}
|
|
246
261
|
```
|
|
247
262
|
|
|
248
|
-
Metalint
|
|
249
|
-
`npm run lint:fix
|
|
263
|
+
Metalint can now be used with the following commands: `npm run lint` and
|
|
264
|
+
`npm run lint:fix`.
|
|
250
265
|
|
|
251
266
|
### GitHub Actions
|
|
252
267
|
|
|
253
|
-
|
|
254
|
-
|
|
268
|
+
To launch Metalint in your GitHub Actions, you can use the `github` formatter to
|
|
269
|
+
report problems in pull requests.
|
|
255
270
|
|
|
256
271
|
```yaml
|
|
257
272
|
jobs:
|
|
258
273
|
lint:
|
|
259
274
|
runs-on: ubuntu-latest
|
|
260
275
|
steps:
|
|
261
|
-
- uses: actions/checkout@
|
|
276
|
+
- uses: actions/checkout@v5
|
|
262
277
|
with:
|
|
263
278
|
persist-credentials: false
|
|
264
|
-
- uses: actions/setup-node@
|
|
279
|
+
- uses: actions/setup-node@v5
|
|
265
280
|
- name: Install dependencies
|
|
266
281
|
run: npm ci
|
|
267
282
|
- name: Lint files
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metalint",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.21.1",
|
|
4
|
+
"description": "One linter to rule them all.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checker",
|
|
7
7
|
"lint",
|
|
@@ -44,8 +44,13 @@
|
|
|
44
44
|
},
|
|
45
45
|
"main": "./src/core/index.js",
|
|
46
46
|
"types": "./types/core/index.d.ts",
|
|
47
|
-
"bin":
|
|
48
|
-
|
|
47
|
+
"bin": {
|
|
48
|
+
"metalint": "src/bin/index.js"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/regseb/metalint.git"
|
|
53
|
+
},
|
|
49
54
|
"type": "module",
|
|
50
55
|
"scripts": {
|
|
51
56
|
"lint": "node src/bin/index.js",
|
|
@@ -54,64 +59,177 @@
|
|
|
54
59
|
"test": "npm run test:unit",
|
|
55
60
|
"test:unit": "node --test 'test/unit/**/*.js'",
|
|
56
61
|
"test:coverage": "stryker run",
|
|
62
|
+
"test:fuzz": "node --test 'test/fuzz/**/*.js'",
|
|
57
63
|
"jsdocs": "typedoc --tsconfig .tsconfig_jsdocs.json",
|
|
58
64
|
"prepare": "tsc --project .tsconfig_types.json",
|
|
59
65
|
"clean": "node .script/clean.js"
|
|
60
66
|
},
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"chalk": "5.4.1",
|
|
63
|
-
"yargs": "17.7.2"
|
|
64
|
-
},
|
|
65
67
|
"devDependencies": {
|
|
68
|
+
"@biomejs/js-api": "4.0.0",
|
|
69
|
+
"@biomejs/wasm-nodejs": "2.3.1",
|
|
66
70
|
"@coffeelint/cli": "5.2.11",
|
|
67
71
|
"@mapbox/jsonlint-lines-primitives": "2.0.2",
|
|
68
72
|
"@prantlf/jsonlint": "16.0.0",
|
|
69
|
-
"@prettier/plugin-xml": "3.4.
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
+
"@prettier/plugin-xml": "3.4.2",
|
|
74
|
+
"@secretlint/secretlint-rule-github": "11.2.5",
|
|
75
|
+
"@secretlint/secretlint-rule-npm": "11.2.5",
|
|
76
|
+
"@stryker-mutator/core": "9.2.0",
|
|
77
|
+
"@stryker-mutator/tap-runner": "9.2.0",
|
|
73
78
|
"@types/htmlhint": "1.1.5",
|
|
74
79
|
"@types/js-yaml": "4.0.9",
|
|
75
80
|
"@types/jshint": "2.12.4",
|
|
76
81
|
"@types/semver-utils": "1.1.3",
|
|
77
|
-
"
|
|
78
|
-
"addons-linter": "7.7.0",
|
|
82
|
+
"addons-linter": "8.4.0",
|
|
79
83
|
"ajv": "8.17.1",
|
|
80
84
|
"depcheck": "1.4.7",
|
|
81
85
|
"doiuse": "6.0.5",
|
|
82
|
-
"eslint": "9.
|
|
83
|
-
"eslint-plugin-array-func": "5.0
|
|
86
|
+
"eslint": "9.38.0",
|
|
87
|
+
"eslint-plugin-array-func": "5.1.0",
|
|
84
88
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
85
|
-
"eslint-plugin-import": "2.
|
|
86
|
-
"eslint-plugin-jsdoc": "
|
|
87
|
-
"eslint-plugin-mocha": "
|
|
88
|
-
"eslint-plugin-n": "17.
|
|
89
|
-
"eslint-plugin-no-unsanitized": "4.1.
|
|
89
|
+
"eslint-plugin-import": "2.32.0",
|
|
90
|
+
"eslint-plugin-jsdoc": "61.1.9",
|
|
91
|
+
"eslint-plugin-mocha": "11.2.0",
|
|
92
|
+
"eslint-plugin-n": "17.23.1",
|
|
93
|
+
"eslint-plugin-no-unsanitized": "4.1.4",
|
|
90
94
|
"eslint-plugin-promise": "7.2.1",
|
|
91
|
-
"eslint-plugin-regexp": "2.
|
|
92
|
-
"eslint-plugin-unicorn": "
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
+
"eslint-plugin-regexp": "2.10.0",
|
|
96
|
+
"eslint-plugin-unicorn": "62.0.0",
|
|
97
|
+
"fast-check": "4.3.0",
|
|
98
|
+
"globals": "16.4.0",
|
|
99
|
+
"htmlhint": "1.7.1",
|
|
95
100
|
"htmllint": "0.8.0",
|
|
96
101
|
"jshint": "2.13.6",
|
|
97
102
|
"jsonlint-mod": "1.7.6",
|
|
98
103
|
"jszip": "3.10.1",
|
|
99
|
-
"markdownlint": "0.
|
|
100
|
-
"markuplint": "4.
|
|
101
|
-
"npm-check-updates": "
|
|
102
|
-
"npm-package-json-lint": "
|
|
103
|
-
"prettier": "3.
|
|
104
|
-
"publint": "0.
|
|
104
|
+
"markdownlint": "0.39.0",
|
|
105
|
+
"markuplint": "4.13.1",
|
|
106
|
+
"npm-check-updates": "19.1.1",
|
|
107
|
+
"npm-package-json-lint": "9.0.0",
|
|
108
|
+
"prettier": "3.6.2",
|
|
109
|
+
"publint": "0.3.15",
|
|
105
110
|
"purgecss": "7.0.2",
|
|
106
|
-
"
|
|
111
|
+
"secretlint": "11.2.5",
|
|
112
|
+
"sort-package-json": "3.4.0",
|
|
107
113
|
"standard": "17.1.2",
|
|
108
|
-
"stylelint": "16.
|
|
109
|
-
"svglint": "
|
|
110
|
-
"typedoc": "0.
|
|
111
|
-
"typescript": "5.
|
|
114
|
+
"stylelint": "16.25.0",
|
|
115
|
+
"svglint": "4.1.2",
|
|
116
|
+
"typedoc": "0.28.14",
|
|
117
|
+
"typescript": "5.9.3",
|
|
112
118
|
"yaml-lint": "1.7.0"
|
|
113
119
|
},
|
|
120
|
+
"peerDependencies": {
|
|
121
|
+
"@biomejs/js-api": ">=4.0.0",
|
|
122
|
+
"@biomejs/wasm-nodejs": ">=2.3.1",
|
|
123
|
+
"@coffeelint/cli": ">=5.2.11",
|
|
124
|
+
"@mapbox/jsonlint-lines-primitives": ">=2.0.2",
|
|
125
|
+
"@prantlf/jsonlint": ">=16.0.0",
|
|
126
|
+
"addons-linter": ">=8.4.0",
|
|
127
|
+
"ajv": ">=8.17.1",
|
|
128
|
+
"depcheck": ">=1.4.7",
|
|
129
|
+
"doiuse": ">=6.0.5",
|
|
130
|
+
"eslint": ">=9.38.0",
|
|
131
|
+
"htmlhint": ">=1.7.1",
|
|
132
|
+
"htmllint": ">=0.8.0",
|
|
133
|
+
"jshint": ">=2.13.6",
|
|
134
|
+
"jsonlint-mod": ">=1.7.6",
|
|
135
|
+
"markdownlint": ">=0.39.0",
|
|
136
|
+
"markuplint": ">=4.13.1",
|
|
137
|
+
"npm-check-updates": ">=19.1.1",
|
|
138
|
+
"npm-package-json-lint": ">=9.0.0",
|
|
139
|
+
"prettier": ">=3.6.2",
|
|
140
|
+
"publint": ">=0.3.15",
|
|
141
|
+
"purgecss": ">=7.0.2",
|
|
142
|
+
"secretlint": ">=11.2.3",
|
|
143
|
+
"sort-package-json": ">=3.4.0",
|
|
144
|
+
"standard": ">=17.1.2",
|
|
145
|
+
"stylelint": ">=16.25.0",
|
|
146
|
+
"svglint": ">=4.1.2",
|
|
147
|
+
"yaml-lint": ">=1.7.0"
|
|
148
|
+
},
|
|
149
|
+
"peerDependenciesMeta": {
|
|
150
|
+
"@biomejs/js-api": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"@biomejs/wasm-nodejs": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
156
|
+
"@coffeelint/cli": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"@mapbox/jsonlint-lines-primitives": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"@prantlf/jsonlint": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"addons-linter": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"ajv": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"depcheck": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"doiuse": {
|
|
175
|
+
"optional": true
|
|
176
|
+
},
|
|
177
|
+
"eslint": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
180
|
+
"htmlhint": {
|
|
181
|
+
"optional": true
|
|
182
|
+
},
|
|
183
|
+
"htmllint": {
|
|
184
|
+
"optional": true
|
|
185
|
+
},
|
|
186
|
+
"jshint": {
|
|
187
|
+
"optional": true
|
|
188
|
+
},
|
|
189
|
+
"jsonlint-mod": {
|
|
190
|
+
"optional": true
|
|
191
|
+
},
|
|
192
|
+
"markdownlint": {
|
|
193
|
+
"optional": true
|
|
194
|
+
},
|
|
195
|
+
"markuplint": {
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
198
|
+
"npm-check-updates": {
|
|
199
|
+
"optional": true
|
|
200
|
+
},
|
|
201
|
+
"npm-package-json-lint": {
|
|
202
|
+
"optional": true
|
|
203
|
+
},
|
|
204
|
+
"prettier": {
|
|
205
|
+
"optional": true
|
|
206
|
+
},
|
|
207
|
+
"publint": {
|
|
208
|
+
"optional": true
|
|
209
|
+
},
|
|
210
|
+
"purgecss": {
|
|
211
|
+
"optional": true
|
|
212
|
+
},
|
|
213
|
+
"secretlint": {
|
|
214
|
+
"optional": true
|
|
215
|
+
},
|
|
216
|
+
"sort-package-json": {
|
|
217
|
+
"optional": true
|
|
218
|
+
},
|
|
219
|
+
"standard": {
|
|
220
|
+
"optional": true
|
|
221
|
+
},
|
|
222
|
+
"stylelint": {
|
|
223
|
+
"optional": true
|
|
224
|
+
},
|
|
225
|
+
"svglint": {
|
|
226
|
+
"optional": true
|
|
227
|
+
},
|
|
228
|
+
"yaml-lint": {
|
|
229
|
+
"optional": true
|
|
230
|
+
}
|
|
231
|
+
},
|
|
114
232
|
"engines": {
|
|
115
|
-
"node": ">=22.
|
|
233
|
+
"node": ">=22.13.0"
|
|
116
234
|
}
|
|
117
235
|
}
|
package/src/bin/argv.js
CHANGED
|
@@ -6,24 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import process from "node:process";
|
|
9
|
-
import
|
|
10
|
-
import { hideBin } from "yargs/helpers";
|
|
9
|
+
import { parseArgs } from "node:util";
|
|
11
10
|
import {
|
|
12
11
|
normalizeFix,
|
|
13
12
|
normalizeFormatter,
|
|
14
13
|
normalizeLevel,
|
|
15
14
|
} from "../core/configuration/normalize.js";
|
|
16
|
-
import { FORMATTERS } from "../core/formatter/formatter.js";
|
|
17
|
-
import Levels from "../core/levels.js";
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
|
-
* @import { Level } from "../core/levels.js"
|
|
21
17
|
* @import { TypeofFormatter } from "../core/formatter/formatter.js"
|
|
18
|
+
* @import { Level } from "../core/levels.js"
|
|
22
19
|
*/
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* @typedef {Object} Argv
|
|
26
|
-
* @prop {string[]}
|
|
23
|
+
* @prop {string[]} bases Les paramètres de la ligne de commande.
|
|
27
24
|
* @prop {string} config L'option `--config` de la ligne de
|
|
28
25
|
* commande.
|
|
29
26
|
* @prop {boolean} [fix] L'option `--fix` de la ligne de commande.
|
|
@@ -42,65 +39,54 @@ import Levels from "../core/levels.js";
|
|
|
42
39
|
* @param {string[]} argv Les paramètres et les options de la ligne de commande.
|
|
43
40
|
* @returns {Promise<Argv>} Les paramètres et les options normalisés.
|
|
44
41
|
*/
|
|
45
|
-
export const parse = async
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
export const parse = async (argv = process.argv) => {
|
|
43
|
+
const { values, positionals } = parseArgs({
|
|
44
|
+
// Enlever les deux premiers arguments de la ligne de commande qui sont
|
|
45
|
+
// "node" et "index.js".
|
|
46
|
+
args: argv.slice(2),
|
|
47
|
+
options: {
|
|
51
48
|
config: {
|
|
52
|
-
alias: "c",
|
|
53
|
-
default: ".metalint/metalint.config.js",
|
|
54
|
-
requiresArg: true,
|
|
55
49
|
type: "string",
|
|
50
|
+
short: "c",
|
|
51
|
+
default: ".metalint/metalint.config.js",
|
|
56
52
|
},
|
|
57
53
|
fix: {
|
|
58
54
|
type: "boolean",
|
|
59
55
|
},
|
|
60
56
|
formatter: {
|
|
61
|
-
alias: "f",
|
|
62
|
-
choices: FORMATTERS,
|
|
63
|
-
requiresArg: true,
|
|
64
57
|
type: "string",
|
|
58
|
+
short: "f",
|
|
65
59
|
},
|
|
66
60
|
level: {
|
|
67
|
-
alias: "l",
|
|
68
|
-
choices: Object.keys(Levels).map((l) => l.toLowerCase()),
|
|
69
|
-
default: undefined,
|
|
70
|
-
requiresArg: true,
|
|
71
61
|
type: "string",
|
|
62
|
+
short: "l",
|
|
72
63
|
},
|
|
73
64
|
help: {
|
|
74
|
-
default: false,
|
|
75
65
|
type: "boolean",
|
|
66
|
+
default: false,
|
|
76
67
|
},
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
},
|
|
69
|
+
allowPositionals: true,
|
|
70
|
+
});
|
|
80
71
|
|
|
81
72
|
return {
|
|
82
73
|
// Ajouter une barre oblique à la fin pour les répertoires.
|
|
83
|
-
|
|
84
|
-
0 ===
|
|
74
|
+
bases:
|
|
75
|
+
0 === positionals.length
|
|
85
76
|
? ["./"]
|
|
86
77
|
: await Promise.all(
|
|
87
|
-
|
|
88
|
-
const stats = await fs.lstat(
|
|
89
|
-
return (
|
|
90
|
-
base.toString() + (stats.isDirectory() ? "/" : "")
|
|
91
|
-
);
|
|
78
|
+
positionals.map(async (positional) => {
|
|
79
|
+
const stats = await fs.lstat(positional);
|
|
80
|
+
return positional + (stats.isDirectory() ? "/" : "");
|
|
92
81
|
}),
|
|
93
82
|
),
|
|
94
|
-
config:
|
|
95
|
-
fix: normalizeFix(
|
|
96
|
-
// Ne pas utiliser yargs.coerce() pour convertir les données, car cette
|
|
97
|
-
// méthode est incompatible avec yargs.choices().
|
|
98
|
-
// https://github.com/yargs/yargs/issues/1379
|
|
83
|
+
config: values.config,
|
|
84
|
+
fix: normalizeFix(values.fix),
|
|
99
85
|
formatter:
|
|
100
|
-
undefined ===
|
|
86
|
+
undefined === values.formatter
|
|
101
87
|
? undefined
|
|
102
|
-
: await normalizeFormatter(
|
|
103
|
-
level: normalizeLevel(
|
|
104
|
-
help:
|
|
88
|
+
: await normalizeFormatter(values.formatter),
|
|
89
|
+
level: normalizeLevel(values.level),
|
|
90
|
+
help: values.help,
|
|
105
91
|
};
|
|
106
92
|
};
|
package/src/bin/index.js
CHANGED
|
@@ -8,14 +8,14 @@ import Levels from "../levels.js";
|
|
|
8
8
|
import { merge } from "../utils/object.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
+
* @import { TypeofFormatter } from "../formatter/formatter.js"
|
|
12
|
+
* @import { Level } from "../levels.js"
|
|
13
|
+
* @import { TypeofWrapper } from "../wrapper/wrapper.js"
|
|
11
14
|
* @import { NormalizedConfig } from "./normalize.js"
|
|
12
15
|
* @import { NormalizedConfigChecker } from "./normalize.js"
|
|
13
16
|
* @import { NormalizedConfigLinter } from "./normalize.js"
|
|
14
17
|
* @import { NormalizedConfigOverride } from "./normalize.js"
|
|
15
18
|
* @import { NormalizedConfigReporter } from "./normalize.js"
|
|
16
|
-
* @import { Level } from "../levels.js"
|
|
17
|
-
* @import { TypeofFormatter } from "../formatter/formatter.js"
|
|
18
|
-
* @import { TypeofWrapper } from "../wrapper/wrapper.js"
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -74,7 +74,7 @@ import { merge } from "../utils/object.js";
|
|
|
74
74
|
* parente.
|
|
75
75
|
* @returns {string[]} La valeur fusionnée.
|
|
76
76
|
*/
|
|
77
|
-
export const flattenPatterns =
|
|
77
|
+
export const flattenPatterns = (hierarchies, { patterns }) => {
|
|
78
78
|
return [...patterns, ...hierarchies];
|
|
79
79
|
};
|
|
80
80
|
|
|
@@ -88,7 +88,7 @@ export const flattenPatterns = function (hierarchies, { patterns }) {
|
|
|
88
88
|
* parente.
|
|
89
89
|
* @returns {boolean} La valeur fusionnée.
|
|
90
90
|
*/
|
|
91
|
-
export const flattenFix =
|
|
91
|
+
export const flattenFix = (hierarchy, { fix }) => {
|
|
92
92
|
return hierarchy ?? fix;
|
|
93
93
|
};
|
|
94
94
|
|
|
@@ -102,7 +102,7 @@ export const flattenFix = function (hierarchy, { fix }) {
|
|
|
102
102
|
* parente.
|
|
103
103
|
* @returns {Level} La valeur fusionnée.
|
|
104
104
|
*/
|
|
105
|
-
export const flattenLevel =
|
|
105
|
+
export const flattenLevel = (hierarchy, { level }) => {
|
|
106
106
|
return hierarchy ?? level;
|
|
107
107
|
};
|
|
108
108
|
|
|
@@ -116,7 +116,7 @@ export const flattenLevel = function (hierarchy, { level }) {
|
|
|
116
116
|
* `"options"` parente.
|
|
117
117
|
* @returns {Record<string, unknown>} La valeur fusionnée.
|
|
118
118
|
*/
|
|
119
|
-
export const flattenOptions =
|
|
119
|
+
export const flattenOptions = (hierarchies, { options }) => {
|
|
120
120
|
return [options, ...hierarchies].reduce(merge);
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -130,7 +130,7 @@ export const flattenOptions = function (hierarchies, { options }) {
|
|
|
130
130
|
* `"level"` parente.
|
|
131
131
|
* @returns {FlattenedConfigReporter} La valeur fusionnée.
|
|
132
132
|
*/
|
|
133
|
-
export const flattenReporter =
|
|
133
|
+
export const flattenReporter = (hierarchy, { level }) => {
|
|
134
134
|
return {
|
|
135
135
|
formatter: hierarchy.formatter,
|
|
136
136
|
level: flattenLevel(hierarchy.level, { level }),
|
|
@@ -155,7 +155,7 @@ export const flattenReporter = function (hierarchy, { level }) {
|
|
|
155
155
|
* parente.
|
|
156
156
|
* @returns {FlattenedConfigReporter[]} La valeur fusionnée.
|
|
157
157
|
*/
|
|
158
|
-
export const flattenReporters =
|
|
158
|
+
export const flattenReporters = (hierarchies, { formatter, level }) => {
|
|
159
159
|
if (undefined === formatter) {
|
|
160
160
|
return hierarchies.map((r) => flattenReporter(r, { level }));
|
|
161
161
|
}
|
|
@@ -183,7 +183,7 @@ export const flattenReporters = function (hierarchies, { formatter, level }) {
|
|
|
183
183
|
* `"options"` parente.
|
|
184
184
|
* @returns {FlattenedConfigLinter} La valeur fusionnée.
|
|
185
185
|
*/
|
|
186
|
-
export const flattenLinter =
|
|
186
|
+
export const flattenLinter = (hierarchy, { fix, level, options }) => {
|
|
187
187
|
return {
|
|
188
188
|
wrapper: hierarchy.wrapper,
|
|
189
189
|
fix: flattenFix(hierarchy.fix, { fix }),
|
|
@@ -204,7 +204,7 @@ export const flattenLinter = function (hierarchy, { fix, level, options }) {
|
|
|
204
204
|
* `"level"` parente.
|
|
205
205
|
* @returns {FlattenedConfigLinter[]} La valeur fusionnée.
|
|
206
206
|
*/
|
|
207
|
-
export const flattenLinters =
|
|
207
|
+
export const flattenLinters = (hierarchies, { fix, level }) => {
|
|
208
208
|
const map = new Map();
|
|
209
209
|
for (const hierarchy of hierarchies) {
|
|
210
210
|
if (map.has(hierarchy.wrapper)) {
|
|
@@ -243,7 +243,7 @@ export const flattenLinters = function (hierarchies, { fix, level }) {
|
|
|
243
243
|
* `"level"` parente.
|
|
244
244
|
* @returns {FlattenedConfigOverride} La valeur fusionnée.
|
|
245
245
|
*/
|
|
246
|
-
export const flattenOverride =
|
|
246
|
+
export const flattenOverride = (hierarchy, { fix, level }) => {
|
|
247
247
|
return {
|
|
248
248
|
patterns: hierarchy.patterns,
|
|
249
249
|
linters: flattenLinters(hierarchy.linters, {
|
|
@@ -265,7 +265,7 @@ export const flattenOverride = function (hierarchy, { fix, level }) {
|
|
|
265
265
|
* `"level"` parente.
|
|
266
266
|
* @returns {FlattenedConfigChecker} La valeur fusionnée.
|
|
267
267
|
*/
|
|
268
|
-
export const flattenChecker =
|
|
268
|
+
export const flattenChecker = (hierarchy, { fix, level }) => {
|
|
269
269
|
const base = {
|
|
270
270
|
fix: flattenFix(hierarchy.fix, { fix }),
|
|
271
271
|
level: flattenLevel(hierarchy.level, { level }),
|
|
@@ -298,7 +298,7 @@ export const flattenChecker = function (hierarchy, { fix, level }) {
|
|
|
298
298
|
* commande.
|
|
299
299
|
* @returns {FlattenedConfig} L'objet JSON fusionné.
|
|
300
300
|
*/
|
|
301
|
-
export const flatten =
|
|
301
|
+
export const flatten = (hierarchy, argv) => {
|
|
302
302
|
const fix = flattenFix(argv.fix ?? hierarchy.fix, { fix: false });
|
|
303
303
|
const level = flattenLevel(argv.level ?? hierarchy.level, {
|
|
304
304
|
level: Levels.INFO,
|