1 | # Metalint
|
2 |
|
3 |
|
4 |
|
5 | <img src="asset/logo.svg" align="right" alt="">
|
6 |
|
7 | [![npm][img-npm]][link-npm]
|
8 | [![build][img-build]][link-build]
|
9 | [![coverage][img-coverage]][link-coverage]
|
10 | [![semver][img-semver]][link-semver]
|
11 |
|
12 | > _Un linter pour les gouverner tous._
|
13 |
|
14 | ## Description
|
15 |
|
16 | **Metalint** est un outil pour analyser tous les fichiers de votre projet.
|
17 | L'analyse est déléguée à des linters (outils d'analyse statique de code source)
|
18 | ou des utilitaires selon le type de fichier :
|
19 |
|
20 | - _Générique_ :
|
21 | [Prettier](https://regseb.github.io/metalint/user/linters/prettier/) ;
|
22 | - WebExtension : [Add-ons
|
23 | Linter](https://regseb.github.io/metalint/user/linters/addons-linter/) ;
|
24 | - CoffeeScript :
|
25 | [CoffeeLint](https://regseb.github.io/metalint/user/linters/coffeelint/) ;
|
26 | - CSS (SCSS, Sass, Less) :
|
27 | [CSSLint](https://regseb.github.io/metalint/user/linters/csslint/),
|
28 | [doiuse](https://regseb.github.io/metalint/user/linters/doiuse/),
|
29 | [lesshint](https://regseb.github.io/metalint/user/linters/lesshint/),
|
30 | [PurgeCSS](https://regseb.github.io/metalint/user/linters/purgecss/) et
|
31 | [stylelint](https://regseb.github.io/metalint/user/linters/stylelint/) ;
|
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/) ;
|
35 | - JavaScript : [ESLint](https://regseb.github.io/metalint/user/linters/eslint/),
|
36 | [Flow](https://regseb.github.io/metalint/user/linters/flow-bin/),
|
37 | [JSHint](https://regseb.github.io/metalint/user/linters/jshint/) et
|
38 | [JavaScript Standard
|
39 | Style](https://regseb.github.io/metalint/user/linters/standard/) ;
|
40 | - JSON : [JSON-Lint](https://regseb.github.io/metalint/user/linters/json-lint/),
|
41 | [JSON Lint](https://regseb.github.io/metalint/user/linters/jsonlint/) et
|
42 | [JSON Lint
|
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 | ;
|
47 | - Markdown :
|
48 | [MarkdownLint](https://regseb.github.io/metalint/user/linters/markdownlint/) ;
|
49 | - YAML : [YAML Lint](https://regseb.github.io/metalint/user/linters/yaml-lint/).
|
50 |
|
51 | ## Installation
|
52 |
|
53 | Vous pouvez installer Metalint en utilisant [npm][link-npm] :
|
54 |
|
55 | ```Shell
|
56 | npm install metalint --save-dev
|
57 | ```
|
58 |
|
59 | ## Configuration
|
60 |
|
61 | Tous les fichiers de configuration sont à regrouper dans le répertoire
|
62 | `.metalint/` qui doit être placé à la racine du projet. Le fichier
|
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.
|
66 |
|
67 | ## Exemple
|
68 |
|
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.
|
72 |
|
73 | ```JavaScript
|
74 | // .metalint/metalint.config.js
|
75 | export default {
|
76 | patterns: ["!/.git/", "!/node_modules/", "**"],
|
77 | checkers: [
|
78 | {
|
79 | patterns: ["!*.min.js", "*.js"],
|
80 | linters: "eslint",
|
81 | }, {
|
82 | patterns: "*.html",
|
83 | linters: "htmlhint",
|
84 | }, {
|
85 | patterns: "*.css",
|
86 | linters: "stylelint",
|
87 | },
|
88 | ],
|
89 | };
|
90 | ```
|
91 |
|
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` :
|
122 |
|
123 | ```JSON
|
124 | {
|
125 | "scripts": {
|
126 | "lint": "metalint"
|
127 | }
|
128 | }
|
129 | ```
|
130 |
|
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 |
|
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"
|