linted 16.12.2-rc.2 → 16.12.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/RELEASE.yml +35 -35
- package/.github/workflows/rc.yml +35 -35
- package/LICENSE +21 -21
- package/README.md +390 -390
- package/SECURITY.md +9 -9
- package/dist/imports/plugins.d.ts.map +1 -1
- package/dist/imports.d.ts.map +1 -1
- package/eslint.config.js +3 -3
- package/package.json +99 -99
- package/src/files/html.ts +1 -1
- package/src/files/js.ts +1 -1
- package/src/files/json.ts +1 -1
- package/src/files/jsonc.ts +4 -4
- package/src/files/md.ts +1 -1
- package/src/files/mocha.ts +1 -1
- package/src/files/svelte.ts +1 -1
- package/src/files/ts.ts +5 -5
- package/src/files/yml.ts +5 -5
- package/src/files.ts +22 -22
- package/src/imports/parsers.ts +15 -15
- package/src/imports/plugins.ts +19 -19
- package/src/imports.ts +8 -8
- package/src/index.ts +36 -36
- package/src/rules/_strings/id.ts +18 -18
- package/src/rules/_strings/level.ts +6 -6
- package/src/rules/_strings/state.ts +56 -56
- package/src/rules/_strings.ts +6 -6
- package/src/rules/html/enable.ts +16 -16
- package/src/rules/html/enable_recommended.ts +9 -9
- package/src/rules/html.ts +4 -4
- package/src/rules/js/enable.ts +524 -524
- package/src/rules/js/enable_stylistic.ts +608 -608
- package/src/rules/js.ts +4 -4
- package/src/rules/json/enable.ts +33 -33
- package/src/rules/json/enable_x.ts +89 -89
- package/src/rules/json.ts +4 -4
- package/src/rules/jsonc/override.ts +16 -16
- package/src/rules/jsonc.ts +4 -4
- package/src/rules/md/enable.ts +15 -15
- package/src/rules/md.ts +3 -3
- package/src/rules/mocha/enable.ts +3 -3
- package/src/rules/mocha/enable_recommended.ts +9 -9
- package/src/rules/mocha.ts +4 -4
- package/src/rules/svelte/disable.ts +9 -9
- package/src/rules/svelte/disable_js.ts +11 -11
- package/src/rules/svelte/disable_ts.ts +9 -9
- package/src/rules/svelte/enable.ts +228 -228
- package/src/rules/svelte/enable_x.ts +20 -20
- package/src/rules/svelte.ts +15 -15
- package/src/rules/ts/disable.ts +22 -22
- package/src/rules/ts/disable_x.ts +32 -32
- package/src/rules/ts/enable.ts +549 -549
- package/src/rules/ts/enable_x.ts +115 -115
- package/src/rules/ts.ts +13 -13
- package/src/rules/yml/enable.ts +64 -64
- package/src/rules/yml/enable_x.ts +68 -68
- package/src/rules/yml.ts +4 -4
- package/src/rules.ts +22 -22
- package/tsconfig.json +161 -161
- package/types/markdownlint/index.d.ts +3 -3
- package/types/markdownlint/parser.d.ts +9 -9
- package/types/mocha/index.d.ts +8 -8
- package/dist/rules/_html.d.ts +0 -8
- package/dist/rules/_html.d.ts.map +0 -1
- package/dist/rules/_html.js +0 -4
- package/dist/rules/_html.js.map +0 -1
- package/dist/rules/_js.d.ts +0 -765
- package/dist/rules/_js.d.ts.map +0 -1
- package/dist/rules/_js.js +0 -4
- package/dist/rules/_js.js.map +0 -1
- package/dist/rules/_json.d.ts +0 -74
- package/dist/rules/_json.d.ts.map +0 -1
- package/dist/rules/_json.js +0 -4
- package/dist/rules/_json.js.map +0 -1
- package/dist/rules/_jsonc.d.ts +0 -77
- package/dist/rules/_jsonc.d.ts.map +0 -1
- package/dist/rules/_jsonc.js +0 -4
- package/dist/rules/_jsonc.js.map +0 -1
- package/dist/rules/_md.d.ts +0 -7
- package/dist/rules/_md.d.ts.map +0 -1
- package/dist/rules/_md.js +0 -3
- package/dist/rules/_md.js.map +0 -1
- package/dist/rules/_mocha.d.ts +0 -8
- package/dist/rules/_mocha.d.ts.map +0 -1
- package/dist/rules/_mocha.js +0 -4
- package/dist/rules/_mocha.js.map +0 -1
- package/dist/rules/_svelte.d.ts +0 -1269
- package/dist/rules/_svelte.d.ts.map +0 -1
- package/dist/rules/_svelte.js +0 -15
- package/dist/rules/_svelte.js.map +0 -1
- package/dist/rules/_ts.d.ts +0 -1133
- package/dist/rules/_ts.d.ts.map +0 -1
- package/dist/rules/_ts.js +0 -13
- package/dist/rules/_ts.js.map +0 -1
- package/dist/rules/_yml.d.ts +0 -73
- package/dist/rules/_yml.d.ts.map +0 -1
- package/dist/rules/_yml.js +0 -4
- package/dist/rules/_yml.js.map +0 -1
- package/dist/rules/html/_enable.d.ts +0 -8
- package/dist/rules/html/_enable.d.ts.map +0 -1
- package/dist/rules/html/_enable.js +0 -10
- package/dist/rules/html/_enable.js.map +0 -1
- package/dist/rules/html/_recommended.d.ts +0 -3
- package/dist/rules/html/_recommended.d.ts.map +0 -1
- package/dist/rules/html/_recommended.js +0 -5
- package/dist/rules/html/_recommended.js.map +0 -1
- package/dist/rules/js/_enable.d.ts +0 -348
- package/dist/rules/js/_enable.d.ts.map +0 -1
- package/dist/rules/js/_enable.js +0 -260
- package/dist/rules/js/_enable.js.map +0 -1
- package/dist/rules/js/stylistic.d.ts +0 -420
- package/dist/rules/js/stylistic.d.ts.map +0 -1
- package/dist/rules/js/stylistic.js +0 -270
- package/dist/rules/js/stylistic.js.map +0 -1
- package/dist/rules/json/_enable.d.ts +0 -27
- package/dist/rules/json/_enable.d.ts.map +0 -1
- package/dist/rules/json/_enable.js +0 -31
- package/dist/rules/json/_enable.js.map +0 -1
- package/dist/rules/md/_enable.d.ts +0 -7
- package/dist/rules/md/_enable.d.ts.map +0 -1
- package/dist/rules/md/_enable.js +0 -9
- package/dist/rules/md/_enable.js.map +0 -1
- package/dist/rules/mocha/_enable.d.ts +0 -3
- package/dist/rules/mocha/_enable.d.ts.map +0 -1
- package/dist/rules/mocha/_enable.js +0 -4
- package/dist/rules/mocha/_enable.js.map +0 -1
- package/dist/rules/mocha/_recommended.d.ts +0 -3
- package/dist/rules/mocha/_recommended.d.ts.map +0 -1
- package/dist/rules/mocha/_recommended.js +0 -5
- package/dist/rules/mocha/_recommended.js.map +0 -1
- package/dist/rules/svelte/_enable.d.ts +0 -126
- package/dist/rules/svelte/_enable.d.ts.map +0 -1
- package/dist/rules/svelte/_enable.js +0 -90
- package/dist/rules/svelte/_enable.js.map +0 -1
- package/dist/rules/svelte/disable_x.d.ts +0 -5
- package/dist/rules/svelte/disable_x.d.ts.map +0 -1
- package/dist/rules/svelte/disable_x.js +0 -4
- package/dist/rules/svelte/disable_x.js.map +0 -1
- package/dist/rules/ts/_enable.d.ts +0 -262
- package/dist/rules/ts/_enable.d.ts.map +0 -1
- package/dist/rules/ts/_enable.js +0 -359
- package/dist/rules/ts/_enable.js.map +0 -1
- package/dist/rules/ts/disable_compiler.d.ts +0 -18
- package/dist/rules/ts/disable_compiler.d.ts.map +0 -1
- package/dist/rules/ts/disable_compiler.js +0 -22
- package/dist/rules/ts/disable_compiler.js.map +0 -1
- package/dist/rules/yml/_enable.d.ts +0 -39
- package/dist/rules/yml/_enable.d.ts.map +0 -1
- package/dist/rules/yml/_enable.js +0 -28
- package/dist/rules/yml/_enable.js.map +0 -1
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).
|