metalint 0.11.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 (63) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +67 -25
  3. package/package.json +99 -94
  4. package/src/bin/help.txt +3 -2
  5. package/src/bin/index.js +61 -48
  6. package/src/core/formatter/checkstyle.js +14 -11
  7. package/src/core/formatter/console.js +35 -17
  8. package/src/core/formatter/csv.js +6 -4
  9. package/src/core/formatter/github.js +14 -8
  10. package/src/core/formatter/json.js +11 -8
  11. package/src/core/formatter/unix.js +6 -3
  12. package/src/core/glob.js +76 -57
  13. package/src/core/index.js +19 -9
  14. package/src/core/normalize.js +202 -121
  15. package/src/core/severity.js +5 -3
  16. package/src/core/wrapper/addons-linter.js +46 -36
  17. package/src/core/wrapper/coffeelint.js +22 -17
  18. package/src/core/wrapper/csslint.js +27 -20
  19. package/src/core/wrapper/doiuse.js +28 -19
  20. package/src/core/wrapper/eslint.js +55 -38
  21. package/src/core/wrapper/flow-bin.js +17 -11
  22. package/src/core/wrapper/htmlhint.js +26 -19
  23. package/src/core/wrapper/htmllint.js +20 -14
  24. package/src/core/wrapper/jshint.js +28 -19
  25. package/src/core/wrapper/json-lint.js +25 -17
  26. package/src/core/wrapper/jsonlint-mod.js +22 -15
  27. package/src/core/wrapper/jsonlint.js +22 -15
  28. package/src/core/wrapper/lesshint.js +40 -30
  29. package/src/core/wrapper/markdownlint.js +28 -22
  30. package/src/core/wrapper/markuplint.js +31 -25
  31. package/src/core/wrapper/npm-package-json-lint.js +24 -16
  32. package/src/core/wrapper/prettier.js +77 -0
  33. package/src/core/wrapper/purgecss.js +33 -25
  34. package/src/core/wrapper/standard.js +42 -31
  35. package/src/core/wrapper/stylelint.js +32 -21
  36. package/src/core/wrapper/yaml-lint.js +28 -19
  37. package/src/types.d.ts +21 -19
  38. package/types/formatter/json.d.ts +2 -0
  39. package/types/formatter/unix.d.ts +2 -0
  40. package/types/glob.d.ts +4 -25
  41. package/types/wrapper/addons-linter.d.ts +3 -1
  42. package/types/wrapper/coffeelint.d.ts +3 -1
  43. package/types/wrapper/csslint.d.ts +3 -1
  44. package/types/wrapper/doiuse.d.ts +3 -1
  45. package/types/wrapper/eslint.d.ts +4 -1
  46. package/types/wrapper/flow-bin.d.ts +3 -1
  47. package/types/wrapper/htmlhint.d.ts +3 -1
  48. package/types/wrapper/htmllint.d.ts +3 -1
  49. package/types/wrapper/jshint.d.ts +3 -1
  50. package/types/wrapper/json-lint.d.ts +3 -1
  51. package/types/wrapper/jsonlint-mod.d.ts +3 -1
  52. package/types/wrapper/jsonlint.d.ts +3 -1
  53. package/types/wrapper/lesshint.d.ts +3 -1
  54. package/types/wrapper/markdownlint.d.ts +3 -1
  55. package/types/wrapper/markuplint.d.ts +3 -1
  56. package/types/wrapper/npm-package-json-lint.d.ts +3 -1
  57. package/types/wrapper/prettier.d.ts +5 -0
  58. package/types/wrapper/purgecss.d.ts +4 -1
  59. package/types/wrapper/standard.d.ts +3 -1
  60. package/types/wrapper/stylelint.d.ts +4 -1
  61. package/types/wrapper/yaml-lint.d.ts +3 -1
  62. package/src/core/wrapper/linthtml.js +0 -51
  63. package/types/wrapper/linthtml.d.ts +0 -2
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 :
@@ -24,8 +30,7 @@ ou des utilitaires selon le type de fichier :
24
30
  [PurgeCSS](https://regseb.github.io/metalint/user/linters/purgecss/) et
25
31
  [stylelint](https://regseb.github.io/metalint/user/linters/stylelint/) ;
26
32
  - HTML : [HTMLHint](https://regseb.github.io/metalint/user/linters/htmlhint/),
27
- [htmllint](https://regseb.github.io/metalint/user/linters/htmllint/),
28
- [linthtml](https://regseb.github.io/metalint/user/linters/linthtml/) et
33
+ [htmllint](https://regseb.github.io/metalint/user/linters/htmllint/) et
29
34
  [markuplint](https://regseb.github.io/metalint/user/linters/markuplint/) ;
30
35
  - JavaScript : [ESLint](https://regseb.github.io/metalint/user/linters/eslint/),
31
36
  [Flow](https://regseb.github.io/metalint/user/linters/flow-bin/),
@@ -37,8 +42,8 @@ ou des utilitaires selon le type de fichier :
37
42
  [JSON Lint
38
43
  (mod)](https://regseb.github.io/metalint/user/linters/jsonlint-mod/) ;
39
44
  - package.json (npm) :
40
- [npm-package-json-lint](
41
- https://regseb.github.io/metalint/user/linters/npm-package-json-lint/) ;
45
+ [npm-package-json-lint](https://regseb.github.io/metalint/user/linters/npm-package-json-lint/)
46
+ ;
42
47
  - Markdown :
43
48
  [MarkdownLint](https://regseb.github.io/metalint/user/linters/markdownlint/) ;
44
49
  - YAML : [YAML Lint](https://regseb.github.io/metalint/user/linters/yaml-lint/).
@@ -47,7 +52,7 @@ ou des utilitaires selon le type de fichier :
47
52
 
48
53
  Vous pouvez installer Metalint en utilisant [npm][link-npm] :
49
54
 
50
- ```shell
55
+ ```Shell
51
56
  npm install metalint --save-dev
52
57
  ```
53
58
 
@@ -55,17 +60,18 @@ npm install metalint --save-dev
55
60
 
56
61
  Tous les fichiers de configuration sont à regrouper dans le répertoire
57
62
  `.metalint/` qui doit être placé à la racine du projet. Le fichier
58
- `metalint.config.js` contient un objet JSON indiquant les linters à utiliser
59
- pour chaque fichier. Les autres fichiers contiennent les options spécifiques
60
- 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.
61
66
 
62
67
  ## Exemple
63
68
 
64
- Dans cet exemple du fichier de configuration `metalint.json`, Metalint analyse
65
- les fichiers JavaScript (non-minifiés), HTML et CSS ; avec respectivement les
66
- 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.
67
72
 
68
73
  ```JavaScript
74
+ // .metalint/metalint.config.js
69
75
  export default {
70
76
  patterns: ["!/.git/", "!/node_modules/", "**"],
71
77
  checkers: [
@@ -83,20 +89,56 @@ export default {
83
89
  };
84
90
  ```
85
91
 
86
- ## 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` :
87
122
 
88
- ```shell
89
- metalint
123
+ ```JSON
124
+ {
125
+ "scripts": {
126
+ "lint": "metalint"
127
+ }
128
+ }
90
129
  ```
91
130
 
92
- <!-- Ne pas ajouter les logos car la couleur du logo de npm n'est pas
93
- personnalisable. https://github.com/badges/shields/issues/6208 -->
94
- [img-npm]:https://img.shields.io/npm/dm/metalint?label=npm
95
- [img-build]:https://img.shields.io/github/workflow/status/regseb/metalint/CI
96
- [img-coverage]:https://img.shields.io/coveralls/github/regseb/metalint
97
- [img-semver]:https://img.shields.io/badge/semver-2.0.0-blue
98
-
99
- [link-npm]:https://www.npmjs.com/package/metalint
100
- [link-build]:https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
101
- [link-coverage]:https://coveralls.io/github/regseb/metalint
102
- [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,96 +1,101 @@
1
1
  {
2
- "name": "metalint",
3
- "version": "0.11.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
- "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:types": "tsc --project .tsconfig_lint.json",
32
- "test": "c8 mocha --config test/mocharc.json",
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
- "release": "standard-version",
37
- "clean": "node .script/clean.js"
38
- },
39
- "dependencies": {
40
- "chalk": "5.1.2",
41
- "yargs": "17.6.2"
42
- },
43
- "devDependencies": {
44
- "@coffeelint/cli": "5.2.11",
45
- "@linthtml/linthtml": "0.9.3",
46
- "@types/debug": "4.1.7",
47
- "@types/eslint": "8.4.10",
48
- "@types/file-entry-cache": "5.0.2",
49
- "@types/htmlhint": "1.1.2",
50
- "@types/js-yaml": "4.0.5",
51
- "@types/jshint": "2.12.1",
52
- "@types/mocha": "10.0.0",
53
- "@types/mock-fs": "4.13.1",
54
- "@types/node": "18.11.9",
55
- "@types/sinon": "10.0.13",
56
- "@types/yargs": "17.0.13",
57
- "addons-linter": "5.21.0",
58
- "c8": "7.12.0",
59
- "csslint": "1.0.5",
60
- "doiuse": "4.4.1",
61
- "eslint": "8.27.0",
62
- "eslint-plugin-eslint-comments": "3.2.0",
63
- "eslint-plugin-import": "2.26.0",
64
- "eslint-plugin-jsdoc": "39.6.2",
65
- "eslint-plugin-mocha": "10.1.0",
66
- "eslint-plugin-n": "15.5.1",
67
- "eslint-plugin-no-unsanitized": "4.0.1",
68
- "eslint-plugin-promise": "6.1.1",
69
- "eslint-plugin-regexp": "1.10.0",
70
- "eslint-plugin-unicorn": "44.0.2",
71
- "flow-bin": "0.193.0",
72
- "htmlhint": "1.1.4",
73
- "htmllint": "0.8.0",
74
- "jshint": "2.13.6",
75
- "json-lint": "0.1.0",
76
- "jsonlint": "1.6.3",
77
- "jsonlint-mod": "1.7.6",
78
- "lesshint": "6.3.7",
79
- "markdownlint": "0.26.2",
80
- "markuplint": "2.11.0",
81
- "mocha": "10.1.0",
82
- "mock-fs": "5.2.0",
83
- "npm-package-json-lint": "6.3.0",
84
- "purgecss": "5.0.0",
85
- "sinon": "14.0.2",
86
- "standard": "17.0.0",
87
- "standard-version": "9.5.0",
88
- "stylelint": "14.15.0",
89
- "typedoc": "0.23.21",
90
- "typescript": "4.8.4",
91
- "yaml-lint": "1.7.0"
92
- },
93
- "engines": {
94
- "node": ">=18.12.0"
95
- }
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
+ }
96
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
  /**
@@ -15,7 +15,6 @@ import SEVERITY from "../core/severity.js";
15
15
  */
16
16
 
17
17
  if (undefined === import.meta.resolve) {
18
-
19
18
  /**
20
19
  * Résous un chemin relatif à partir du module.
21
20
  *
@@ -26,43 +25,50 @@ if (undefined === import.meta.resolve) {
26
25
  * @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
27
26
  */
28
27
  import.meta.resolve = (specifier) => {
29
- return Promise.resolve(fileURLToPath(new URL(specifier,
30
- import.meta.url).href));
28
+ return Promise.resolve(
29
+ fileURLToPath(new URL(specifier, import.meta.url).href),
30
+ );
31
31
  };
32
32
  }
33
33
 
34
- const argv = yargs(process.argv.slice(2)).options({
35
- c: {
36
- alias: "config",
37
- default: ".metalint/metalint.config.js",
38
- requiresArg: true,
39
- type: "string",
40
- },
41
- f: {
42
- alias: "formatter",
43
- requiresArg: true,
44
- type: "string",
45
- },
46
- l: {
47
- alias: "level",
48
- requiresArg: true,
49
- type: "string",
50
- },
51
- o: {
52
- alias: "output",
53
- requiresArg: true,
54
- type: "string",
55
- },
56
- p: {
57
- alias: "patterns",
58
- requiresArg: true,
59
- type: "array",
60
- },
61
- help: {
62
- alias: "help",
63
- type: "boolean",
64
- },
65
- }).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;
66
72
 
67
73
  /**
68
74
  * Vérifie (en appelant des linters) une liste de fichiers.
@@ -103,9 +109,9 @@ const check = async function (files, checkers, root, reporters) {
103
109
  };
104
110
 
105
111
  if (argv.help) {
106
- process.stdout.write(fs.readFileSync(
107
- await import.meta.resolve("./help.txt"),
108
- ));
112
+ process.stdout.write(
113
+ fs.readFileSync(await import.meta.resolve("./help.txt")),
114
+ );
109
115
  process.exit(0);
110
116
  }
111
117
 
@@ -124,20 +130,27 @@ while (!fs.existsSync(path.join(root, argv.config))) {
124
130
  try {
125
131
  // eslint-disable-next-line no-unsanitized/method
126
132
  const { default: config } = await import(path.join(root, argv.config));
127
- const { patterns, checkers, reporters } =
128
- await normalize(config,
129
- root,
130
- path.dirname(path.join(root, argv.config)),
131
- argv);
133
+ const { patterns, checkers, reporters } = await normalize(
134
+ config,
135
+ root,
136
+ path.dirname(path.join(root, argv.config)),
137
+ argv,
138
+ );
132
139
 
133
- 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);
134
142
 
135
143
  const severity = await check(files, checkers, root, reporters);
136
144
  let code;
137
145
  switch (severity) {
138
- case SEVERITY.FATAL: code = 2; break;
139
- case SEVERITY.ERROR: code = 1; break;
140
- 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;
141
154
  }
142
155
  process.exit(code);
143
156
  } catch (err) {
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * @module
3
+ * @license MIT
4
+ * @author Sébastien Règne
3
5
  */
4
6
 
5
7
  import SEVERITY from "../severity.js";
@@ -18,15 +20,15 @@ import SEVERITY from "../severity.js";
18
20
  */
19
21
  const encode = function (input) {
20
22
  const ENTITIES = {
21
- "&": "&amp;",
22
- "<": "&lt;",
23
- ">": "&gt;",
24
- "'": "&apos;",
25
- "\"": "&quot;",
23
+ "&": "&amp;",
24
+ "<": "&lt;",
25
+ ">": "&gt;",
26
+ "'": "&apos;",
27
+ '"': "&quot;",
26
28
  };
27
29
  let output = input;
28
30
  for (const [character, entity] of Object.entries(ENTITIES)) {
29
- output = output.replace(new RegExp(character, "gu"), entity);
31
+ output = output.replaceAll(new RegExp(character, "gu"), entity);
30
32
  }
31
33
  return output;
32
34
  };
@@ -52,7 +54,6 @@ const shift = function (depth, writer, size) {
52
54
  * <strong>checkstyle</strong>.
53
55
  */
54
56
  export const Formatter = class {
55
-
56
57
  /**
57
58
  * Le niveau de sévérité minimum des notifications affichées.
58
59
  *
@@ -88,7 +89,7 @@ export const Formatter = class {
88
89
  * retour à la ligne.
89
90
  */
90
91
  constructor(level, writer, options) {
91
- this.#level = level;
92
+ this.#level = level;
92
93
  this.#writer = writer;
93
94
  this.#indent = options.indent ?? -1;
94
95
 
@@ -120,14 +121,16 @@ export const Formatter = class {
120
121
  if (0 !== notice.locations.length) {
121
122
  this.#writer.write(` line="${notice.locations[0].line}"`);
122
123
  if ("column" in notice.locations[0]) {
123
- this.#writer.write(` column="` +
124
- `${notice.locations[0].column}"`);
124
+ this.#writer.write(
125
+ ` column="${notice.locations[0].column}"`,
126
+ );
125
127
  }
126
128
  }
127
129
 
128
130
  this.#writer.write(` severity="`);
129
131
  switch (notice.severity) {
130
- case SEVERITY.FATAL: case SEVERITY.ERROR:
132
+ case SEVERITY.FATAL:
133
+ case SEVERITY.ERROR:
131
134
  this.#writer.write("error");
132
135
  break;
133
136
  case SEVERITY.WARN: