@luxass/eslint-config 4.2.8 → 4.2.10
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/README.md +42 -42
- package/dist/index.cjs +49 -33
- package/dist/index.d.cts +35 -35
- package/dist/index.d.ts +35 -35
- package/dist/index.js +49 -33
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -29,28 +29,28 @@ With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package
|
|
|
29
29
|
|
|
30
30
|
```js
|
|
31
31
|
// eslint.config.js
|
|
32
|
-
import luxass from
|
|
32
|
+
import luxass from '@luxass/eslint-config'
|
|
33
33
|
|
|
34
|
-
export default luxass()
|
|
34
|
+
export default luxass()
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
With CJS:
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
// eslint.config.js
|
|
41
|
-
const luxass = require(
|
|
41
|
+
const luxass = require('@luxass/eslint-config').default
|
|
42
42
|
|
|
43
|
-
module.exports = luxass()
|
|
43
|
+
module.exports = luxass()
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Combined with legacy config:
|
|
47
47
|
|
|
48
48
|
```js
|
|
49
49
|
// eslint.config.js
|
|
50
|
-
const luxass = require(
|
|
51
|
-
const { FlatCompat } = require(
|
|
50
|
+
const luxass = require('@luxass/eslint-config').default
|
|
51
|
+
const { FlatCompat } = require('@eslint/eslintrc')
|
|
52
52
|
|
|
53
|
-
const compat = new FlatCompat()
|
|
53
|
+
const compat = new FlatCompat()
|
|
54
54
|
|
|
55
55
|
module.exports = luxass(
|
|
56
56
|
{
|
|
@@ -60,13 +60,13 @@ module.exports = luxass(
|
|
|
60
60
|
// Legacy config
|
|
61
61
|
...compat.config({
|
|
62
62
|
extends: [
|
|
63
|
-
|
|
63
|
+
'eslint:recommended',
|
|
64
64
|
// Other extends...
|
|
65
65
|
],
|
|
66
66
|
})
|
|
67
67
|
|
|
68
68
|
// Other flat configs...
|
|
69
|
-
)
|
|
69
|
+
)
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
> Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
|
|
@@ -129,16 +129,16 @@ Normally you would only need to import the `luxass` preset:
|
|
|
129
129
|
|
|
130
130
|
```js
|
|
131
131
|
// eslint.config.js
|
|
132
|
-
import luxass from
|
|
132
|
+
import luxass from '@luxass/eslint-config'
|
|
133
133
|
|
|
134
|
-
export default luxass()
|
|
134
|
+
export default luxass()
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
you can also configure each `config` individually:
|
|
138
138
|
|
|
139
139
|
```js
|
|
140
140
|
// eslint.config.js
|
|
141
|
-
import luxass from
|
|
141
|
+
import luxass from '@luxass/eslint-config'
|
|
142
142
|
|
|
143
143
|
export default luxass({
|
|
144
144
|
stylistic: true,
|
|
@@ -150,16 +150,16 @@ export default luxass({
|
|
|
150
150
|
|
|
151
151
|
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead.
|
|
152
152
|
ignores: [
|
|
153
|
-
|
|
153
|
+
'**/fixtures'
|
|
154
154
|
]
|
|
155
|
-
})
|
|
155
|
+
})
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
The `luxass` function accepts an arbitrary number of `flat configs` overrides:
|
|
159
159
|
|
|
160
160
|
```js
|
|
161
161
|
// eslint.config.js
|
|
162
|
-
import luxass from
|
|
162
|
+
import luxass from '@luxass/eslint-config'
|
|
163
163
|
|
|
164
164
|
export default luxass({
|
|
165
165
|
// configuration points for my config
|
|
@@ -167,7 +167,7 @@ export default luxass({
|
|
|
167
167
|
rules: {}
|
|
168
168
|
}, {
|
|
169
169
|
rules: {}
|
|
170
|
-
})
|
|
170
|
+
})
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
<details>
|
|
@@ -194,7 +194,7 @@ import {
|
|
|
194
194
|
unicorn,
|
|
195
195
|
vue,
|
|
196
196
|
yaml
|
|
197
|
-
} from
|
|
197
|
+
} from '@luxass/eslint-config'
|
|
198
198
|
|
|
199
199
|
export default combine(
|
|
200
200
|
ignores(),
|
|
@@ -210,7 +210,7 @@ export default combine(
|
|
|
210
210
|
jsonc(),
|
|
211
211
|
yaml(),
|
|
212
212
|
markdown(),
|
|
213
|
-
)
|
|
213
|
+
)
|
|
214
214
|
```
|
|
215
215
|
|
|
216
216
|
</details>
|
|
@@ -246,44 +246,44 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
|
|
|
246
246
|
|
|
247
247
|
```js
|
|
248
248
|
// eslint.config.js
|
|
249
|
-
import luxass from
|
|
249
|
+
import luxass from '@luxass/eslint-config'
|
|
250
250
|
|
|
251
251
|
export default luxass(
|
|
252
252
|
{ vue: true, typescript: true },
|
|
253
253
|
{
|
|
254
254
|
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
|
|
255
|
-
files: [
|
|
255
|
+
files: ['**/*.vue'],
|
|
256
256
|
rules: {
|
|
257
|
-
|
|
257
|
+
'vue/operator-linebreak': ['error', 'before'],
|
|
258
258
|
},
|
|
259
259
|
},
|
|
260
260
|
{
|
|
261
261
|
// Without `files`, they are general rules for all files
|
|
262
262
|
rules: {
|
|
263
|
-
|
|
263
|
+
'style/semi': ['error', 'never'],
|
|
264
264
|
},
|
|
265
265
|
}
|
|
266
|
-
)
|
|
266
|
+
)
|
|
267
267
|
```
|
|
268
268
|
|
|
269
269
|
We also provided a `overrides` options to make it easier:
|
|
270
270
|
|
|
271
271
|
```js
|
|
272
272
|
// eslint.config.js
|
|
273
|
-
import luxass from
|
|
273
|
+
import luxass from '@luxass/eslint-config'
|
|
274
274
|
|
|
275
275
|
export default luxass({
|
|
276
276
|
overrides: {
|
|
277
277
|
vue: {
|
|
278
|
-
|
|
278
|
+
'vue/operator-linebreak': ['error', 'before'],
|
|
279
279
|
},
|
|
280
280
|
typescript: {
|
|
281
|
-
|
|
281
|
+
'ts/consistent-type-definitions': ['error', 'interface'],
|
|
282
282
|
},
|
|
283
283
|
yaml: {},
|
|
284
284
|
// ...
|
|
285
285
|
}
|
|
286
|
-
})
|
|
286
|
+
})
|
|
287
287
|
```
|
|
288
288
|
|
|
289
289
|
### Optional Configs
|
|
@@ -299,7 +299,7 @@ Use external formatters to format files that ESLint cannot handle yet (`.css`, `
|
|
|
299
299
|
|
|
300
300
|
```js
|
|
301
301
|
// eslint.config.js
|
|
302
|
-
import luxass from
|
|
302
|
+
import luxass from '@luxass/eslint-config'
|
|
303
303
|
|
|
304
304
|
export default luxass({
|
|
305
305
|
formatters: {
|
|
@@ -317,15 +317,15 @@ export default luxass({
|
|
|
317
317
|
* Format TOML files
|
|
318
318
|
* Currently only supports dprint
|
|
319
319
|
*/
|
|
320
|
-
toml:
|
|
320
|
+
toml: 'dprint',
|
|
321
321
|
/**
|
|
322
322
|
* Format Markdown files
|
|
323
323
|
* Supports Prettier and dprint
|
|
324
324
|
* By default uses Prettier
|
|
325
325
|
*/
|
|
326
|
-
markdown:
|
|
326
|
+
markdown: 'prettier'
|
|
327
327
|
}
|
|
328
|
-
})
|
|
328
|
+
})
|
|
329
329
|
```
|
|
330
330
|
|
|
331
331
|
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
@@ -340,11 +340,11 @@ To enable React support, need to explicitly turn it on:
|
|
|
340
340
|
|
|
341
341
|
```js
|
|
342
342
|
// eslint.config.js
|
|
343
|
-
import luxass from
|
|
343
|
+
import luxass from '@luxass/eslint-config'
|
|
344
344
|
|
|
345
345
|
export default luxass({
|
|
346
346
|
react: true,
|
|
347
|
-
})
|
|
347
|
+
})
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
@@ -361,11 +361,11 @@ Next.JS also enables React support.
|
|
|
361
361
|
|
|
362
362
|
```js
|
|
363
363
|
// eslint.config.js
|
|
364
|
-
import luxass from
|
|
364
|
+
import luxass from '@luxass/eslint-config'
|
|
365
365
|
|
|
366
366
|
export default luxass({
|
|
367
367
|
nextjs: true,
|
|
368
|
-
})
|
|
368
|
+
})
|
|
369
369
|
```
|
|
370
370
|
|
|
371
371
|
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
@@ -380,11 +380,11 @@ To enable UnoCSS support, need to explicitly turn it on:
|
|
|
380
380
|
|
|
381
381
|
```js
|
|
382
382
|
// eslint.config.js
|
|
383
|
-
import luxass from
|
|
383
|
+
import luxass from '@luxass/eslint-config'
|
|
384
384
|
|
|
385
385
|
export default luxass({
|
|
386
386
|
unocss: true,
|
|
387
|
-
})
|
|
387
|
+
})
|
|
388
388
|
```
|
|
389
389
|
|
|
390
390
|
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
@@ -399,11 +399,11 @@ To enable TailwindCSS support, need to explicitly turn it on:
|
|
|
399
399
|
|
|
400
400
|
```js
|
|
401
401
|
// eslint.config.js
|
|
402
|
-
import luxass from
|
|
402
|
+
import luxass from '@luxass/eslint-config'
|
|
403
403
|
|
|
404
404
|
export default luxass({
|
|
405
405
|
tailwindcss: true,
|
|
406
|
-
})
|
|
406
|
+
})
|
|
407
407
|
```
|
|
408
408
|
|
|
409
409
|
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
@@ -422,13 +422,13 @@ You can optionally enable the [type aware rules](https://typescript-eslint.io/li
|
|
|
422
422
|
|
|
423
423
|
```js
|
|
424
424
|
// eslint.config.js
|
|
425
|
-
import luxass from
|
|
425
|
+
import luxass from '@luxass/eslint-config'
|
|
426
426
|
|
|
427
427
|
export default luxass({
|
|
428
428
|
typescript: {
|
|
429
|
-
tsconfigPath:
|
|
429
|
+
tsconfigPath: 'tsconfig.json',
|
|
430
430
|
},
|
|
431
|
-
})
|
|
431
|
+
})
|
|
432
432
|
```
|
|
433
433
|
|
|
434
434
|
## Versioning Policy
|
package/dist/index.cjs
CHANGED
|
@@ -93,7 +93,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
93
93
|
// src/factory.ts
|
|
94
94
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
95
95
|
var import_node_fs = require("fs");
|
|
96
|
-
var
|
|
96
|
+
var import_local_pkg4 = require("local-pkg");
|
|
97
97
|
|
|
98
98
|
// src/configs/comments.ts
|
|
99
99
|
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
@@ -105,8 +105,6 @@ async function comments() {
|
|
|
105
105
|
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
106
106
|
},
|
|
107
107
|
rules: {
|
|
108
|
-
// https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/disable-enable-pair.md
|
|
109
|
-
"eslint-comments/disable-enable-pair": "error",
|
|
110
108
|
// https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-aggregating-enable.md
|
|
111
109
|
"eslint-comments/no-aggregating-enable": "error",
|
|
112
110
|
// https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-duplicate-disable.md
|
|
@@ -525,7 +523,7 @@ async function imports(options = {}) {
|
|
|
525
523
|
"import/no-webpack-loader-syntax": "error",
|
|
526
524
|
"import/order": "error",
|
|
527
525
|
...stylistic2 ? {
|
|
528
|
-
"import/newline-after-import": ["error", {
|
|
526
|
+
"import/newline-after-import": ["error", { count: 1 }]
|
|
529
527
|
} : {}
|
|
530
528
|
}
|
|
531
529
|
},
|
|
@@ -830,25 +828,17 @@ async function ensure(packages) {
|
|
|
830
828
|
return;
|
|
831
829
|
}
|
|
832
830
|
;
|
|
833
|
-
const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
|
|
831
|
+
const nonExistingPackages = packages.filter((i) => i && !(0, import_local_pkg.isPackageExists)(i));
|
|
834
832
|
if (nonExistingPackages.length === 0) {
|
|
835
833
|
return;
|
|
836
834
|
}
|
|
837
|
-
;
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
name: "result",
|
|
842
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
843
|
-
type: "confirm"
|
|
844
|
-
}
|
|
845
|
-
]);
|
|
835
|
+
const p = await import("@clack/prompts");
|
|
836
|
+
const result = await p.confirm({
|
|
837
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
838
|
+
});
|
|
846
839
|
if (result) {
|
|
847
|
-
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, {
|
|
848
|
-
dev: true
|
|
849
|
-
}));
|
|
840
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
850
841
|
}
|
|
851
|
-
;
|
|
852
842
|
}
|
|
853
843
|
function resolveSubOptions(options, key) {
|
|
854
844
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
@@ -1076,8 +1066,8 @@ var import_eslint_plugin_antfu3 = __toESM(require("eslint-plugin-antfu"), 1);
|
|
|
1076
1066
|
var StylisticConfigDefaults = {
|
|
1077
1067
|
indent: 2,
|
|
1078
1068
|
jsx: true,
|
|
1079
|
-
quotes: "
|
|
1080
|
-
semi:
|
|
1069
|
+
quotes: "single",
|
|
1070
|
+
semi: false
|
|
1081
1071
|
};
|
|
1082
1072
|
async function stylistic(options = {}) {
|
|
1083
1073
|
const {
|
|
@@ -1259,6 +1249,8 @@ async function typescript(options = {}) {
|
|
|
1259
1249
|
"error",
|
|
1260
1250
|
{ disallowTypeAnnotations: false, prefer: "type-imports" }
|
|
1261
1251
|
],
|
|
1252
|
+
"ts/method-signature-style": ["error", "property"],
|
|
1253
|
+
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
|
|
1262
1254
|
"ts/no-dupe-class-members": "error",
|
|
1263
1255
|
"ts/no-dynamic-delete": "off",
|
|
1264
1256
|
"ts/no-explicit-any": "off",
|
|
@@ -1528,7 +1520,7 @@ async function yaml(options = {}) {
|
|
|
1528
1520
|
]);
|
|
1529
1521
|
const {
|
|
1530
1522
|
indent = 2,
|
|
1531
|
-
quotes = "
|
|
1523
|
+
quotes = "single"
|
|
1532
1524
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1533
1525
|
return [
|
|
1534
1526
|
{
|
|
@@ -2023,29 +2015,29 @@ async function react(options = {}) {
|
|
|
2023
2015
|
// src/configs/frameworks/astro.ts
|
|
2024
2016
|
async function astro(options) {
|
|
2025
2017
|
const {
|
|
2026
|
-
a11y = false,
|
|
2027
2018
|
files = [GLOB_ASTRO],
|
|
2028
2019
|
overrides = {},
|
|
2029
2020
|
typescript: typescript2 = true,
|
|
2030
2021
|
stylistic: stylistic2 = true
|
|
2031
2022
|
} = options;
|
|
2023
|
+
await ensure([
|
|
2024
|
+
"eslint-plugin-astro",
|
|
2025
|
+
"astro-eslint-parser"
|
|
2026
|
+
]);
|
|
2032
2027
|
const [
|
|
2033
2028
|
pluginAstro,
|
|
2034
2029
|
parserAstro,
|
|
2035
|
-
parserTs
|
|
2036
|
-
pluginA11y
|
|
2030
|
+
parserTs
|
|
2037
2031
|
] = await Promise.all([
|
|
2038
2032
|
interop(import("eslint-plugin-astro")),
|
|
2039
2033
|
interop(import("astro-eslint-parser")),
|
|
2040
|
-
interop(import("@typescript-eslint/parser"))
|
|
2041
|
-
...a11y ? [interop(import("eslint-plugin-jsx-a11y"))] : []
|
|
2034
|
+
interop(import("@typescript-eslint/parser"))
|
|
2042
2035
|
]);
|
|
2043
2036
|
return [
|
|
2044
2037
|
{
|
|
2045
2038
|
name: "luxass:astro:setup",
|
|
2046
2039
|
plugins: {
|
|
2047
|
-
astro: pluginAstro
|
|
2048
|
-
...a11y ? { "jsx-a11y": pluginA11y } : {}
|
|
2040
|
+
astro: pluginAstro
|
|
2049
2041
|
}
|
|
2050
2042
|
},
|
|
2051
2043
|
{
|
|
@@ -2167,18 +2159,21 @@ async function tailwindcss(options = {}) {
|
|
|
2167
2159
|
|
|
2168
2160
|
// src/configs/formatters.ts
|
|
2169
2161
|
var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
|
|
2162
|
+
var import_local_pkg3 = require("local-pkg");
|
|
2170
2163
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
2171
|
-
await ensure([
|
|
2172
|
-
"eslint-plugin-format"
|
|
2173
|
-
]);
|
|
2174
2164
|
if (options === true) {
|
|
2175
2165
|
options = {
|
|
2166
|
+
astro: (0, import_local_pkg3.isPackageExists)("astro"),
|
|
2176
2167
|
css: true,
|
|
2177
2168
|
graphql: true,
|
|
2178
2169
|
html: true,
|
|
2179
2170
|
markdown: true
|
|
2180
2171
|
};
|
|
2181
2172
|
}
|
|
2173
|
+
await ensure([
|
|
2174
|
+
"eslint-plugin-format",
|
|
2175
|
+
options.astro ? "prettier-plugin-astro" : void 0
|
|
2176
|
+
]);
|
|
2182
2177
|
const {
|
|
2183
2178
|
indent,
|
|
2184
2179
|
quotes,
|
|
@@ -2309,6 +2304,27 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2309
2304
|
}
|
|
2310
2305
|
});
|
|
2311
2306
|
}
|
|
2307
|
+
if (options.astro) {
|
|
2308
|
+
configs.push({
|
|
2309
|
+
name: "luxass:formatter:astro",
|
|
2310
|
+
files: [GLOB_ASTRO],
|
|
2311
|
+
languageOptions: {
|
|
2312
|
+
parser: parserPlain2
|
|
2313
|
+
},
|
|
2314
|
+
rules: {
|
|
2315
|
+
"format/prettier": [
|
|
2316
|
+
"error",
|
|
2317
|
+
{
|
|
2318
|
+
...prettierOptions,
|
|
2319
|
+
parser: "astro",
|
|
2320
|
+
plugins: [
|
|
2321
|
+
"prettier-plugin-astro"
|
|
2322
|
+
]
|
|
2323
|
+
}
|
|
2324
|
+
]
|
|
2325
|
+
}
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2312
2328
|
if (options.graphql) {
|
|
2313
2329
|
configs.push({
|
|
2314
2330
|
name: "luxass:formatter:graphql",
|
|
@@ -2416,9 +2432,9 @@ async function luxass(options = {}, ...userConfigs) {
|
|
|
2416
2432
|
nextjs: enableNextJS = false,
|
|
2417
2433
|
react: enableReact = false,
|
|
2418
2434
|
tailwindcss: enableTailwindCSS = false,
|
|
2419
|
-
typescript: enableTypeScript = (0,
|
|
2435
|
+
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2420
2436
|
unocss: enableUnoCSS = false,
|
|
2421
|
-
vue: enableVue = VuePackages.some((i) => (0,
|
|
2437
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2422
2438
|
} = options;
|
|
2423
2439
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2424
2440
|
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
package/dist/index.d.cts
CHANGED
|
@@ -30,7 +30,7 @@ declare function sortPackageJson(): FlatConfigItem[];
|
|
|
30
30
|
*/
|
|
31
31
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
32
32
|
|
|
33
|
-
type StylisticConfig = Pick<StylisticCustomizeOptions,
|
|
33
|
+
type StylisticConfig = Pick<StylisticCustomizeOptions, 'jsx' | 'indent' | 'quotes' | 'semi'>;
|
|
34
34
|
interface StylisticOptions {
|
|
35
35
|
/**
|
|
36
36
|
* Enable stylistic rules.
|
|
@@ -41,7 +41,7 @@ interface StylisticOptions {
|
|
|
41
41
|
/**
|
|
42
42
|
* Overrides for the config.
|
|
43
43
|
*/
|
|
44
|
-
overrides?: FlatConfigItem[
|
|
44
|
+
overrides?: FlatConfigItem['rules'];
|
|
45
45
|
}
|
|
46
46
|
declare function stylistic(options?: StylisticOptions): Promise<FlatConfigItem[]>;
|
|
47
47
|
|
|
@@ -64,7 +64,7 @@ interface JavaScriptOptions {
|
|
|
64
64
|
/**
|
|
65
65
|
* Overrides for the config.
|
|
66
66
|
*/
|
|
67
|
-
overrides?: FlatConfigItem[
|
|
67
|
+
overrides?: FlatConfigItem['rules'];
|
|
68
68
|
}
|
|
69
69
|
declare function javascript(options?: JavaScriptOptions): Promise<FlatConfigItem[]>;
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ interface JSDOCOptions {
|
|
|
78
78
|
/**
|
|
79
79
|
* Overrides for the config.
|
|
80
80
|
*/
|
|
81
|
-
overrides?: FlatConfigItem[
|
|
81
|
+
overrides?: FlatConfigItem['rules'];
|
|
82
82
|
}
|
|
83
83
|
declare function jsdoc(options?: JSDOCOptions): Promise<FlatConfigItem[]>;
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ interface JSONOptions {
|
|
|
86
86
|
/**
|
|
87
87
|
* Override rules.
|
|
88
88
|
*/
|
|
89
|
-
overrides?: FlatConfigItem[
|
|
89
|
+
overrides?: FlatConfigItem['rules'];
|
|
90
90
|
/**
|
|
91
91
|
* Enable stylistic rules.
|
|
92
92
|
*
|
|
@@ -107,7 +107,7 @@ interface MarkdownOptions {
|
|
|
107
107
|
/**
|
|
108
108
|
* Override rules.
|
|
109
109
|
*/
|
|
110
|
-
overrides?: FlatConfigItem[
|
|
110
|
+
overrides?: FlatConfigItem['rules'];
|
|
111
111
|
/**
|
|
112
112
|
* Additional extensions for components.
|
|
113
113
|
*
|
|
@@ -157,7 +157,7 @@ interface TypeScriptOptions {
|
|
|
157
157
|
/**
|
|
158
158
|
* Overrides for the config.
|
|
159
159
|
*/
|
|
160
|
-
overrides?: FlatConfigItem[
|
|
160
|
+
overrides?: FlatConfigItem['rules'];
|
|
161
161
|
}
|
|
162
162
|
declare function typescript(options?: TypeScriptOptions): Promise<FlatConfigItem[]>;
|
|
163
163
|
|
|
@@ -165,7 +165,7 @@ interface VueOptions {
|
|
|
165
165
|
/**
|
|
166
166
|
* Override rules.
|
|
167
167
|
*/
|
|
168
|
-
overrides?: FlatConfigItem[
|
|
168
|
+
overrides?: FlatConfigItem['rules'];
|
|
169
169
|
/**
|
|
170
170
|
* Enable stylistic rules.
|
|
171
171
|
*
|
|
@@ -199,7 +199,7 @@ interface YAMLOptions {
|
|
|
199
199
|
/**
|
|
200
200
|
* Override rules.
|
|
201
201
|
*/
|
|
202
|
-
overrides?: FlatConfigItem[
|
|
202
|
+
overrides?: FlatConfigItem['rules'];
|
|
203
203
|
/**
|
|
204
204
|
* Enable stylistic rules.
|
|
205
205
|
*
|
|
@@ -233,7 +233,7 @@ interface TestOptions {
|
|
|
233
233
|
/**
|
|
234
234
|
* Override rules for for test files.
|
|
235
235
|
*/
|
|
236
|
-
overrides?: FlatConfigItem[
|
|
236
|
+
overrides?: FlatConfigItem['rules'];
|
|
237
237
|
}
|
|
238
238
|
declare function test(options?: TestOptions): Promise<FlatConfigItem[]>;
|
|
239
239
|
|
|
@@ -260,7 +260,7 @@ interface UnoCSSOptions {
|
|
|
260
260
|
/**
|
|
261
261
|
* Override rules for for files with unocss classes.
|
|
262
262
|
*/
|
|
263
|
-
overrides?: FlatConfigItem[
|
|
263
|
+
overrides?: FlatConfigItem['rules'];
|
|
264
264
|
}
|
|
265
265
|
declare function unocss(options?: UnoCSSOptions): Promise<FlatConfigItem[]>;
|
|
266
266
|
|
|
@@ -275,7 +275,7 @@ interface NextJSOptions {
|
|
|
275
275
|
/**
|
|
276
276
|
* Override rules.
|
|
277
277
|
*/
|
|
278
|
-
overrides?: FlatConfigItem[
|
|
278
|
+
overrides?: FlatConfigItem['rules'];
|
|
279
279
|
/**
|
|
280
280
|
* Glob patterns for Next.js files.
|
|
281
281
|
*
|
|
@@ -290,7 +290,7 @@ interface ReactOptions {
|
|
|
290
290
|
/**
|
|
291
291
|
* Override rules.
|
|
292
292
|
*/
|
|
293
|
-
overrides?: FlatConfigItem[
|
|
293
|
+
overrides?: FlatConfigItem['rules'];
|
|
294
294
|
/**
|
|
295
295
|
* Enable TypeScript support.
|
|
296
296
|
*
|
|
@@ -317,19 +317,13 @@ interface AstroOptions {
|
|
|
317
317
|
/**
|
|
318
318
|
* Override rules.
|
|
319
319
|
*/
|
|
320
|
-
overrides?: FlatConfigItem[
|
|
320
|
+
overrides?: FlatConfigItem['rules'];
|
|
321
321
|
/**
|
|
322
322
|
* Enable TypeScript support.
|
|
323
323
|
*
|
|
324
324
|
* @default true
|
|
325
325
|
*/
|
|
326
326
|
typescript?: boolean;
|
|
327
|
-
/**
|
|
328
|
-
* Enable React A11y support.
|
|
329
|
-
*
|
|
330
|
-
* @default false
|
|
331
|
-
*/
|
|
332
|
-
a11y?: boolean;
|
|
333
327
|
/**
|
|
334
328
|
* Glob patterns for Astro files.
|
|
335
329
|
*
|
|
@@ -357,7 +351,7 @@ interface TailwindCSSOptions {
|
|
|
357
351
|
/**
|
|
358
352
|
* Override rules for for files with tailwind classes.
|
|
359
353
|
*/
|
|
360
|
-
overrides?: FlatConfigItem[
|
|
354
|
+
overrides?: FlatConfigItem['rules'];
|
|
361
355
|
}
|
|
362
356
|
declare function tailwindcss(options?: TailwindCSSOptions): Promise<FlatConfigItem[]>;
|
|
363
357
|
|
|
@@ -394,7 +388,7 @@ interface VendoredPrettierOptionsRequired {
|
|
|
394
388
|
/**
|
|
395
389
|
* Print trailing commas wherever possible.
|
|
396
390
|
*/
|
|
397
|
-
trailingComma:
|
|
391
|
+
trailingComma: 'none' | 'es5' | 'all';
|
|
398
392
|
/**
|
|
399
393
|
* Print spaces between brackets in object literals.
|
|
400
394
|
*/
|
|
@@ -423,12 +417,12 @@ interface VendoredPrettierOptionsRequired {
|
|
|
423
417
|
* In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
|
|
424
418
|
* @default "preserve"
|
|
425
419
|
*/
|
|
426
|
-
proseWrap:
|
|
420
|
+
proseWrap: 'always' | 'never' | 'preserve';
|
|
427
421
|
/**
|
|
428
422
|
* Include parentheses around a sole arrow function parameter.
|
|
429
423
|
* @default "always"
|
|
430
424
|
*/
|
|
431
|
-
arrowParens:
|
|
425
|
+
arrowParens: 'avoid' | 'always';
|
|
432
426
|
/**
|
|
433
427
|
* Provide ability to support new languages to prettier.
|
|
434
428
|
*/
|
|
@@ -437,17 +431,17 @@ interface VendoredPrettierOptionsRequired {
|
|
|
437
431
|
* How to handle whitespaces in HTML.
|
|
438
432
|
* @default "css"
|
|
439
433
|
*/
|
|
440
|
-
htmlWhitespaceSensitivity:
|
|
434
|
+
htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
|
|
441
435
|
/**
|
|
442
436
|
* Which end of line characters to apply.
|
|
443
437
|
* @default "lf"
|
|
444
438
|
*/
|
|
445
|
-
endOfLine:
|
|
439
|
+
endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
|
|
446
440
|
/**
|
|
447
441
|
* Change when properties in objects are quoted.
|
|
448
442
|
* @default "as-needed"
|
|
449
443
|
*/
|
|
450
|
-
quoteProps:
|
|
444
|
+
quoteProps: 'as-needed' | 'consistent' | 'preserve';
|
|
451
445
|
/**
|
|
452
446
|
* Whether or not to indent the code inside <script> and <style> tags in Vue files.
|
|
453
447
|
* @default false
|
|
@@ -466,13 +460,13 @@ interface FormattersOptions {
|
|
|
466
460
|
*
|
|
467
461
|
* Currently only support Prettier.
|
|
468
462
|
*/
|
|
469
|
-
css?:
|
|
463
|
+
css?: 'prettier' | boolean;
|
|
470
464
|
/**
|
|
471
465
|
* Enable formatting support for HTML.
|
|
472
466
|
*
|
|
473
467
|
* Currently only support Prettier.
|
|
474
468
|
*/
|
|
475
|
-
html?:
|
|
469
|
+
html?: 'prettier' | boolean;
|
|
476
470
|
/**
|
|
477
471
|
* Enable formatting support for Markdown.
|
|
478
472
|
*
|
|
@@ -480,11 +474,17 @@ interface FormattersOptions {
|
|
|
480
474
|
*
|
|
481
475
|
* When set to `true`, it will use Prettier.
|
|
482
476
|
*/
|
|
483
|
-
markdown?:
|
|
477
|
+
markdown?: 'prettier' | 'dprint' | boolean;
|
|
478
|
+
/**
|
|
479
|
+
* Enable formatting support for Astro.
|
|
480
|
+
*
|
|
481
|
+
* Currently only support Prettier.
|
|
482
|
+
*/
|
|
483
|
+
astro?: 'prettier' | boolean;
|
|
484
484
|
/**
|
|
485
485
|
* Enable formatting support for GraphQL.
|
|
486
486
|
*/
|
|
487
|
-
graphql?:
|
|
487
|
+
graphql?: 'prettier' | boolean;
|
|
488
488
|
/**
|
|
489
489
|
* Custom options for Prettier.
|
|
490
490
|
*
|
|
@@ -504,7 +504,7 @@ interface TOMLOptions {
|
|
|
504
504
|
/**
|
|
505
505
|
* Override rules.
|
|
506
506
|
*/
|
|
507
|
-
overrides?: FlatConfigItem[
|
|
507
|
+
overrides?: FlatConfigItem['rules'];
|
|
508
508
|
/**
|
|
509
509
|
* Enable stylistic rules.
|
|
510
510
|
*
|
|
@@ -527,8 +527,8 @@ type WrapRuleConfig<T extends {
|
|
|
527
527
|
[K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
|
|
528
528
|
};
|
|
529
529
|
type Awaitable<T> = T | Promise<T>;
|
|
530
|
-
type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions,
|
|
531
|
-
type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>,
|
|
530
|
+
type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<UnprefixedRuleOptions, 'style/'> & Prefix<Rules$1, 'antfu/'> & ReactHooksRules & ReactRules & RuleOptions$1 & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$2 & EslintCommentsRules>>;
|
|
531
|
+
type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
|
|
532
532
|
/**
|
|
533
533
|
* Custom name of each config item
|
|
534
534
|
*/
|
|
@@ -728,7 +728,7 @@ declare function toArray<T>(value: T | T[]): T[];
|
|
|
728
728
|
declare function interop<T>(m: Awaitable<T>): Promise<T extends {
|
|
729
729
|
default: infer U;
|
|
730
730
|
} ? U : T>;
|
|
731
|
-
declare function ensure(packages: string[]): Promise<void>;
|
|
731
|
+
declare function ensure(packages: (string | undefined)[]): Promise<void>;
|
|
732
732
|
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
733
733
|
declare function resolveSubOptions<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): ResolvedOptions<ConfigOptions[K]>;
|
|
734
734
|
declare function getOverrides<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): any;
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ declare function sortPackageJson(): FlatConfigItem[];
|
|
|
30
30
|
*/
|
|
31
31
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
32
32
|
|
|
33
|
-
type StylisticConfig = Pick<StylisticCustomizeOptions,
|
|
33
|
+
type StylisticConfig = Pick<StylisticCustomizeOptions, 'jsx' | 'indent' | 'quotes' | 'semi'>;
|
|
34
34
|
interface StylisticOptions {
|
|
35
35
|
/**
|
|
36
36
|
* Enable stylistic rules.
|
|
@@ -41,7 +41,7 @@ interface StylisticOptions {
|
|
|
41
41
|
/**
|
|
42
42
|
* Overrides for the config.
|
|
43
43
|
*/
|
|
44
|
-
overrides?: FlatConfigItem[
|
|
44
|
+
overrides?: FlatConfigItem['rules'];
|
|
45
45
|
}
|
|
46
46
|
declare function stylistic(options?: StylisticOptions): Promise<FlatConfigItem[]>;
|
|
47
47
|
|
|
@@ -64,7 +64,7 @@ interface JavaScriptOptions {
|
|
|
64
64
|
/**
|
|
65
65
|
* Overrides for the config.
|
|
66
66
|
*/
|
|
67
|
-
overrides?: FlatConfigItem[
|
|
67
|
+
overrides?: FlatConfigItem['rules'];
|
|
68
68
|
}
|
|
69
69
|
declare function javascript(options?: JavaScriptOptions): Promise<FlatConfigItem[]>;
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ interface JSDOCOptions {
|
|
|
78
78
|
/**
|
|
79
79
|
* Overrides for the config.
|
|
80
80
|
*/
|
|
81
|
-
overrides?: FlatConfigItem[
|
|
81
|
+
overrides?: FlatConfigItem['rules'];
|
|
82
82
|
}
|
|
83
83
|
declare function jsdoc(options?: JSDOCOptions): Promise<FlatConfigItem[]>;
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ interface JSONOptions {
|
|
|
86
86
|
/**
|
|
87
87
|
* Override rules.
|
|
88
88
|
*/
|
|
89
|
-
overrides?: FlatConfigItem[
|
|
89
|
+
overrides?: FlatConfigItem['rules'];
|
|
90
90
|
/**
|
|
91
91
|
* Enable stylistic rules.
|
|
92
92
|
*
|
|
@@ -107,7 +107,7 @@ interface MarkdownOptions {
|
|
|
107
107
|
/**
|
|
108
108
|
* Override rules.
|
|
109
109
|
*/
|
|
110
|
-
overrides?: FlatConfigItem[
|
|
110
|
+
overrides?: FlatConfigItem['rules'];
|
|
111
111
|
/**
|
|
112
112
|
* Additional extensions for components.
|
|
113
113
|
*
|
|
@@ -157,7 +157,7 @@ interface TypeScriptOptions {
|
|
|
157
157
|
/**
|
|
158
158
|
* Overrides for the config.
|
|
159
159
|
*/
|
|
160
|
-
overrides?: FlatConfigItem[
|
|
160
|
+
overrides?: FlatConfigItem['rules'];
|
|
161
161
|
}
|
|
162
162
|
declare function typescript(options?: TypeScriptOptions): Promise<FlatConfigItem[]>;
|
|
163
163
|
|
|
@@ -165,7 +165,7 @@ interface VueOptions {
|
|
|
165
165
|
/**
|
|
166
166
|
* Override rules.
|
|
167
167
|
*/
|
|
168
|
-
overrides?: FlatConfigItem[
|
|
168
|
+
overrides?: FlatConfigItem['rules'];
|
|
169
169
|
/**
|
|
170
170
|
* Enable stylistic rules.
|
|
171
171
|
*
|
|
@@ -199,7 +199,7 @@ interface YAMLOptions {
|
|
|
199
199
|
/**
|
|
200
200
|
* Override rules.
|
|
201
201
|
*/
|
|
202
|
-
overrides?: FlatConfigItem[
|
|
202
|
+
overrides?: FlatConfigItem['rules'];
|
|
203
203
|
/**
|
|
204
204
|
* Enable stylistic rules.
|
|
205
205
|
*
|
|
@@ -233,7 +233,7 @@ interface TestOptions {
|
|
|
233
233
|
/**
|
|
234
234
|
* Override rules for for test files.
|
|
235
235
|
*/
|
|
236
|
-
overrides?: FlatConfigItem[
|
|
236
|
+
overrides?: FlatConfigItem['rules'];
|
|
237
237
|
}
|
|
238
238
|
declare function test(options?: TestOptions): Promise<FlatConfigItem[]>;
|
|
239
239
|
|
|
@@ -260,7 +260,7 @@ interface UnoCSSOptions {
|
|
|
260
260
|
/**
|
|
261
261
|
* Override rules for for files with unocss classes.
|
|
262
262
|
*/
|
|
263
|
-
overrides?: FlatConfigItem[
|
|
263
|
+
overrides?: FlatConfigItem['rules'];
|
|
264
264
|
}
|
|
265
265
|
declare function unocss(options?: UnoCSSOptions): Promise<FlatConfigItem[]>;
|
|
266
266
|
|
|
@@ -275,7 +275,7 @@ interface NextJSOptions {
|
|
|
275
275
|
/**
|
|
276
276
|
* Override rules.
|
|
277
277
|
*/
|
|
278
|
-
overrides?: FlatConfigItem[
|
|
278
|
+
overrides?: FlatConfigItem['rules'];
|
|
279
279
|
/**
|
|
280
280
|
* Glob patterns for Next.js files.
|
|
281
281
|
*
|
|
@@ -290,7 +290,7 @@ interface ReactOptions {
|
|
|
290
290
|
/**
|
|
291
291
|
* Override rules.
|
|
292
292
|
*/
|
|
293
|
-
overrides?: FlatConfigItem[
|
|
293
|
+
overrides?: FlatConfigItem['rules'];
|
|
294
294
|
/**
|
|
295
295
|
* Enable TypeScript support.
|
|
296
296
|
*
|
|
@@ -317,19 +317,13 @@ interface AstroOptions {
|
|
|
317
317
|
/**
|
|
318
318
|
* Override rules.
|
|
319
319
|
*/
|
|
320
|
-
overrides?: FlatConfigItem[
|
|
320
|
+
overrides?: FlatConfigItem['rules'];
|
|
321
321
|
/**
|
|
322
322
|
* Enable TypeScript support.
|
|
323
323
|
*
|
|
324
324
|
* @default true
|
|
325
325
|
*/
|
|
326
326
|
typescript?: boolean;
|
|
327
|
-
/**
|
|
328
|
-
* Enable React A11y support.
|
|
329
|
-
*
|
|
330
|
-
* @default false
|
|
331
|
-
*/
|
|
332
|
-
a11y?: boolean;
|
|
333
327
|
/**
|
|
334
328
|
* Glob patterns for Astro files.
|
|
335
329
|
*
|
|
@@ -357,7 +351,7 @@ interface TailwindCSSOptions {
|
|
|
357
351
|
/**
|
|
358
352
|
* Override rules for for files with tailwind classes.
|
|
359
353
|
*/
|
|
360
|
-
overrides?: FlatConfigItem[
|
|
354
|
+
overrides?: FlatConfigItem['rules'];
|
|
361
355
|
}
|
|
362
356
|
declare function tailwindcss(options?: TailwindCSSOptions): Promise<FlatConfigItem[]>;
|
|
363
357
|
|
|
@@ -394,7 +388,7 @@ interface VendoredPrettierOptionsRequired {
|
|
|
394
388
|
/**
|
|
395
389
|
* Print trailing commas wherever possible.
|
|
396
390
|
*/
|
|
397
|
-
trailingComma:
|
|
391
|
+
trailingComma: 'none' | 'es5' | 'all';
|
|
398
392
|
/**
|
|
399
393
|
* Print spaces between brackets in object literals.
|
|
400
394
|
*/
|
|
@@ -423,12 +417,12 @@ interface VendoredPrettierOptionsRequired {
|
|
|
423
417
|
* In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
|
|
424
418
|
* @default "preserve"
|
|
425
419
|
*/
|
|
426
|
-
proseWrap:
|
|
420
|
+
proseWrap: 'always' | 'never' | 'preserve';
|
|
427
421
|
/**
|
|
428
422
|
* Include parentheses around a sole arrow function parameter.
|
|
429
423
|
* @default "always"
|
|
430
424
|
*/
|
|
431
|
-
arrowParens:
|
|
425
|
+
arrowParens: 'avoid' | 'always';
|
|
432
426
|
/**
|
|
433
427
|
* Provide ability to support new languages to prettier.
|
|
434
428
|
*/
|
|
@@ -437,17 +431,17 @@ interface VendoredPrettierOptionsRequired {
|
|
|
437
431
|
* How to handle whitespaces in HTML.
|
|
438
432
|
* @default "css"
|
|
439
433
|
*/
|
|
440
|
-
htmlWhitespaceSensitivity:
|
|
434
|
+
htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
|
|
441
435
|
/**
|
|
442
436
|
* Which end of line characters to apply.
|
|
443
437
|
* @default "lf"
|
|
444
438
|
*/
|
|
445
|
-
endOfLine:
|
|
439
|
+
endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
|
|
446
440
|
/**
|
|
447
441
|
* Change when properties in objects are quoted.
|
|
448
442
|
* @default "as-needed"
|
|
449
443
|
*/
|
|
450
|
-
quoteProps:
|
|
444
|
+
quoteProps: 'as-needed' | 'consistent' | 'preserve';
|
|
451
445
|
/**
|
|
452
446
|
* Whether or not to indent the code inside <script> and <style> tags in Vue files.
|
|
453
447
|
* @default false
|
|
@@ -466,13 +460,13 @@ interface FormattersOptions {
|
|
|
466
460
|
*
|
|
467
461
|
* Currently only support Prettier.
|
|
468
462
|
*/
|
|
469
|
-
css?:
|
|
463
|
+
css?: 'prettier' | boolean;
|
|
470
464
|
/**
|
|
471
465
|
* Enable formatting support for HTML.
|
|
472
466
|
*
|
|
473
467
|
* Currently only support Prettier.
|
|
474
468
|
*/
|
|
475
|
-
html?:
|
|
469
|
+
html?: 'prettier' | boolean;
|
|
476
470
|
/**
|
|
477
471
|
* Enable formatting support for Markdown.
|
|
478
472
|
*
|
|
@@ -480,11 +474,17 @@ interface FormattersOptions {
|
|
|
480
474
|
*
|
|
481
475
|
* When set to `true`, it will use Prettier.
|
|
482
476
|
*/
|
|
483
|
-
markdown?:
|
|
477
|
+
markdown?: 'prettier' | 'dprint' | boolean;
|
|
478
|
+
/**
|
|
479
|
+
* Enable formatting support for Astro.
|
|
480
|
+
*
|
|
481
|
+
* Currently only support Prettier.
|
|
482
|
+
*/
|
|
483
|
+
astro?: 'prettier' | boolean;
|
|
484
484
|
/**
|
|
485
485
|
* Enable formatting support for GraphQL.
|
|
486
486
|
*/
|
|
487
|
-
graphql?:
|
|
487
|
+
graphql?: 'prettier' | boolean;
|
|
488
488
|
/**
|
|
489
489
|
* Custom options for Prettier.
|
|
490
490
|
*
|
|
@@ -504,7 +504,7 @@ interface TOMLOptions {
|
|
|
504
504
|
/**
|
|
505
505
|
* Override rules.
|
|
506
506
|
*/
|
|
507
|
-
overrides?: FlatConfigItem[
|
|
507
|
+
overrides?: FlatConfigItem['rules'];
|
|
508
508
|
/**
|
|
509
509
|
* Enable stylistic rules.
|
|
510
510
|
*
|
|
@@ -527,8 +527,8 @@ type WrapRuleConfig<T extends {
|
|
|
527
527
|
[K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
|
|
528
528
|
};
|
|
529
529
|
type Awaitable<T> = T | Promise<T>;
|
|
530
|
-
type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions,
|
|
531
|
-
type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>,
|
|
530
|
+
type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<UnprefixedRuleOptions, 'style/'> & Prefix<Rules$1, 'antfu/'> & ReactHooksRules & ReactRules & RuleOptions$1 & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$2 & EslintCommentsRules>>;
|
|
531
|
+
type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
|
|
532
532
|
/**
|
|
533
533
|
* Custom name of each config item
|
|
534
534
|
*/
|
|
@@ -728,7 +728,7 @@ declare function toArray<T>(value: T | T[]): T[];
|
|
|
728
728
|
declare function interop<T>(m: Awaitable<T>): Promise<T extends {
|
|
729
729
|
default: infer U;
|
|
730
730
|
} ? U : T>;
|
|
731
|
-
declare function ensure(packages: string[]): Promise<void>;
|
|
731
|
+
declare function ensure(packages: (string | undefined)[]): Promise<void>;
|
|
732
732
|
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
733
733
|
declare function resolveSubOptions<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): ResolvedOptions<ConfigOptions[K]>;
|
|
734
734
|
declare function getOverrides<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): any;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import process3 from "node:process";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
|
-
import { isPackageExists as
|
|
4
|
+
import { isPackageExists as isPackageExists4 } from "local-pkg";
|
|
5
5
|
|
|
6
6
|
// src/configs/comments.ts
|
|
7
7
|
import eslintCommentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
|
|
@@ -13,8 +13,6 @@ async function comments() {
|
|
|
13
13
|
"eslint-comments": eslintCommentsPlugin
|
|
14
14
|
},
|
|
15
15
|
rules: {
|
|
16
|
-
// https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/disable-enable-pair.md
|
|
17
|
-
"eslint-comments/disable-enable-pair": "error",
|
|
18
16
|
// https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-aggregating-enable.md
|
|
19
17
|
"eslint-comments/no-aggregating-enable": "error",
|
|
20
18
|
// https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-duplicate-disable.md
|
|
@@ -433,7 +431,7 @@ async function imports(options = {}) {
|
|
|
433
431
|
"import/no-webpack-loader-syntax": "error",
|
|
434
432
|
"import/order": "error",
|
|
435
433
|
...stylistic2 ? {
|
|
436
|
-
"import/newline-after-import": ["error", {
|
|
434
|
+
"import/newline-after-import": ["error", { count: 1 }]
|
|
437
435
|
} : {}
|
|
438
436
|
}
|
|
439
437
|
},
|
|
@@ -738,25 +736,17 @@ async function ensure(packages) {
|
|
|
738
736
|
return;
|
|
739
737
|
}
|
|
740
738
|
;
|
|
741
|
-
const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
|
|
739
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
|
|
742
740
|
if (nonExistingPackages.length === 0) {
|
|
743
741
|
return;
|
|
744
742
|
}
|
|
745
|
-
;
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
name: "result",
|
|
750
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
751
|
-
type: "confirm"
|
|
752
|
-
}
|
|
753
|
-
]);
|
|
743
|
+
const p = await import("@clack/prompts");
|
|
744
|
+
const result = await p.confirm({
|
|
745
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
746
|
+
});
|
|
754
747
|
if (result) {
|
|
755
|
-
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, {
|
|
756
|
-
dev: true
|
|
757
|
-
}));
|
|
748
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
758
749
|
}
|
|
759
|
-
;
|
|
760
750
|
}
|
|
761
751
|
function resolveSubOptions(options, key) {
|
|
762
752
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
@@ -984,8 +974,8 @@ import pluginAntfu3 from "eslint-plugin-antfu";
|
|
|
984
974
|
var StylisticConfigDefaults = {
|
|
985
975
|
indent: 2,
|
|
986
976
|
jsx: true,
|
|
987
|
-
quotes: "
|
|
988
|
-
semi:
|
|
977
|
+
quotes: "single",
|
|
978
|
+
semi: false
|
|
989
979
|
};
|
|
990
980
|
async function stylistic(options = {}) {
|
|
991
981
|
const {
|
|
@@ -1167,6 +1157,8 @@ async function typescript(options = {}) {
|
|
|
1167
1157
|
"error",
|
|
1168
1158
|
{ disallowTypeAnnotations: false, prefer: "type-imports" }
|
|
1169
1159
|
],
|
|
1160
|
+
"ts/method-signature-style": ["error", "property"],
|
|
1161
|
+
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
|
|
1170
1162
|
"ts/no-dupe-class-members": "error",
|
|
1171
1163
|
"ts/no-dynamic-delete": "off",
|
|
1172
1164
|
"ts/no-explicit-any": "off",
|
|
@@ -1436,7 +1428,7 @@ async function yaml(options = {}) {
|
|
|
1436
1428
|
]);
|
|
1437
1429
|
const {
|
|
1438
1430
|
indent = 2,
|
|
1439
|
-
quotes = "
|
|
1431
|
+
quotes = "single"
|
|
1440
1432
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1441
1433
|
return [
|
|
1442
1434
|
{
|
|
@@ -1931,29 +1923,29 @@ async function react(options = {}) {
|
|
|
1931
1923
|
// src/configs/frameworks/astro.ts
|
|
1932
1924
|
async function astro(options) {
|
|
1933
1925
|
const {
|
|
1934
|
-
a11y = false,
|
|
1935
1926
|
files = [GLOB_ASTRO],
|
|
1936
1927
|
overrides = {},
|
|
1937
1928
|
typescript: typescript2 = true,
|
|
1938
1929
|
stylistic: stylistic2 = true
|
|
1939
1930
|
} = options;
|
|
1931
|
+
await ensure([
|
|
1932
|
+
"eslint-plugin-astro",
|
|
1933
|
+
"astro-eslint-parser"
|
|
1934
|
+
]);
|
|
1940
1935
|
const [
|
|
1941
1936
|
pluginAstro,
|
|
1942
1937
|
parserAstro,
|
|
1943
|
-
parserTs
|
|
1944
|
-
pluginA11y
|
|
1938
|
+
parserTs
|
|
1945
1939
|
] = await Promise.all([
|
|
1946
1940
|
interop(import("eslint-plugin-astro")),
|
|
1947
1941
|
interop(import("astro-eslint-parser")),
|
|
1948
|
-
interop(import("@typescript-eslint/parser"))
|
|
1949
|
-
...a11y ? [interop(import("eslint-plugin-jsx-a11y"))] : []
|
|
1942
|
+
interop(import("@typescript-eslint/parser"))
|
|
1950
1943
|
]);
|
|
1951
1944
|
return [
|
|
1952
1945
|
{
|
|
1953
1946
|
name: "luxass:astro:setup",
|
|
1954
1947
|
plugins: {
|
|
1955
|
-
astro: pluginAstro
|
|
1956
|
-
...a11y ? { "jsx-a11y": pluginA11y } : {}
|
|
1948
|
+
astro: pluginAstro
|
|
1957
1949
|
}
|
|
1958
1950
|
},
|
|
1959
1951
|
{
|
|
@@ -2075,18 +2067,21 @@ async function tailwindcss(options = {}) {
|
|
|
2075
2067
|
|
|
2076
2068
|
// src/configs/formatters.ts
|
|
2077
2069
|
import * as parserPlain2 from "eslint-parser-plain";
|
|
2070
|
+
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
2078
2071
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
2079
|
-
await ensure([
|
|
2080
|
-
"eslint-plugin-format"
|
|
2081
|
-
]);
|
|
2082
2072
|
if (options === true) {
|
|
2083
2073
|
options = {
|
|
2074
|
+
astro: isPackageExists3("astro"),
|
|
2084
2075
|
css: true,
|
|
2085
2076
|
graphql: true,
|
|
2086
2077
|
html: true,
|
|
2087
2078
|
markdown: true
|
|
2088
2079
|
};
|
|
2089
2080
|
}
|
|
2081
|
+
await ensure([
|
|
2082
|
+
"eslint-plugin-format",
|
|
2083
|
+
options.astro ? "prettier-plugin-astro" : void 0
|
|
2084
|
+
]);
|
|
2090
2085
|
const {
|
|
2091
2086
|
indent,
|
|
2092
2087
|
quotes,
|
|
@@ -2217,6 +2212,27 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
2217
2212
|
}
|
|
2218
2213
|
});
|
|
2219
2214
|
}
|
|
2215
|
+
if (options.astro) {
|
|
2216
|
+
configs.push({
|
|
2217
|
+
name: "luxass:formatter:astro",
|
|
2218
|
+
files: [GLOB_ASTRO],
|
|
2219
|
+
languageOptions: {
|
|
2220
|
+
parser: parserPlain2
|
|
2221
|
+
},
|
|
2222
|
+
rules: {
|
|
2223
|
+
"format/prettier": [
|
|
2224
|
+
"error",
|
|
2225
|
+
{
|
|
2226
|
+
...prettierOptions,
|
|
2227
|
+
parser: "astro",
|
|
2228
|
+
plugins: [
|
|
2229
|
+
"prettier-plugin-astro"
|
|
2230
|
+
]
|
|
2231
|
+
}
|
|
2232
|
+
]
|
|
2233
|
+
}
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2220
2236
|
if (options.graphql) {
|
|
2221
2237
|
configs.push({
|
|
2222
2238
|
name: "luxass:formatter:graphql",
|
|
@@ -2324,9 +2340,9 @@ async function luxass(options = {}, ...userConfigs) {
|
|
|
2324
2340
|
nextjs: enableNextJS = false,
|
|
2325
2341
|
react: enableReact = false,
|
|
2326
2342
|
tailwindcss: enableTailwindCSS = false,
|
|
2327
|
-
typescript: enableTypeScript =
|
|
2343
|
+
typescript: enableTypeScript = isPackageExists4("typescript"),
|
|
2328
2344
|
unocss: enableUnoCSS = false,
|
|
2329
|
-
vue: enableVue = VuePackages.some((i) =>
|
|
2345
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
|
|
2330
2346
|
} = options;
|
|
2331
2347
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2332
2348
|
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/eslint-config",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.10",
|
|
4
4
|
"description": "ESLint config for @luxass",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@antfu/eslint-define-config": "^1.23.0-2",
|
|
94
94
|
"@antfu/install-pkg": "^0.3.1",
|
|
95
|
+
"@clack/prompts": "^0.7.0",
|
|
95
96
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
|
|
96
97
|
"@eslint-types/jsdoc": "^48.2.0",
|
|
97
98
|
"@eslint-types/typescript-eslint": "^7.0.2",
|
|
@@ -121,7 +122,6 @@
|
|
|
121
122
|
"jsonc-eslint-parser": "^2.4.0",
|
|
122
123
|
"local-pkg": "^0.5.0",
|
|
123
124
|
"parse-gitignore": "^2.0.0",
|
|
124
|
-
"prompts": "^2.4.2",
|
|
125
125
|
"toml-eslint-parser": "^0.9.3",
|
|
126
126
|
"vue-eslint-parser": "^9.4.2",
|
|
127
127
|
"yaml-eslint-parser": "^1.2.2"
|
|
@@ -133,7 +133,6 @@
|
|
|
133
133
|
"@types/eslint": "^8.56.5",
|
|
134
134
|
"@types/estree": "^1.0.5",
|
|
135
135
|
"@types/node": "^18.17.19",
|
|
136
|
-
"@types/prompts": "^2.4.9",
|
|
137
136
|
"@typescript-eslint/rule-tester": "^7.2.0",
|
|
138
137
|
"@unocss/eslint-plugin": "^0.58.5",
|
|
139
138
|
"astro-eslint-parser": "^0.16.3",
|