linted 16.12.2-rc.0 → 16.12.2-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. package/.github/workflows/RELEASE.yml +35 -35
  2. package/.github/workflows/rc.yml +35 -35
  3. package/LICENSE +21 -21
  4. package/README.md +390 -390
  5. package/SECURITY.md +9 -9
  6. package/dist/imports/plugins.d.ts.map +1 -1
  7. package/dist/imports.d.ts.map +1 -1
  8. package/dist/rules/html/enable.d.ts +8 -0
  9. package/dist/rules/html/enable.d.ts.map +1 -0
  10. package/dist/rules/html/enable.js +15 -0
  11. package/dist/rules/html/enable.js.map +1 -0
  12. package/dist/rules/html/enable_recommended.d.ts +3 -0
  13. package/dist/rules/html/enable_recommended.d.ts.map +1 -0
  14. package/dist/rules/html/enable_recommended.js +8 -0
  15. package/dist/rules/html/enable_recommended.js.map +1 -0
  16. package/dist/rules/html.d.ts +8 -0
  17. package/dist/rules/html.d.ts.map +1 -0
  18. package/dist/rules/html.js +4 -0
  19. package/dist/rules/html.js.map +1 -0
  20. package/dist/rules/js/enable.d.ts +348 -0
  21. package/dist/rules/js/enable.d.ts.map +1 -0
  22. package/dist/rules/js/enable.js +496 -0
  23. package/dist/rules/js/enable.js.map +1 -0
  24. package/dist/rules/js/enable_stylistic.d.ts +420 -0
  25. package/dist/rules/js/enable_stylistic.d.ts.map +1 -0
  26. package/dist/rules/js/enable_stylistic.js +585 -0
  27. package/dist/rules/js/enable_stylistic.js.map +1 -0
  28. package/dist/rules/js.d.ts +765 -0
  29. package/dist/rules/js.d.ts.map +1 -0
  30. package/dist/rules/js.js +4 -0
  31. package/dist/rules/js.js.map +1 -0
  32. package/dist/rules/json/enable.d.ts +27 -0
  33. package/dist/rules/json/enable.d.ts.map +1 -0
  34. package/dist/rules/json/enable.js +31 -0
  35. package/dist/rules/json/enable.js.map +1 -0
  36. package/dist/rules/json/enable_x.d.ts.map +1 -1
  37. package/dist/rules/json/enable_x.js +48 -8
  38. package/dist/rules/json/enable_x.js.map +1 -1
  39. package/dist/rules/json.d.ts +74 -0
  40. package/dist/rules/json.d.ts.map +1 -0
  41. package/dist/rules/json.js +4 -0
  42. package/dist/rules/json.js.map +1 -0
  43. package/dist/rules/jsonc/override.d.ts.map +1 -1
  44. package/dist/rules/jsonc/override.js +12 -3
  45. package/dist/rules/jsonc/override.js.map +1 -1
  46. package/dist/rules/jsonc.d.ts +77 -0
  47. package/dist/rules/jsonc.d.ts.map +1 -0
  48. package/dist/rules/jsonc.js +4 -0
  49. package/dist/rules/jsonc.js.map +1 -0
  50. package/dist/rules/md/enable.d.ts +7 -0
  51. package/dist/rules/md/enable.d.ts.map +1 -0
  52. package/dist/rules/md/enable.js +14 -0
  53. package/dist/rules/md/enable.js.map +1 -0
  54. package/dist/rules/md.d.ts +7 -0
  55. package/dist/rules/md.d.ts.map +1 -0
  56. package/dist/rules/md.js +3 -0
  57. package/dist/rules/md.js.map +1 -0
  58. package/dist/rules/mocha/enable.d.ts +3 -0
  59. package/dist/rules/mocha/enable.d.ts.map +1 -0
  60. package/dist/rules/mocha/enable.js +3 -0
  61. package/dist/rules/mocha/enable.js.map +1 -0
  62. package/dist/rules/mocha/enable_recommended.d.ts +3 -0
  63. package/dist/rules/mocha/enable_recommended.d.ts.map +1 -0
  64. package/dist/rules/mocha/enable_recommended.js +8 -0
  65. package/dist/rules/mocha/enable_recommended.js.map +1 -0
  66. package/dist/rules/mocha.d.ts +8 -0
  67. package/dist/rules/mocha.d.ts.map +1 -0
  68. package/dist/rules/mocha.js +4 -0
  69. package/dist/rules/mocha.js.map +1 -0
  70. package/dist/rules/svelte/disable.d.ts +5 -0
  71. package/dist/rules/svelte/disable.d.ts.map +1 -0
  72. package/dist/rules/svelte/disable.js +8 -0
  73. package/dist/rules/svelte/disable.js.map +1 -0
  74. package/dist/rules/svelte/disable_js.d.ts.map +1 -1
  75. package/dist/rules/svelte/disable_js.js +8 -3
  76. package/dist/rules/svelte/disable_js.js.map +1 -1
  77. package/dist/rules/svelte/disable_ts.d.ts.map +1 -1
  78. package/dist/rules/svelte/disable_ts.js +8 -3
  79. package/dist/rules/svelte/disable_ts.js.map +1 -1
  80. package/dist/rules/svelte/enable.d.ts +126 -0
  81. package/dist/rules/svelte/enable.d.ts.map +1 -0
  82. package/dist/rules/svelte/enable.js +190 -0
  83. package/dist/rules/svelte/enable.js.map +1 -0
  84. package/dist/rules/svelte/enable_x.d.ts.map +1 -1
  85. package/dist/rules/svelte/enable_x.js +15 -3
  86. package/dist/rules/svelte/enable_x.js.map +1 -1
  87. package/dist/rules/svelte.d.ts +1269 -0
  88. package/dist/rules/svelte.d.ts.map +1 -0
  89. package/dist/rules/svelte.js +15 -0
  90. package/dist/rules/svelte.js.map +1 -0
  91. package/dist/rules/ts/disable.d.ts +18 -0
  92. package/dist/rules/ts/disable.d.ts.map +1 -0
  93. package/dist/rules/ts/disable.js +21 -0
  94. package/dist/rules/ts/disable.js.map +1 -0
  95. package/dist/rules/ts/disable_x.d.ts.map +1 -1
  96. package/dist/rules/ts/disable_x.js +1 -2
  97. package/dist/rules/ts/disable_x.js.map +1 -1
  98. package/dist/rules/ts/enable.d.ts +262 -0
  99. package/dist/rules/ts/enable.d.ts.map +1 -0
  100. package/dist/rules/ts/enable.js +503 -0
  101. package/dist/rules/ts/enable.js.map +1 -0
  102. package/dist/rules/ts/enable_x.d.ts.map +1 -1
  103. package/dist/rules/ts/enable_x.js +32 -5
  104. package/dist/rules/ts/enable_x.js.map +1 -1
  105. package/dist/rules/ts.d.ts +1133 -0
  106. package/dist/rules/ts.d.ts.map +1 -0
  107. package/dist/rules/ts.js +13 -0
  108. package/dist/rules/ts.js.map +1 -0
  109. package/dist/rules/yml/enable.d.ts +39 -0
  110. package/dist/rules/yml/enable.d.ts.map +1 -0
  111. package/dist/rules/yml/enable.js +60 -0
  112. package/dist/rules/yml/enable.js.map +1 -0
  113. package/dist/rules/yml/enable_x.d.ts.map +1 -1
  114. package/dist/rules/yml/enable_x.js +57 -9
  115. package/dist/rules/yml/enable_x.js.map +1 -1
  116. package/dist/rules/yml.d.ts +73 -0
  117. package/dist/rules/yml.d.ts.map +1 -0
  118. package/dist/rules/yml.js +4 -0
  119. package/dist/rules/yml.js.map +1 -0
  120. package/dist/rules.d.ts +75 -75
  121. package/dist/rules.js +9 -9
  122. package/dist/rules.js.map +1 -1
  123. package/eslint.config.js +3 -3
  124. package/package.json +99 -99
  125. package/src/files/html.ts +1 -1
  126. package/src/files/js.ts +1 -1
  127. package/src/files/json.ts +1 -1
  128. package/src/files/jsonc.ts +4 -4
  129. package/src/files/md.ts +1 -1
  130. package/src/files/mocha.ts +1 -1
  131. package/src/files/svelte.ts +1 -1
  132. package/src/files/ts.ts +5 -5
  133. package/src/files/yml.ts +5 -5
  134. package/src/files.ts +22 -22
  135. package/src/imports/parsers.ts +15 -15
  136. package/src/imports/plugins.ts +19 -19
  137. package/src/imports.ts +8 -8
  138. package/src/index.ts +36 -36
  139. package/src/rules/_strings/id.ts +18 -18
  140. package/src/rules/_strings/level.ts +6 -6
  141. package/src/rules/_strings/state.ts +56 -56
  142. package/src/rules/_strings.ts +6 -6
  143. package/src/rules/html/enable.ts +16 -0
  144. package/src/rules/html/enable_recommended.ts +9 -0
  145. package/src/rules/html.ts +4 -0
  146. package/src/rules/js/enable.ts +524 -0
  147. package/src/rules/js/enable_stylistic.ts +608 -0
  148. package/src/rules/js.ts +4 -0
  149. package/src/rules/json/{_enable.ts → enable.ts} +33 -35
  150. package/src/rules/json/enable_x.ts +89 -50
  151. package/src/rules/{_json.ts → json.ts} +4 -4
  152. package/src/rules/jsonc/override.ts +16 -9
  153. package/src/rules/{_jsonc.ts → jsonc.ts} +4 -4
  154. package/src/rules/md/enable.ts +15 -0
  155. package/src/rules/md.ts +3 -0
  156. package/src/rules/mocha/enable.ts +3 -0
  157. package/src/rules/mocha/enable_recommended.ts +9 -0
  158. package/src/rules/mocha.ts +4 -0
  159. package/src/rules/svelte/disable.ts +9 -0
  160. package/src/rules/svelte/disable_js.ts +11 -7
  161. package/src/rules/svelte/disable_ts.ts +9 -5
  162. package/src/rules/svelte/{_enable.ts → enable.ts} +228 -129
  163. package/src/rules/svelte/enable_x.ts +20 -9
  164. package/src/rules/{_svelte.ts → svelte.ts} +15 -15
  165. package/src/rules/ts/{disable_compiler.ts → disable.ts} +22 -23
  166. package/src/rules/ts/disable_x.ts +32 -36
  167. package/src/rules/ts/{_enable.ts → enable.ts} +549 -406
  168. package/src/rules/ts/enable_x.ts +115 -90
  169. package/src/rules/{_ts.ts → ts.ts} +13 -13
  170. package/src/rules/yml/{_enable.ts → enable.ts} +64 -33
  171. package/src/rules/yml/enable_x.ts +68 -21
  172. package/src/rules/{_yml.ts → yml.ts} +4 -4
  173. package/src/rules.ts +22 -22
  174. package/tsconfig.json +161 -161
  175. package/types/markdownlint/index.d.ts +3 -3
  176. package/types/markdownlint/parser.d.ts +9 -9
  177. package/types/mocha/index.d.ts +8 -8
  178. package/src/rules/_html.ts +0 -4
  179. package/src/rules/_js.ts +0 -4
  180. package/src/rules/_md.ts +0 -3
  181. package/src/rules/_mocha.ts +0 -4
  182. package/src/rules/html/_enable.ts +0 -13
  183. package/src/rules/html/_recommended.ts +0 -7
  184. package/src/rules/js/_enable.ts +0 -287
  185. package/src/rules/js/stylistic.ts +0 -294
  186. package/src/rules/md/_enable.ts +0 -14
  187. package/src/rules/mocha/_enable.ts +0 -5
  188. package/src/rules/mocha/_recommended.ts +0 -7
  189. package/src/rules/svelte/disable_x.ts +0 -8
package/README.md CHANGED
@@ -1,390 +1,390 @@
1
- # [`linted`](https://www.npmjs.com/package/linted)
2
-
3
- [![NPM Publish (RELEASE)](https://github.com/jimmy-zhening-luo/linted/actions/workflows/RELEASE.yml/badge.svg)](https://github.com/jimmy-zhening-luo/linted/actions/workflows/RELEASE.yml)
4
-
5
- ___DO NOT USE - DOCUMENTATION IS SIGNIFICANTLY OUTDATED AS OF AUGUST 4, 2024___
6
-
7
- [ESLint](https://eslint.org) mono-plugin bundler with strict, opinionated defaults for (Stylistic) JavaScript, TypeScript, Svelte, HTML, Tailwind/CSS, JSON, JSONC, YAML, and Mocha.
8
-
9
- 1. [Languages](#languages)
10
- 2. [Features](#features)
11
- 3. [Limitation](#limitation)
12
- 4. [Install](#install)
13
- 5. [Roadmap](#roadmap)
14
- 6. [Rule Logic (Advanced)](#rule-logic-advanced)
15
-
16
- ## Languages
17
-
18
- ### Web
19
-
20
- - __[JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript):__ [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
21
- - __[TypeScript](https://www.typescriptlang.org):__ [`@typescript-eslint`](https://typescript-eslint.io/) + [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
22
- - __[Svelte](https://svelte.dev):__ [`eslint-plugin-svelte`](https://sveltejs.github.io/eslint-plugin-svelte/) + [`@typescript-eslint`](https://typescript-eslint.io/) + [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
23
- - __[HTML](https://developer.mozilla.org/en-US/docs/Web/HTML):__ [`@html-eslint`](https://html-eslint.org/)
24
-
25
- ### Data
26
-
27
- - __[JSON](https://json.org) & [JSONC](https://code.visualstudio.com/docs/languages/json#_json-with-comments):__ [`eslint-plugin-jsonc`](https://ota-meshi.github.io/eslint-plugin-jsonc/)
28
- - __[YAML](https://redhat.com/en/topics/automation/what-is-yaml):__ [`eslint-plugin-yml`](https://ota-meshi.github.io/eslint-plugin-yml/)
29
-
30
- ### Library
31
-
32
- - __[Mocha](https://mochajs.org/):__ [`eslint-plugin-mocha`](https://github.com/lo1tuma/eslint-plugin-mocha) + [`@typescript-eslint`](https://typescript-eslint.io/) + [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
33
-
34
- ### Text
35
-
36
- - __[Markdown](https://en.wikipedia.org/wiki/Markdown) ([GitHub Flavored Markdown](https://github.github.com/gfm/) & [CommonMark](https://commonmark.org)):__ [`eslint-plugin-markdownlint`](https://gitlab.com/pawelbbdrozd/eslint-plugin-markdownlint/-/blob/main/README.md) <- bad plugin, check it out and find out why. still mad at wasting my time on this gitlab-hosted piece of shit. Probably gonna deprecate it out of spite
37
-
38
- <br />
39
-
40
- _See language support __[roadmap](#roadmap).___
41
-
42
- ## Features
43
-
44
- ### Zero-Dependency
45
-
46
- No need to install 17 plugins and 12 parsers: each language's latest plugin is bundled and configured.
47
-
48
- ### Zero-Config
49
-
50
- No need to remember each plugin's `parserOptions`; you won't have to do _this_ just to enable Svelte linting:
51
-
52
- ```javascript
53
- // lint TypeScript blocks in Svelte
54
- plugins: {
55
- "@stylistic": stylistic,
56
- "@typescript-eslint": ts,
57
- svelte,
58
- },
59
- languageOptions: {
60
- ecmaVersion: "latest",
61
- sourceType: "module",
62
- parser: svelteParser,
63
- parserOptions: {
64
- parser: tsParser,
65
- ecmaVersion: "latest",
66
- sourceType: "module",
67
- project: "tsconfig.json",
68
- extraFileExtensions: [".svelte"],
69
- },
70
- },
71
- processor: "svelte/svelte",
72
- ```
73
-
74
- ### Zero-Arugment API
75
-
76
- ```javascript
77
- linted();
78
- ```
79
-
80
- ### Two-Statement `eslint.config.js`
81
-
82
- ```javascript
83
- import linted from "linted";
84
-
85
- export default linted();
86
- ```
87
-
88
- ### Total Control via Optional Arguments
89
-
90
- ___WIP for v14.1, currently inaccurate___.
91
-
92
- - `includes` (scoped [`glob patterns`](https://code.visualstudio.com/docs/editor/glob-patterns))
93
- - `ignores` (global [`glob patterns`](https://code.visualstudio.com/docs/editor/glob-patterns) and other options)
94
- - `overrides` (scoped rule statements)
95
-
96
- #### `includes` _(Scoped)_
97
-
98
- ```javascript
99
- import linted from "linted";
100
-
101
- linted(
102
- {
103
- /** includes **/
104
- js: [
105
- "scripts/**/*/.{js,mjs}",
106
- "*.config.js",
107
- ], /* example: array of glob patterns to lint using JavaScript rules */
108
- ts: [
109
- "src/**/*.ts",
110
- "*.config.ts",
111
- ],
112
-
113
- // svelte: [],
114
- // html: [],
115
-
116
- /* ...json, jsonc, yml, */
117
- },
118
- )
119
- ```
120
-
121
- #### `ignores` _(Global)_
122
-
123
- ```javascript
124
- import linted from "linted";
125
-
126
- linted(
127
- { /** includes **/ },
128
- {
129
- /** ignores **/
130
- gitignore: true, /* (default) never lint any git-ignored file */
131
- ignoreArtifacts: true, /* (default) never lint "**/*/package-lock.json" */
132
- global: [], /* array of glob patterns to never lint */
133
- },
134
- )
135
- ```
136
-
137
- #### `overrides` _(Scoped)_
138
-
139
- ```javascript
140
- linted(
141
- { /** includes **/ },
142
- { /** ignores **/ },
143
- {
144
- /** overrides **/
145
- overrideJs: {}, /* js rule overrides */
146
- overrideTs: {
147
- /* Overrides apply to `ts` scope,
148
- * but NOT to `js` scope,
149
- * NOR to `svelte` scope.
150
- */
151
- "no-unused-vars": "off", /* example: ESLint base rule */
152
- "@typescript-eslint/indent": "warn", /* example: TypeScript plugin rule */
153
- }, /* js rule overrides */
154
-
155
- /* ...overrideTs, overrideSvelte, overrideHtml, overrideJson, overrideJsonc, overrideYml, */
156
- },
157
- )
158
- ```
159
-
160
- ## Limitation
161
-
162
- In __TypeScript__ projects, [`skipLibCheck`](https://www.typescriptlang.org/tsconfig/#skipLibCheck) must be `true`.
163
-
164
- ### Enable `skipLibCheck`
165
-
166
- By default, `skipLibCheck` is `false`. To set it to `true`:
167
-
168
- #### `tsconfig.json`
169
-
170
- ```jsonc
171
- {
172
- "compilerOptions": {
173
- "skipLibCheck": true,
174
- },
175
- }
176
- ```
177
-
178
- #### _...or_ `tsc` CLI option
179
-
180
- ```bash
181
- tsc --skipLibCheck
182
- ```
183
-
184
- ## Install
185
-
186
- 1. Install [`eslint`](https://www.npmjs.com/package/eslint) and [`linted`](https://www.npmjs.com/package/linted).
187
-
188
- ```bash
189
- npm i -D eslint@^8.57 linted
190
- ```
191
-
192
- 2. Create `eslint.config.js` in your project root.
193
-
194
- 3. In `eslint.config.js`:
195
- - Import function `linted`.
196
-
197
- ```javascript
198
- import linted from "linted";
199
- ```
200
-
201
- - Export `linted` with optional [arguments](#total-control-via-optional-arguments):
202
-
203
- ```javascript
204
- import linted from "linted";
205
-
206
- export default linted(
207
- // ...
208
- );
209
- ```
210
-
211
- ___
212
-
213
- ## Roadmap
214
-
215
- ### v11
216
-
217
- #### Mocha
218
-
219
- - Mocha
220
-
221
- #### Tailwind PostCSS
222
-
223
- - [Tailwind](https://github.com/francoismassart/eslint-plugin-tailwindcss)
224
-
225
- - [CSS](https://ota-meshi.github.io/eslint-plugin-css/)
226
-
227
- #### HTML Connectors
228
-
229
- - [Embedded TypeScript](https://github.com/BenoitZugmeyer/eslint-plugin-html)
230
-
231
- - Embedded CSS
232
-
233
- - Svelte Interaction TBD
234
-
235
- - .svelte-embedded HTML (on top of Svelte HTML rules)
236
-
237
- - .html files in Svelte projects (e.g. title not required)
238
-
239
- - Should Svelte-Linter handle all .html / HTML-embedded linting for Svelte projects, and HTML-Linter only handles non-Svelte projects?
240
-
241
- #### JSON (Custom Schema Validation)
242
-
243
- - [JSON Custom Schema Validation](https://github.com/ota-meshi/eslint-plugin-json-schema-validator)
244
-
245
- ___
246
-
247
- ## Rule Logic (Advanced)
248
-
249
- ### What is `scope`?
250
-
251
- Each `scope` maps to a unique `language`:
252
-
253
- - __`js`:__ `JavaScript`
254
-
255
- - __`ts`:__ `TypeScript`
256
-
257
- - __`svelte`:__ `Svelte`
258
-
259
- - __`html`:__ `HTML`
260
-
261
- - __`json`:__ `JSON`
262
-
263
- - __`jsonc`:__ `JSONC`
264
-
265
- - __`yml`:__ `YAML`
266
-
267
- ### Rules
268
-
269
- Each `scope` supports:
270
-
271
- - all base ESLint rules
272
-
273
- - all rules from its `language`'s [__plugins__](#languages)
274
-
275
- #### Default Rules
276
-
277
- - Each `language` has a set of default rules.
278
-
279
- #### Language-Aggregate `scope`
280
-
281
- A `language` can be an extension of or depend on another `language`.
282
-
283
- For example:
284
-
285
- - TypeScript extends JavaScript
286
-
287
- - Svelte depends on TypeScript (which extends JavaScript)
288
-
289
- For such a `language`, its `scope`'s default rules are aggregated with the default rules of extended or consumed `language`s by `scope` precedence:
290
-
291
- - __`js`:__ `js`
292
-
293
- - __`ts`:__ `js` < `ts`
294
-
295
- - __`svelte`:__ `js` < `ts` < `svelte`
296
-
297
- - __`html`:__ `html`
298
-
299
- - __`json`:__ `json`
300
-
301
- - __`jsonc`:__ `json` < `jsonc`
302
-
303
- - __`yml`:__ `yml`
304
-
305
- ### Files
306
-
307
- #### Global Ignores
308
-
309
- ##### `.gitignore`
310
-
311
- By default, `linted` ignores all files in `.gitignore`. This behavior can be disabled.
312
-
313
- ##### `package-lock.json`
314
-
315
- `**/*.package-lock.json` is always skipped. _This cannot be overriden._
316
-
317
- ##### `ignores`
318
-
319
- Additional glob patterns supplied if matched by a file will skip linting that file, even if a scope pattern matches the file.
320
-
321
- #### Scoped Includes
322
-
323
- Files specified in `scope` are appended to the following default files:
324
-
325
- ```javascript
326
- {
327
- js: [
328
- "{src,static}/**/*.{js,mjs,cjs}",
329
- "*.{js,mjs,cjs}",
330
- ],
331
- ts: [
332
- "{src,static}/**/*.{ts,mts,cts}",
333
- "*.{ts,mts,cts}",
334
- ],
335
- svelte: ["{src,static}/**/*.svelte"],
336
- html: [
337
- "{src,static}/**/*.html",
338
- "*.html",
339
- ],
340
- json: [
341
- "{src,static}/**/*.json",
342
- "*.json",
343
- ],
344
- jsonc: [
345
- "tsconfig.json",
346
- "{src,static}/**/*.jsonc",
347
- "*.jsonc",
348
- ],
349
- yml: [
350
- ".github/workflows/*.{yml,yaml}",
351
- "{src,static}/**/*.{yml,yaml}",
352
- "*.{yml,yaml}",
353
- ],
354
- },
355
- ```
356
-
357
- #### Scope Conflict
358
-
359
- - If a given file matches more than one `scope` glob, then the set of all matching `scope`s' rules are applied to the file.
360
-
361
- - If any rule is specified in more than one `scope` matching a given file, the specifies a rule, then the highest-precedence `scope`'s rule specification wins.
362
-
363
- ##### Scope Precedence (low to high)
364
-
365
- ```bash
366
- js
367
- ts
368
- svelte
369
- html
370
- json
371
- jsonc
372
- yml
373
- ignores (global)
374
- ```
375
-
376
- ### Override
377
-
378
- Overrides are per-__scope.__
379
-
380
- #### Example
381
-
382
- `overrideTs` rules apply to files which:
383
-
384
- - ✅ ONLY match scope `ts`.
385
-
386
- - ✅ match scope `ts` and any number of lower precedence scopes (e.g. `js`).
387
-
388
- `overrideTs` rules do __NOT__ apply to files which:
389
-
390
- - ❌ match scope `ts` and at least one higher precedence scope (e.g. `svelte`), even if the higher precedence scope includes `ts` language default rules (e.g. `svelte` includes `ts` default rules, but NOT `overrideTs` rules).
1
+ # [`linted`](https://www.npmjs.com/package/linted)
2
+
3
+ [![NPM Publish (RELEASE)](https://github.com/jimmy-zhening-luo/linted/actions/workflows/RELEASE.yml/badge.svg)](https://github.com/jimmy-zhening-luo/linted/actions/workflows/RELEASE.yml)
4
+
5
+ ___DO NOT USE - DOCUMENTATION IS SIGNIFICANTLY OUTDATED AS OF AUGUST 4, 2024___
6
+
7
+ [ESLint](https://eslint.org) mono-plugin bundler with strict, opinionated defaults for (Stylistic) JavaScript, TypeScript, Svelte, HTML, Tailwind/CSS, JSON, JSONC, YAML, and Mocha.
8
+
9
+ 1. [Languages](#languages)
10
+ 2. [Features](#features)
11
+ 3. [Limitation](#limitation)
12
+ 4. [Install](#install)
13
+ 5. [Roadmap](#roadmap)
14
+ 6. [Rule Logic (Advanced)](#rule-logic-advanced)
15
+
16
+ ## Languages
17
+
18
+ ### Web
19
+
20
+ - __[JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript):__ [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
21
+ - __[TypeScript](https://www.typescriptlang.org):__ [`@typescript-eslint`](https://typescript-eslint.io/) + [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
22
+ - __[Svelte](https://svelte.dev):__ [`eslint-plugin-svelte`](https://sveltejs.github.io/eslint-plugin-svelte/) + [`@typescript-eslint`](https://typescript-eslint.io/) + [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
23
+ - __[HTML](https://developer.mozilla.org/en-US/docs/Web/HTML):__ [`@html-eslint`](https://html-eslint.org/)
24
+
25
+ ### Data
26
+
27
+ - __[JSON](https://json.org) & [JSONC](https://code.visualstudio.com/docs/languages/json#_json-with-comments):__ [`eslint-plugin-jsonc`](https://ota-meshi.github.io/eslint-plugin-jsonc/)
28
+ - __[YAML](https://redhat.com/en/topics/automation/what-is-yaml):__ [`eslint-plugin-yml`](https://ota-meshi.github.io/eslint-plugin-yml/)
29
+
30
+ ### Library
31
+
32
+ - __[Mocha](https://mochajs.org/):__ [`eslint-plugin-mocha`](https://github.com/lo1tuma/eslint-plugin-mocha) + [`@typescript-eslint`](https://typescript-eslint.io/) + [`@stylistic`](https://eslint.style) + [`eslint`](https://eslint.org)
33
+
34
+ ### Text
35
+
36
+ - __[Markdown](https://en.wikipedia.org/wiki/Markdown) ([GitHub Flavored Markdown](https://github.github.com/gfm/) & [CommonMark](https://commonmark.org)):__ [`eslint-plugin-markdownlint`](https://gitlab.com/pawelbbdrozd/eslint-plugin-markdownlint/-/blob/main/README.md) <- bad plugin, check it out and find out why. still mad at wasting my time on this gitlab-hosted piece of shit. Probably gonna deprecate it out of spite
37
+
38
+ <br />
39
+
40
+ _See language support __[roadmap](#roadmap).___
41
+
42
+ ## Features
43
+
44
+ ### Zero-Dependency
45
+
46
+ No need to install 17 plugins and 12 parsers: each language's latest plugin is bundled and configured.
47
+
48
+ ### Zero-Config
49
+
50
+ No need to remember each plugin's `parserOptions`; you won't have to do _this_ just to enable Svelte linting:
51
+
52
+ ```javascript
53
+ // lint TypeScript blocks in Svelte
54
+ plugins: {
55
+ "@stylistic": stylistic,
56
+ "@typescript-eslint": ts,
57
+ svelte,
58
+ },
59
+ languageOptions: {
60
+ ecmaVersion: "latest",
61
+ sourceType: "module",
62
+ parser: svelteParser,
63
+ parserOptions: {
64
+ parser: tsParser,
65
+ ecmaVersion: "latest",
66
+ sourceType: "module",
67
+ project: "tsconfig.json",
68
+ extraFileExtensions: [".svelte"],
69
+ },
70
+ },
71
+ processor: "svelte/svelte",
72
+ ```
73
+
74
+ ### Zero-Arugment API
75
+
76
+ ```javascript
77
+ linted();
78
+ ```
79
+
80
+ ### Two-Statement `eslint.config.js`
81
+
82
+ ```javascript
83
+ import linted from "linted";
84
+
85
+ export default linted();
86
+ ```
87
+
88
+ ### Total Control via Optional Arguments
89
+
90
+ ___WIP for v14.1, currently inaccurate___.
91
+
92
+ - `includes` (scoped [`glob patterns`](https://code.visualstudio.com/docs/editor/glob-patterns))
93
+ - `ignores` (global [`glob patterns`](https://code.visualstudio.com/docs/editor/glob-patterns) and other options)
94
+ - `overrides` (scoped rule statements)
95
+
96
+ #### `includes` _(Scoped)_
97
+
98
+ ```javascript
99
+ import linted from "linted";
100
+
101
+ linted(
102
+ {
103
+ /** includes **/
104
+ js: [
105
+ "scripts/**/*/.{js,mjs}",
106
+ "*.config.js",
107
+ ], /* example: array of glob patterns to lint using JavaScript rules */
108
+ ts: [
109
+ "src/**/*.ts",
110
+ "*.config.ts",
111
+ ],
112
+
113
+ // svelte: [],
114
+ // html: [],
115
+
116
+ /* ...json, jsonc, yml, */
117
+ },
118
+ )
119
+ ```
120
+
121
+ #### `ignores` _(Global)_
122
+
123
+ ```javascript
124
+ import linted from "linted";
125
+
126
+ linted(
127
+ { /** includes **/ },
128
+ {
129
+ /** ignores **/
130
+ gitignore: true, /* (default) never lint any git-ignored file */
131
+ ignoreArtifacts: true, /* (default) never lint "**/*/package-lock.json" */
132
+ global: [], /* array of glob patterns to never lint */
133
+ },
134
+ )
135
+ ```
136
+
137
+ #### `overrides` _(Scoped)_
138
+
139
+ ```javascript
140
+ linted(
141
+ { /** includes **/ },
142
+ { /** ignores **/ },
143
+ {
144
+ /** overrides **/
145
+ overrideJs: {}, /* js rule overrides */
146
+ overrideTs: {
147
+ /* Overrides apply to `ts` scope,
148
+ * but NOT to `js` scope,
149
+ * NOR to `svelte` scope.
150
+ */
151
+ "no-unused-vars": "off", /* example: ESLint base rule */
152
+ "@typescript-eslint/indent": "warn", /* example: TypeScript plugin rule */
153
+ }, /* js rule overrides */
154
+
155
+ /* ...overrideTs, overrideSvelte, overrideHtml, overrideJson, overrideJsonc, overrideYml, */
156
+ },
157
+ )
158
+ ```
159
+
160
+ ## Limitation
161
+
162
+ In __TypeScript__ projects, [`skipLibCheck`](https://www.typescriptlang.org/tsconfig/#skipLibCheck) must be `true`.
163
+
164
+ ### Enable `skipLibCheck`
165
+
166
+ By default, `skipLibCheck` is `false`. To set it to `true`:
167
+
168
+ #### `tsconfig.json`
169
+
170
+ ```jsonc
171
+ {
172
+ "compilerOptions": {
173
+ "skipLibCheck": true,
174
+ },
175
+ }
176
+ ```
177
+
178
+ #### _...or_ `tsc` CLI option
179
+
180
+ ```bash
181
+ tsc --skipLibCheck
182
+ ```
183
+
184
+ ## Install
185
+
186
+ 1. Install [`eslint`](https://www.npmjs.com/package/eslint) and [`linted`](https://www.npmjs.com/package/linted).
187
+
188
+ ```bash
189
+ npm i -D eslint@^8.57 linted
190
+ ```
191
+
192
+ 2. Create `eslint.config.js` in your project root.
193
+
194
+ 3. In `eslint.config.js`:
195
+ - Import function `linted`.
196
+
197
+ ```javascript
198
+ import linted from "linted";
199
+ ```
200
+
201
+ - Export `linted` with optional [arguments](#total-control-via-optional-arguments):
202
+
203
+ ```javascript
204
+ import linted from "linted";
205
+
206
+ export default linted(
207
+ // ...
208
+ );
209
+ ```
210
+
211
+ ___
212
+
213
+ ## Roadmap
214
+
215
+ ### v11
216
+
217
+ #### Mocha
218
+
219
+ - Mocha
220
+
221
+ #### Tailwind PostCSS
222
+
223
+ - [Tailwind](https://github.com/francoismassart/eslint-plugin-tailwindcss)
224
+
225
+ - [CSS](https://ota-meshi.github.io/eslint-plugin-css/)
226
+
227
+ #### HTML Connectors
228
+
229
+ - [Embedded TypeScript](https://github.com/BenoitZugmeyer/eslint-plugin-html)
230
+
231
+ - Embedded CSS
232
+
233
+ - Svelte Interaction TBD
234
+
235
+ - .svelte-embedded HTML (on top of Svelte HTML rules)
236
+
237
+ - .html files in Svelte projects (e.g. title not required)
238
+
239
+ - Should Svelte-Linter handle all .html / HTML-embedded linting for Svelte projects, and HTML-Linter only handles non-Svelte projects?
240
+
241
+ #### JSON (Custom Schema Validation)
242
+
243
+ - [JSON Custom Schema Validation](https://github.com/ota-meshi/eslint-plugin-json-schema-validator)
244
+
245
+ ___
246
+
247
+ ## Rule Logic (Advanced)
248
+
249
+ ### What is `scope`?
250
+
251
+ Each `scope` maps to a unique `language`:
252
+
253
+ - __`js`:__ `JavaScript`
254
+
255
+ - __`ts`:__ `TypeScript`
256
+
257
+ - __`svelte`:__ `Svelte`
258
+
259
+ - __`html`:__ `HTML`
260
+
261
+ - __`json`:__ `JSON`
262
+
263
+ - __`jsonc`:__ `JSONC`
264
+
265
+ - __`yml`:__ `YAML`
266
+
267
+ ### Rules
268
+
269
+ Each `scope` supports:
270
+
271
+ - all base ESLint rules
272
+
273
+ - all rules from its `language`'s [__plugins__](#languages)
274
+
275
+ #### Default Rules
276
+
277
+ - Each `language` has a set of default rules.
278
+
279
+ #### Language-Aggregate `scope`
280
+
281
+ A `language` can be an extension of or depend on another `language`.
282
+
283
+ For example:
284
+
285
+ - TypeScript extends JavaScript
286
+
287
+ - Svelte depends on TypeScript (which extends JavaScript)
288
+
289
+ For such a `language`, its `scope`'s default rules are aggregated with the default rules of extended or consumed `language`s by `scope` precedence:
290
+
291
+ - __`js`:__ `js`
292
+
293
+ - __`ts`:__ `js` < `ts`
294
+
295
+ - __`svelte`:__ `js` < `ts` < `svelte`
296
+
297
+ - __`html`:__ `html`
298
+
299
+ - __`json`:__ `json`
300
+
301
+ - __`jsonc`:__ `json` < `jsonc`
302
+
303
+ - __`yml`:__ `yml`
304
+
305
+ ### Files
306
+
307
+ #### Global Ignores
308
+
309
+ ##### `.gitignore`
310
+
311
+ By default, `linted` ignores all files in `.gitignore`. This behavior can be disabled.
312
+
313
+ ##### `package-lock.json`
314
+
315
+ `**/*.package-lock.json` is always skipped. _This cannot be overriden._
316
+
317
+ ##### `ignores`
318
+
319
+ Additional glob patterns supplied if matched by a file will skip linting that file, even if a scope pattern matches the file.
320
+
321
+ #### Scoped Includes
322
+
323
+ Files specified in `scope` are appended to the following default files:
324
+
325
+ ```javascript
326
+ {
327
+ js: [
328
+ "{src,static}/**/*.{js,mjs,cjs}",
329
+ "*.{js,mjs,cjs}",
330
+ ],
331
+ ts: [
332
+ "{src,static}/**/*.{ts,mts,cts}",
333
+ "*.{ts,mts,cts}",
334
+ ],
335
+ svelte: ["{src,static}/**/*.svelte"],
336
+ html: [
337
+ "{src,static}/**/*.html",
338
+ "*.html",
339
+ ],
340
+ json: [
341
+ "{src,static}/**/*.json",
342
+ "*.json",
343
+ ],
344
+ jsonc: [
345
+ "tsconfig.json",
346
+ "{src,static}/**/*.jsonc",
347
+ "*.jsonc",
348
+ ],
349
+ yml: [
350
+ ".github/workflows/*.{yml,yaml}",
351
+ "{src,static}/**/*.{yml,yaml}",
352
+ "*.{yml,yaml}",
353
+ ],
354
+ },
355
+ ```
356
+
357
+ #### Scope Conflict
358
+
359
+ - If a given file matches more than one `scope` glob, then the set of all matching `scope`s' rules are applied to the file.
360
+
361
+ - If any rule is specified in more than one `scope` matching a given file, the specifies a rule, then the highest-precedence `scope`'s rule specification wins.
362
+
363
+ ##### Scope Precedence (low to high)
364
+
365
+ ```bash
366
+ js
367
+ ts
368
+ svelte
369
+ html
370
+ json
371
+ jsonc
372
+ yml
373
+ ignores (global)
374
+ ```
375
+
376
+ ### Override
377
+
378
+ Overrides are per-__scope.__
379
+
380
+ #### Example
381
+
382
+ `overrideTs` rules apply to files which:
383
+
384
+ - ✅ ONLY match scope `ts`.
385
+
386
+ - ✅ match scope `ts` and any number of lower precedence scopes (e.g. `js`).
387
+
388
+ `overrideTs` rules do __NOT__ apply to files which:
389
+
390
+ - ❌ match scope `ts` and at least one higher precedence scope (e.g. `svelte`), even if the higher precedence scope includes `ts` language default rules (e.g. `svelte` includes `ts` default rules, but NOT `overrideTs` rules).