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