metalint 0.10.0 → 0.11.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.
Files changed (65) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +70 -23
  3. package/package.json +99 -90
  4. package/src/bin/help.txt +3 -2
  5. package/src/bin/index.js +79 -59
  6. package/src/core/formatter/checkstyle.js +20 -17
  7. package/src/core/formatter/console.js +44 -24
  8. package/src/core/formatter/csv.js +11 -9
  9. package/src/core/formatter/github.js +114 -0
  10. package/src/core/formatter/json.js +16 -9
  11. package/src/core/formatter/unix.js +10 -7
  12. package/src/core/glob.js +76 -55
  13. package/src/core/index.js +21 -11
  14. package/src/core/normalize.js +222 -132
  15. package/src/core/severity.js +5 -3
  16. package/src/core/wrapper/addons-linter.js +47 -33
  17. package/src/core/wrapper/coffeelint.js +22 -16
  18. package/src/core/wrapper/csslint.js +27 -19
  19. package/src/core/wrapper/doiuse.js +28 -18
  20. package/src/core/wrapper/eslint.js +54 -34
  21. package/src/core/wrapper/flow-bin.js +18 -12
  22. package/src/core/wrapper/htmlhint.js +27 -19
  23. package/src/core/wrapper/htmllint.js +20 -13
  24. package/src/core/wrapper/jshint.js +28 -18
  25. package/src/core/wrapper/json-lint.js +25 -17
  26. package/src/core/wrapper/jsonlint-mod.js +22 -16
  27. package/src/core/wrapper/jsonlint.js +22 -16
  28. package/src/core/wrapper/lesshint.js +40 -29
  29. package/src/core/wrapper/markdownlint.js +28 -21
  30. package/src/core/wrapper/markuplint.js +60 -0
  31. package/src/core/wrapper/npm-package-json-lint.js +55 -0
  32. package/src/core/wrapper/prettier.js +77 -0
  33. package/src/core/wrapper/purgecss.js +33 -26
  34. package/src/core/wrapper/standard.js +45 -18
  35. package/src/core/wrapper/stylelint.js +32 -20
  36. package/src/core/wrapper/yaml-lint.js +28 -19
  37. package/src/types.d.ts +21 -19
  38. package/types/formatter/checkstyle.d.ts +5 -5
  39. package/types/formatter/console.d.ts +4 -4
  40. package/types/formatter/csv.d.ts +4 -4
  41. package/types/formatter/github.d.ts +40 -0
  42. package/types/formatter/json.d.ts +12 -10
  43. package/types/formatter/unix.d.ts +9 -7
  44. package/types/glob.d.ts +4 -25
  45. package/types/wrapper/addons-linter.d.ts +3 -1
  46. package/types/wrapper/coffeelint.d.ts +3 -1
  47. package/types/wrapper/csslint.d.ts +3 -1
  48. package/types/wrapper/doiuse.d.ts +3 -1
  49. package/types/wrapper/eslint.d.ts +4 -1
  50. package/types/wrapper/flow-bin.d.ts +3 -1
  51. package/types/wrapper/htmlhint.d.ts +3 -1
  52. package/types/wrapper/htmllint.d.ts +3 -1
  53. package/types/wrapper/jshint.d.ts +3 -1
  54. package/types/wrapper/json-lint.d.ts +3 -1
  55. package/types/wrapper/jsonlint-mod.d.ts +3 -1
  56. package/types/wrapper/jsonlint.d.ts +3 -1
  57. package/types/wrapper/lesshint.d.ts +3 -1
  58. package/types/wrapper/markdownlint.d.ts +3 -1
  59. package/types/wrapper/markuplint.d.ts +4 -0
  60. package/types/wrapper/npm-package-json-lint.d.ts +4 -0
  61. package/types/wrapper/prettier.d.ts +5 -0
  62. package/types/wrapper/purgecss.d.ts +4 -1
  63. package/types/wrapper/standard.d.ts +3 -1
  64. package/types/wrapper/stylelint.d.ts +4 -1
  65. package/types/wrapper/yaml-lint.d.ts +3 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2022 Sébastien Règne
3
+ Copyright (c) 2020-2023 Sébastien Règne
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Metalint
2
2
 
3
+ <!-- Utiliser du HTML pour faire flotter l'image à droite. -->
4
+ <!-- markdownlint-disable-next-line no-inline-html-->
5
+ <img src="asset/logo.svg" align="right" alt="">
6
+
3
7
  [![npm][img-npm]][link-npm]
4
8
  [![build][img-build]][link-build]
5
9
  [![coverage][img-coverage]][link-coverage]
@@ -13,6 +17,8 @@
13
17
  L'analyse est déléguée à des linters (outils d'analyse statique de code source)
14
18
  ou des utilitaires selon le type de fichier :
15
19
 
20
+ - _Générique_ :
21
+ [Prettier](https://regseb.github.io/metalint/user/linters/prettier/) ;
16
22
  - WebExtension : [Add-ons
17
23
  Linter](https://regseb.github.io/metalint/user/linters/addons-linter/) ;
18
24
  - CoffeeScript :
@@ -23,8 +29,9 @@ ou des utilitaires selon le type de fichier :
23
29
  [lesshint](https://regseb.github.io/metalint/user/linters/lesshint/),
24
30
  [PurgeCSS](https://regseb.github.io/metalint/user/linters/purgecss/) et
25
31
  [stylelint](https://regseb.github.io/metalint/user/linters/stylelint/) ;
26
- - HTML : [HTMLHint](https://regseb.github.io/metalint/user/linters/htmlhint/) et
27
- [htmllint](https://regseb.github.io/metalint/user/linters/htmllint/) ;
32
+ - HTML : [HTMLHint](https://regseb.github.io/metalint/user/linters/htmlhint/),
33
+ [htmllint](https://regseb.github.io/metalint/user/linters/htmllint/) et
34
+ [markuplint](https://regseb.github.io/metalint/user/linters/markuplint/) ;
28
35
  - JavaScript : [ESLint](https://regseb.github.io/metalint/user/linters/eslint/),
29
36
  [Flow](https://regseb.github.io/metalint/user/linters/flow-bin/),
30
37
  [JSHint](https://regseb.github.io/metalint/user/linters/jshint/) et
@@ -34,6 +41,9 @@ ou des utilitaires selon le type de fichier :
34
41
  [JSON Lint](https://regseb.github.io/metalint/user/linters/jsonlint/) et
35
42
  [JSON Lint
36
43
  (mod)](https://regseb.github.io/metalint/user/linters/jsonlint-mod/) ;
44
+ - package.json (npm) :
45
+ [npm-package-json-lint](https://regseb.github.io/metalint/user/linters/npm-package-json-lint/)
46
+ ;
37
47
  - Markdown :
38
48
  [MarkdownLint](https://regseb.github.io/metalint/user/linters/markdownlint/) ;
39
49
  - YAML : [YAML Lint](https://regseb.github.io/metalint/user/linters/yaml-lint/).
@@ -42,7 +52,7 @@ ou des utilitaires selon le type de fichier :
42
52
 
43
53
  Vous pouvez installer Metalint en utilisant [npm][link-npm] :
44
54
 
45
- ```shell
55
+ ```Shell
46
56
  npm install metalint --save-dev
47
57
  ```
48
58
 
@@ -50,17 +60,18 @@ npm install metalint --save-dev
50
60
 
51
61
  Tous les fichiers de configuration sont à regrouper dans le répertoire
52
62
  `.metalint/` qui doit être placé à la racine du projet. Le fichier
53
- `metalint.config.js` contient un objet JSON indiquant les linters à utiliser
54
- pour chaque fichier. Les autres fichiers contiennent les options spécifiques
55
- pour les linters.
63
+ `metalint.config.js` export un objet JSON indiquant les linters à utiliser pour
64
+ chaque fichier. Les autres fichiers contiennent les options spécifiques pour les
65
+ linters.
56
66
 
57
67
  ## Exemple
58
68
 
59
- Dans cet exemple du fichier de configuration `metalint.json`, Metalint analyse
60
- les fichiers JavaScript (non-minifiés), HTML et CSS ; avec respectivement les
61
- linters ESLint, HTMLHint et stylelint.
69
+ Dans cet exemple des fichiers de configuration, Metalint analyse les fichiers
70
+ JavaScript (non-minifiés), HTML et CSS ; avec respectivement les linters ESLint,
71
+ HTMLHint et stylelint.
62
72
 
63
73
  ```JavaScript
74
+ // .metalint/metalint.config.js
64
75
  export default {
65
76
  patterns: ["!/.git/", "!/node_modules/", "**"],
66
77
  checkers: [
@@ -78,20 +89,56 @@ export default {
78
89
  };
79
90
  ```
80
91
 
81
- ## Usage
92
+ ```JavaScript
93
+ // .metalint/eslint.config.js
94
+ export default {
95
+ rules: {
96
+ quotes: ["error", "double"],
97
+ semi: ["error", "always"],
98
+ },
99
+ };
100
+ ```
101
+
102
+ ```JavaScript
103
+ // .metalint/htmlhint.config.js
104
+ export default {
105
+ "attr-value-not-empty": false,
106
+ };
107
+ ```
108
+
109
+ ```JavaScript
110
+ // .metalint/stylelint.config.js
111
+ export default {
112
+ rules: {
113
+ "color-no-invalid-hex": true,
114
+ },
115
+ };
116
+ ```
117
+
118
+ ## Intégration
119
+
120
+ Après avoir installé Metalint et les linters dans votre projet npm, vous pouvez
121
+ ajouter le script suivant dans votre `package.json` :
82
122
 
83
- ```shell
84
- metalint
123
+ ```JSON
124
+ {
125
+ "scripts": {
126
+ "lint": "metalint"
127
+ }
128
+ }
85
129
  ```
86
130
 
87
- <!-- Ne pas ajouter les logos car la couleur du logo de npm n'est pas
88
- personnalisable. https://github.com/badges/shields/issues/6208 -->
89
- [img-npm]:https://img.shields.io/npm/dm/metalint?label=npm
90
- [img-build]:https://img.shields.io/github/workflow/status/regseb/metalint/CI
91
- [img-coverage]:https://img.shields.io/coveralls/github/regseb/metalint
92
- [img-semver]:https://img.shields.io/badge/semver-2.0.0-blue
93
-
94
- [link-npm]:https://www.npmjs.com/package/metalint
95
- [link-build]:https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
96
- [link-coverage]:https://coveralls.io/github/regseb/metalint
97
- [link-semver]:https://semver.org/spec/v2.0.0.html "Semantic Versioning 2.0.0"
131
+ Metalint est maintenant utilisable avec la commande : `npm run lint`
132
+
133
+ [img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=white
134
+ [img-build]: https://img.shields.io/github/actions/workflow/status/regseb/metalint/ci.yml?branch=main&logo=github&logoColor=white
135
+
136
+ <!-- Attendre que le logo de Stryker soit accepté.
137
+ https://github.com/simple-icons/simple-icons/pull/7388 -->
138
+
139
+ [img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain
140
+ [img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=white
141
+ [link-npm]: https://www.npmjs.com/package/metalint
142
+ [link-build]: https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
143
+ [link-coverage]: https://dashboard.stryker-mutator.io/reports/github.com/regseb/metalint/main
144
+ [link-semver]: https://semver.org/spec/v2.0.0.html "Semantic Versioning 2.0.0"
package/package.json CHANGED
@@ -1,92 +1,101 @@
1
1
  {
2
- "name": "metalint",
3
- "version": "0.10.0",
4
- "description": "Un linter pour les gouverner tous.",
5
- "keywords": [
6
- "checker",
7
- "lint",
8
- "metalint",
9
- "quality",
10
- "static-analysis"
11
- ],
12
- "homepage": "https://github.com/regseb/metalint#readme",
13
- "bugs": {
14
- "url": "https://github.com/regseb/metalint/issues",
15
- "email": "regseb@gmail.com"
16
- },
17
- "license": "MIT",
18
- "author": "Sébastien Règne <regseb@gmail.com> (https://github.com/regseb)",
19
- "funding": "https://www.paypal.me/sebastienregne",
20
- "files": [
21
- "src/",
22
- "types/"
23
- ],
24
- "main": "src/core/index.js",
25
- "bin": "src/bin/index.js",
26
- "types": "types/index.d.ts",
27
- "repository": "regseb/metalint",
28
- "type": "module",
29
- "scripts": {
30
- "lint": "src/bin/index.js",
31
- "lint:types": "tsc --project .tsconfig_lint.json",
32
- "test": "c8 mocha test/",
33
- "coverage:html": "c8 report --reporter html",
34
- "coverage:lcov": "c8 report --reporter lcovonly",
35
- "jsdocs": "typedoc --tsconfig .tsconfig_jsdocs.json --out jsdocs/ src/core/",
36
- "prepare": "tsc --project .tsconfig_types.json",
37
- "release": "standard-version",
38
- "clean": "node .script/clean.js"
39
- },
40
- "dependencies": {
41
- "chalk": "^5.0.1",
42
- "yargs": "^17.3.1"
43
- },
44
- "devDependencies": {
45
- "@coffeelint/cli": "5.2.5",
46
- "@types/eslint": "8.4.1",
47
- "@types/htmlhint": "1.1.2",
48
- "@types/jshint": "2.12.1",
49
- "@types/mocha": "9.1.0",
50
- "@types/mock-fs": "4.13.1",
51
- "@types/node": "17.0.23",
52
- "@types/sinon": "10.0.11",
53
- "@types/yargs": "17.0.10",
54
- "addons-linter": "5.0.0",
55
- "c8": "7.11.0",
56
- "coffeelint": "2.1.0",
57
- "csslint": "1.0.5",
58
- "doiuse": "4.4.1",
59
- "eslint": "8.12.0",
60
- "eslint-plugin-eslint-comments": "3.2.0",
61
- "eslint-plugin-import": "2.25.4",
62
- "eslint-plugin-jsdoc": "38.1.4",
63
- "eslint-plugin-mocha": "10.0.3",
64
- "eslint-plugin-no-unsanitized": "4.0.1",
65
- "eslint-plugin-node": "11.1.0",
66
- "eslint-plugin-promise": "6.0.0",
67
- "eslint-plugin-regexp": "1.6.0",
68
- "eslint-plugin-unicorn": "41.0.1",
69
- "flow-bin": "0.174.1",
70
- "htmlhint": "1.1.3",
71
- "htmllint": "0.8.0",
72
- "jshint": "2.13.4",
73
- "json-lint": "0.1.0",
74
- "jsonlint": "1.6.3",
75
- "jsonlint-mod": "1.7.6",
76
- "lesshint": "6.3.7",
77
- "markdownlint": "0.25.1",
78
- "mocha": "9.2.2",
79
- "mock-fs": "5.1.2",
80
- "purgecss": "4.1.3",
81
- "sinon": "13.0.1",
82
- "standard": "16.0.4",
83
- "standard-version": "9.3.2",
84
- "stylelint": "14.6.1",
85
- "typedoc": "0.22.13",
86
- "typescript": "4.6.3",
87
- "yaml-lint": "1.2.4"
88
- },
89
- "engines": {
90
- "node": ">=16.0.0"
91
- }
2
+ "name": "metalint",
3
+ "version": "0.11.1",
4
+ "description": "Un linter pour les gouverner tous.",
5
+ "keywords": [
6
+ "checker",
7
+ "lint",
8
+ "metalint",
9
+ "quality",
10
+ "static-analysis"
11
+ ],
12
+ "homepage": "https://github.com/regseb/metalint#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/regseb/metalint/issues",
15
+ "email": "regseb@gmail.com"
16
+ },
17
+ "license": "MIT",
18
+ "author": "Sébastien Règne <regseb@gmail.com> (https://github.com/regseb)",
19
+ "funding": "https://www.paypal.me/sebastienregne",
20
+ "files": [
21
+ "src/",
22
+ "types/"
23
+ ],
24
+ "main": "src/core/index.js",
25
+ "types": "types/index.d.ts",
26
+ "bin": "src/bin/index.js",
27
+ "repository": "regseb/metalint",
28
+ "type": "module",
29
+ "scripts": {
30
+ "lint": "src/bin/index.js",
31
+ "lint:fix": "src/bin/index.js --fix",
32
+ "lint:types": "tsc --project .tsconfig_lint.json",
33
+ "test": "npm run test:unit",
34
+ "test:unit": "mocha --config test/mocharc.json",
35
+ "test:coverage": "stryker run .stryker.config.js",
36
+ "jsdocs": "typedoc --tsconfig .tsconfig_jsdocs.json --out jsdocs/ src/core/",
37
+ "prepare": "tsc --project .tsconfig_types.json",
38
+ "release": "standard-version",
39
+ "clean": "node .script/clean.js"
40
+ },
41
+ "dependencies": {
42
+ "chalk": "5.2.0",
43
+ "yargs": "17.7.1"
44
+ },
45
+ "devDependencies": {
46
+ "@coffeelint/cli": "5.2.11",
47
+ "@prettier/plugin-xml": "2.2.0",
48
+ "@stryker-mutator/core": "6.4.1",
49
+ "@stryker-mutator/mocha-runner": "6.4.1",
50
+ "@types/debug": "4.1.7",
51
+ "@types/eslint": "8.21.1",
52
+ "@types/file-entry-cache": "5.0.2",
53
+ "@types/htmlhint": "1.1.2",
54
+ "@types/js-yaml": "4.0.5",
55
+ "@types/jshint": "2.12.1",
56
+ "@types/mocha": "10.0.1",
57
+ "@types/mock-fs": "4.13.1",
58
+ "@types/node": "18.14.6",
59
+ "@types/sinon": "10.0.13",
60
+ "@types/yargs": "17.0.22",
61
+ "addons-linter": "5.30.0",
62
+ "csslint": "1.0.5",
63
+ "doiuse": "4.4.1",
64
+ "eslint": "8.35.0",
65
+ "eslint-plugin-array-func": "3.1.8",
66
+ "eslint-plugin-eslint-comments": "3.2.0",
67
+ "eslint-plugin-import": "2.27.5",
68
+ "eslint-plugin-jsdoc": "40.0.1",
69
+ "eslint-plugin-mocha": "10.1.0",
70
+ "eslint-plugin-n": "15.6.1",
71
+ "eslint-plugin-no-unsanitized": "4.0.2",
72
+ "eslint-plugin-promise": "6.1.1",
73
+ "eslint-plugin-regexp": "1.12.0",
74
+ "eslint-plugin-unicorn": "46.0.0",
75
+ "flow-bin": "0.201.0",
76
+ "htmlhint": "1.1.4",
77
+ "htmllint": "0.8.0",
78
+ "jshint": "2.13.6",
79
+ "json-lint": "0.1.0",
80
+ "jsonlint": "1.6.3",
81
+ "jsonlint-mod": "1.7.6",
82
+ "lesshint": "6.3.7",
83
+ "markdownlint": "0.27.0",
84
+ "markuplint": "3.3.0",
85
+ "mocha": "10.2.0",
86
+ "mock-fs": "5.2.0",
87
+ "npm-package-json-lint": "6.4.0",
88
+ "prettier": "2.8.4",
89
+ "purgecss": "5.0.0",
90
+ "sinon": "15.0.1",
91
+ "standard": "17.0.0",
92
+ "standard-version": "9.5.0",
93
+ "stylelint": "15.2.0",
94
+ "typedoc": "0.23.26",
95
+ "typescript": "4.9.5",
96
+ "yaml-lint": "1.7.0"
97
+ },
98
+ "engines": {
99
+ "node": ">=18.12.0"
100
+ }
92
101
  }
package/src/bin/help.txt CHANGED
@@ -6,13 +6,14 @@ options courtes.
6
6
  -c, --config=CONFIG spécifier l'emplacement du fichier de configuration
7
7
  -f, --formatter=FORMATTER définir le formateur utilisé pour afficher les
8
8
  résultats
9
+ --fix corriger les fichiers
9
10
  -l, --level=NIVEAU définir le niveau de sévérité global
10
11
  -o, --output=OUTPUT spécifier le fichier de sortie où seront écrit les
11
12
  résultats
12
13
  -p, --patterns=PATRONS spécifier les patrons pour filtrer les fichiers qui
13
14
  seront analysés
14
- --help afficher l'aide et quitter
15
- --version afficher des informations de version et quitter
15
+ --help afficher l'aide et quitter
16
+ --version afficher des informations de version et quitter
16
17
 
17
18
  L'argument NIVEAU peut avoir comme valeur : off, fatal, error, warn ou info.
18
19
 
package/src/bin/index.js CHANGED
@@ -5,8 +5,8 @@ import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import yargs from "yargs";
7
7
  import glob from "../core/glob.js";
8
- import normalize from "../core/normalize.js";
9
8
  import metalint from "../core/index.js";
9
+ import normalize from "../core/normalize.js";
10
10
  import SEVERITY from "../core/severity.js";
11
11
 
12
12
  /**
@@ -14,51 +14,61 @@ import SEVERITY from "../core/severity.js";
14
14
  * @typedef {import("../types").Formatter} Formatter
15
15
  */
16
16
 
17
- /**
18
- * Résous un chemin relatif à partir du module.
19
- *
20
- * @param {string} specifier Le chemin relatif vers un fichier ou un répertoire.
21
- * @returns {Promise<string>} Une promesse contenant le chemin absolue vers le
22
- * fichier ou le répertoire.
23
- * @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
24
- */
25
- const resolve = function (specifier) {
26
- return Promise.resolve(fileURLToPath(new URL(specifier,
27
- import.meta.url).href));
28
- };
17
+ if (undefined === import.meta.resolve) {
18
+ /**
19
+ * Résous un chemin relatif à partir du module.
20
+ *
21
+ * @param {string} specifier Le chemin relatif vers un fichier ou un
22
+ * répertoire.
23
+ * @returns {Promise<string>} Une promesse contenant le chemin absolue vers
24
+ * le fichier ou le répertoire.
25
+ * @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
26
+ */
27
+ import.meta.resolve = (specifier) => {
28
+ return Promise.resolve(
29
+ fileURLToPath(new URL(specifier, import.meta.url).href),
30
+ );
31
+ };
32
+ }
29
33
 
30
- const argv = yargs(process.argv.slice(2)).options({
31
- c: {
32
- alias: "config",
33
- default: ".metalint/metalint.config.js",
34
- requiresArg: true,
35
- type: "string",
36
- },
37
- f: {
38
- alias: "formatter",
39
- requiresArg: true,
40
- type: "string",
41
- },
42
- l: {
43
- alias: "level",
44
- requiresArg: true,
45
- type: "string",
46
- },
47
- o: {
48
- alias: "output",
49
- requiresArg: true,
50
- type: "string",
51
- },
52
- p: {
53
- alias: "patterns",
54
- requiresArg: true,
55
- type: "array",
56
- },
57
- help: {
58
- alias: "help",
59
- type: "boolean",
60
- },
61
- }).help(false).argv;
34
+ const argv = yargs(process.argv.slice(2))
35
+ .options({
36
+ c: {
37
+ alias: "config",
38
+ default: ".metalint/metalint.config.js",
39
+ requiresArg: true,
40
+ type: "string",
41
+ },
42
+ f: {
43
+ alias: "formatter",
44
+ requiresArg: true,
45
+ type: "string",
46
+ },
47
+ fix: {
48
+ alias: "fix",
49
+ type: "boolean",
50
+ },
51
+ l: {
52
+ alias: "level",
53
+ requiresArg: true,
54
+ type: "string",
55
+ },
56
+ o: {
57
+ alias: "output",
58
+ requiresArg: true,
59
+ type: "string",
60
+ },
61
+ p: {
62
+ alias: "patterns",
63
+ requiresArg: true,
64
+ type: "array",
65
+ },
66
+ help: {
67
+ alias: "help",
68
+ type: "boolean",
69
+ },
70
+ })
71
+ .help(false).argv;
62
72
 
63
73
  /**
64
74
  * Vérifie (en appelant des linters) une liste de fichiers.
@@ -70,17 +80,18 @@ const argv = yargs(process.argv.slice(2)).options({
70
80
  * dossier <code>.metalint/</code>.
71
81
  * @param {Formatter[]} reporters La liste des rapporteurs utilisés pour
72
82
  * afficher les résultats.
73
- * @returns {Promise<?number>} La sévérité la plus élévée des résultats.
83
+ * @returns {Promise<number|undefined>} La sévérité la plus élévée des
84
+ * résultats.
74
85
  */
75
86
  const check = async function (files, checkers, root, reporters) {
76
- let severity = null;
87
+ let severity;
77
88
 
78
89
  const results = await metalint(files, checkers, root);
79
90
  for (const [file, notices] of Object.entries(results)) {
80
91
  // Déterminer la sévérité la plus élévée des résultats.
81
- if (null !== notices) {
92
+ if (undefined !== notices) {
82
93
  for (const notice of notices) {
83
- if (null === severity || severity > notice.severity) {
94
+ if (undefined === severity || severity > notice.severity) {
84
95
  severity = notice.severity;
85
96
  }
86
97
  }
@@ -98,7 +109,9 @@ const check = async function (files, checkers, root, reporters) {
98
109
  };
99
110
 
100
111
  if (argv.help) {
101
- process.stdout.write(fs.readFileSync(await resolve("./help.txt")));
112
+ process.stdout.write(
113
+ fs.readFileSync(await import.meta.resolve("./help.txt")),
114
+ );
102
115
  process.exit(0);
103
116
  }
104
117
 
@@ -117,20 +130,27 @@ while (!fs.existsSync(path.join(root, argv.config))) {
117
130
  try {
118
131
  // eslint-disable-next-line no-unsanitized/method
119
132
  const { default: config } = await import(path.join(root, argv.config));
120
- const { patterns, checkers, reporters } =
121
- await normalize(config,
122
- root,
123
- path.dirname(path.join(root, argv.config)),
124
- argv);
133
+ const { patterns, checkers, reporters } = await normalize(
134
+ config,
135
+ root,
136
+ path.dirname(path.join(root, argv.config)),
137
+ argv,
138
+ );
125
139
 
126
- const files = await glob.walk(argv._, patterns, root);
140
+ const bases = await Promise.resolve(argv._.map((a) => glob.normalize(a)));
141
+ const files = await glob.walk(bases, patterns, root);
127
142
 
128
143
  const severity = await check(files, checkers, root, reporters);
129
144
  let code;
130
145
  switch (severity) {
131
- case SEVERITY.FATAL: code = 2; break;
132
- case SEVERITY.ERROR: code = 1; break;
133
- default: code = 0;
146
+ case SEVERITY.FATAL:
147
+ code = 2;
148
+ break;
149
+ case SEVERITY.ERROR:
150
+ code = 1;
151
+ break;
152
+ default:
153
+ code = 0;
134
154
  }
135
155
  process.exit(code);
136
156
  } catch (err) {