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
|
18 | source) :
|
19 |
|
20 |
|
21 | <table>
|
22 | <tr>
|
23 | <th>Langage / Technologie</th>
|
24 | <th>Linters</th>
|
25 | </tr>
|
26 | <tr>
|
27 | <td>CoffeeScript</td>
|
28 | <td>
|
29 | <a title="@coffeelint/cli"
|
30 | href="https://www.npmjs.com/package/@coffeelint/cli">CoffeeLint</a>
|
31 | </td>
|
32 | </tr>
|
33 | <tr>
|
34 | <td>CSS</td>
|
35 | <td>
|
36 | <a title="csslint"
|
37 | href="https://www.npmjs.com/package/csslint">CSSLint</a>,
|
38 | <a title="doiuse" href="https://www.npmjs.com/package/doiuse">doiuse</a>,
|
39 | <a title="prettier"
|
40 | href="https://www.npmjs.com/package/prettier">Prettier</a>,
|
41 | <a title="purgecss"
|
42 | href="https://www.npmjs.com/package/purgecss">PurgeCSS</a>,
|
43 | <a title="stylelint"
|
44 | href="https://www.npmjs.com/package/stylelint">Stylelint</a>
|
45 | </td>
|
46 | </tr>
|
47 | <tr>
|
48 | <td>HTML</td>
|
49 | <td>
|
50 | <a title="htmlhint"
|
51 | href="https://www.npmjs.com/package/htmlhint">HTMLHint</a>,
|
52 | <a title="htmllint"
|
53 | href="https://www.npmjs.com/package/htmllint">htmllint</a>,
|
54 | <a title="markuplint"
|
55 | href="https://www.npmjs.com/package/markuplint">markuplint</a>,
|
56 | <a title="prettier"
|
57 | href="https://www.npmjs.com/package/prettier">Prettier</a>
|
58 | </td>
|
59 | </tr>
|
60 | <tr>
|
61 | <td>JavaScript</td>
|
62 | <td>
|
63 | <a title="eslint" href="https://www.npmjs.com/package/eslint">ESLint</a>,
|
64 | <a title="jshint" href="https://www.npmjs.com/package/jshint">JSHint</a>,
|
65 | <a title="standard"
|
66 | href="https://www.npmjs.com/package/standard">JavaScript Standard
|
67 | Style</a>,
|
68 | <a title="prettier"
|
69 | href="https://www.npmjs.com/package/prettier">Prettier</a>
|
70 | </td>
|
71 | </tr>
|
72 | <tr>
|
73 | <td>JSON</td>
|
74 | <td>
|
75 | <a title="@prantlf/jsonlint"
|
76 | href="https://www.npmjs.com/package/@prantlf/jsonlint">@prantlf/JSON
|
77 | Lint</a>,
|
78 | <a title="jsonlint-mod"
|
79 | href="https://www.npmjs.com/package/jsonlint-mod">JSON Lint (mod)</a>,
|
80 | <a title="prettier"
|
81 | href="https://www.npmjs.com/package/prettier">Prettier</a>
|
82 | </td>
|
83 | </tr>
|
84 | <tr>
|
85 | <td>Less</td>
|
86 | <td>
|
87 | <a title="prettier"
|
88 | href="https://www.npmjs.com/package/prettier">Prettier</a>,
|
89 | <a title="stylelint"
|
90 | href="https://www.npmjs.com/package/stylelint">Stylelint</a>
|
91 | </td>
|
92 | </tr>
|
93 | <tr>
|
94 | <td>Markdown</td>
|
95 | <td>
|
96 | <a title="markdownlint"
|
97 | href="https://www.npmjs.com/package/markdownlint">MarkdownLint</a>
|
98 | </td>
|
99 | </tr>
|
100 | <tr>
|
101 | <td>package.json</td>
|
102 | <td>
|
103 | <a title="npm-package-json-lint"
|
104 | href="https://www.npmjs.com/package/npm-package-json-lint"
|
105 | >npm-package-json-lint</a>
|
106 | </td>
|
107 | </tr>
|
108 | <tr>
|
109 | <td>SCSS</td>
|
110 | <td>
|
111 | <a title="prettier"
|
112 | href="https://www.npmjs.com/package/prettier">Prettier</a>,
|
113 | <a title="stylelint"
|
114 | href="https://www.npmjs.com/package/stylelint">Stylelint</a>
|
115 | </td>
|
116 | </tr>
|
117 | <tr>
|
118 | <td>SugarSS</td>
|
119 | <td>
|
120 | <a title="stylelint"
|
121 | href="https://www.npmjs.com/package/stylelint">Stylelint</a>
|
122 | </td>
|
123 | </tr>
|
124 | <tr>
|
125 | <td>WebExtension</td>
|
126 | <td>
|
127 | <a title="addons-linter"
|
128 | href="https://www.npmjs.com/package/addons-linter">Add-ons Linter</a>
|
129 | </td>
|
130 | </tr>
|
131 | <tr>
|
132 | <td>YAML</td>
|
133 | <td>
|
134 | <a title="yaml-lint"
|
135 | href="https://www.npmjs.com/package/yaml-lint">YAML Lint</a>,
|
136 | <a title="prettier"
|
137 | href="https://www.npmjs.com/package/prettier">Prettier</a>
|
138 | </td>
|
139 | </tr>
|
140 | </table>
|
141 |
|
142 |
|
143 | ## Installation
|
144 |
|
145 | Vous pouvez installer Metalint en utilisant [npm][link-npm] :
|
146 |
|
147 | ```Shell
|
148 | npm install --save-dev metalint
|
149 | ```
|
150 |
|
151 | ## Configuration
|
152 |
|
153 | Tous les fichiers de configuration sont à regrouper dans le répertoire
|
154 | `.metalint/` qui doit être placé à la racine du projet. Le fichier
|
155 | `metalint.config.js` export un objet JSON indiquant les linters à utiliser pour
|
156 | chaque fichier. Les autres fichiers contiennent les options spécifiques pour les
|
157 | linters.
|
158 |
|
159 | ## Exemple
|
160 |
|
161 | Dans cet exemple des fichiers de configuration, Metalint analyse les fichiers
|
162 | JavaScript (non-minifiés), HTML et CSS ; avec respectivement les linters ESLint,
|
163 | HTMLHint et Stylelint.
|
164 |
|
165 | ```JavaScript
|
166 | // .metalint/metalint.config.js
|
167 | export default {
|
168 | patterns: ["**", "!/.git/**", "!/node_modules/**"],
|
169 | checkers: [
|
170 | {
|
171 | patterns: ["*.js", "!*.min.js"],
|
172 | linters: "eslint",
|
173 | }, {
|
174 | patterns: "*.html",
|
175 | linters: "htmlhint",
|
176 | }, {
|
177 | patterns: "*.css",
|
178 | linters: "stylelint",
|
179 | },
|
180 | ],
|
181 | };
|
182 | ```
|
183 |
|
184 | ```JavaScript
|
185 | // .metalint/eslint.config.js
|
186 | export default {
|
187 | rules: {
|
188 | quotes: ["error", "double"],
|
189 | semi: ["error", "always"],
|
190 | },
|
191 | };
|
192 | ```
|
193 |
|
194 | ```JavaScript
|
195 | // .metalint/htmlhint.config.js
|
196 | export default {
|
197 | "attr-value-not-empty": false,
|
198 | };
|
199 | ```
|
200 |
|
201 | ```JavaScript
|
202 | // .metalint/stylelint.config.js
|
203 | export default {
|
204 | rules: {
|
205 | "color-no-invalid-hex": true,
|
206 | },
|
207 | };
|
208 | ```
|
209 |
|
210 | ## Intégration
|
211 |
|
212 | Après avoir installé Metalint et les linters dans votre projet npm, vous pouvez
|
213 | ajouter le script suivant dans votre `package.json` :
|
214 |
|
215 | ```JSON
|
216 | {
|
217 | "scripts": {
|
218 | "lint": "metalint"
|
219 | }
|
220 | }
|
221 | ```
|
222 |
|
223 | Metalint est maintenant utilisable avec la commande : `npm run lint`
|
224 |
|
225 | [img-npm]: https://img.shields.io/npm/dm/metalint?label=npm&logo=npm&logoColor=white
|
226 | [img-build]: https://img.shields.io/github/actions/workflow/status/regseb/metalint/ci.yml?branch=main&logo=github&logoColor=white
|
227 |
|
228 |
|
229 | https://github.com/simple-icons/simple-icons/pull/7388 -->
|
230 |
|
231 | [img-coverage]: https://img.shields.io/endpoint?label=coverage&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fregseb%2Fmetalint%2Fmain
|
232 | [img-semver]: https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&logoColor=white
|
233 | [link-npm]: https://www.npmjs.com/package/metalint
|
234 | [link-build]: https://github.com/regseb/metalint/actions/workflows/ci.yml?query=branch%3Amain
|
235 | [link-coverage]: https://dashboard.stryker-mutator.io/reports/github.com/regseb/metalint/main
|
236 | [link-semver]: https://semver.org/spec/v2.0.0.html "Semantic Versioning 2.0.0"
|