@ivanmaxlogiudice/eslint-config 1.0.9 → 1.0.11
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 +79 -8
- package/dist/cli.cjs +6 -5
- package/dist/cli.js +6 -5
- package/dist/index.cjs +69 -27
- package/dist/index.d.cts +32 -10
- package/dist/index.d.ts +32 -10
- package/dist/index.js +68 -27
- package/package.json +22 -19
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package
|
|
|
32
32
|
// eslint.config.js
|
|
33
33
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
34
34
|
|
|
35
|
-
export default config()
|
|
35
|
+
export default await config()
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
With CJS:
|
|
@@ -44,6 +44,32 @@ const config = require('@ivanmaxlogiudice/eslint-config').default
|
|
|
44
44
|
module.exports = config()
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Combined with legacy config:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
// eslint.config.js
|
|
51
|
+
const config = require('@ivanmaxlogiudice/eslint-config').default
|
|
52
|
+
const { FlatCompat } = require('@eslint/eslintrc')
|
|
53
|
+
|
|
54
|
+
const compat = new FlatCompat()
|
|
55
|
+
|
|
56
|
+
module.exports = config(
|
|
57
|
+
{
|
|
58
|
+
ignores: [],
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// Legacy config
|
|
62
|
+
...compat.config({
|
|
63
|
+
extends: [
|
|
64
|
+
'eslint:recommended',
|
|
65
|
+
// Other extends...
|
|
66
|
+
],
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// Other flat configs...
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
47
73
|
> Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
|
|
48
74
|
|
|
49
75
|
### Add script for package.json
|
|
@@ -135,7 +161,7 @@ Normally you only need to import the `config` preset:
|
|
|
135
161
|
// eslint.config.js
|
|
136
162
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
137
163
|
|
|
138
|
-
export default config()
|
|
164
|
+
export default await config()
|
|
139
165
|
```
|
|
140
166
|
|
|
141
167
|
And that's it! Or you can configure each integration individually, for example:
|
|
@@ -144,7 +170,7 @@ And that's it! Or you can configure each integration individually, for example:
|
|
|
144
170
|
// eslint.config.js
|
|
145
171
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
146
172
|
|
|
147
|
-
export default config({
|
|
173
|
+
export default await config({
|
|
148
174
|
// Enable stylistic formatting rules
|
|
149
175
|
// stylistic: true,
|
|
150
176
|
|
|
@@ -176,7 +202,7 @@ The `config` factory function also accepts any number of arbitrary custom config
|
|
|
176
202
|
// eslint.config.js
|
|
177
203
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
178
204
|
|
|
179
|
-
export default config(
|
|
205
|
+
export default await config(
|
|
180
206
|
{
|
|
181
207
|
// Configuration
|
|
182
208
|
},
|
|
@@ -279,7 +305,7 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
|
|
|
279
305
|
// eslint.config.js
|
|
280
306
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
281
307
|
|
|
282
|
-
export default config(
|
|
308
|
+
export default await config(
|
|
283
309
|
{
|
|
284
310
|
typescript: true,
|
|
285
311
|
vue: true
|
|
@@ -300,13 +326,13 @@ export default config(
|
|
|
300
326
|
)
|
|
301
327
|
```
|
|
302
328
|
|
|
303
|
-
We also provided
|
|
329
|
+
We also provided a `overrides` options to make it easier:
|
|
304
330
|
|
|
305
331
|
```js
|
|
306
332
|
// eslint.config.js
|
|
307
333
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
308
334
|
|
|
309
|
-
export default config({
|
|
335
|
+
export default await config({
|
|
310
336
|
overrides: {
|
|
311
337
|
typescript: {
|
|
312
338
|
'ts/consistent-type-definitions': ['error', 'interface'],
|
|
@@ -320,6 +346,51 @@ export default config({
|
|
|
320
346
|
})
|
|
321
347
|
```
|
|
322
348
|
|
|
349
|
+
### Optional Configs
|
|
350
|
+
|
|
351
|
+
We provide some optional configs for specific use cases, that we don't include their dependencies by default.
|
|
352
|
+
|
|
353
|
+
#### UnoCSS
|
|
354
|
+
|
|
355
|
+
UnoCSS is auto-detected, you can also explicitly enable them:
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
// eslint.config.js
|
|
359
|
+
import config from '@ivanmaxlogiudice/eslint-config'
|
|
360
|
+
|
|
361
|
+
export default config({
|
|
362
|
+
unocss: true,
|
|
363
|
+
})
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Running `pnpm dlx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
pnpm add -D @unocss/eslint-plugin
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Optional Rules
|
|
373
|
+
|
|
374
|
+
This config also provides some optional plugins/rules for extended usages.
|
|
375
|
+
|
|
376
|
+
#### `perfectionist` (sorting)
|
|
377
|
+
|
|
378
|
+
This plugin [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) allows you to sorted object keys, imports, etc, with auto-fix.
|
|
379
|
+
|
|
380
|
+
The plugin is installed, you can check the [enabled rules](/src/configs/perfectionist.ts) for more info.
|
|
381
|
+
|
|
382
|
+
It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
|
|
383
|
+
|
|
384
|
+
```js
|
|
385
|
+
/* eslint perfectionist/sort-objects: "error" */
|
|
386
|
+
const objectWantedToSort = {
|
|
387
|
+
a: 2,
|
|
388
|
+
b: 1,
|
|
389
|
+
c: 3,
|
|
390
|
+
}
|
|
391
|
+
/* eslint perfectionist/sort-objects: "off" */
|
|
392
|
+
```
|
|
393
|
+
|
|
323
394
|
### Type Aware Rules
|
|
324
395
|
|
|
325
396
|
You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
|
|
@@ -328,7 +399,7 @@ You can optionally enable the [type aware rules](https://typescript-eslint.io/li
|
|
|
328
399
|
// eslint.config.js
|
|
329
400
|
import config from '@ivanmaxlogiudice/eslint-config'
|
|
330
401
|
|
|
331
|
-
export default config({
|
|
402
|
+
export default await config({
|
|
332
403
|
typescript: {
|
|
333
404
|
tsconfigPath: 'tsconfig.json',
|
|
334
405
|
|
package/dist/cli.cjs
CHANGED
|
@@ -35,12 +35,13 @@ var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
|
35
35
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
36
36
|
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "1.0.
|
|
38
|
+
var version = "1.0.11";
|
|
39
39
|
var devDependencies = {
|
|
40
40
|
"@types/eslint": "^8.44.7",
|
|
41
41
|
"@types/fs-extra": "^11.0.4",
|
|
42
|
-
"@types/node": "^20.
|
|
43
|
-
"@types/prompts": "^2.4.
|
|
42
|
+
"@types/node": "^20.10.0",
|
|
43
|
+
"@types/prompts": "^2.4.9",
|
|
44
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
44
45
|
bumpp: "^9.2.0",
|
|
45
46
|
eslint: "^8.54.0",
|
|
46
47
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
@@ -49,8 +50,8 @@ var devDependencies = {
|
|
|
49
50
|
"fs-extra": "^11.1.1",
|
|
50
51
|
"lint-staged": "^15.1.0",
|
|
51
52
|
"simple-git-hooks": "^2.9.0",
|
|
52
|
-
tsup: "^8.0.
|
|
53
|
-
typescript: "^5.
|
|
53
|
+
tsup: "^8.0.1",
|
|
54
|
+
typescript: "^5.3.2",
|
|
54
55
|
vitest: "^0.34.6"
|
|
55
56
|
};
|
|
56
57
|
|
package/dist/cli.js
CHANGED
|
@@ -6,12 +6,13 @@ import c4 from "picocolors";
|
|
|
6
6
|
import c from "picocolors";
|
|
7
7
|
|
|
8
8
|
// package.json
|
|
9
|
-
var version = "1.0.
|
|
9
|
+
var version = "1.0.11";
|
|
10
10
|
var devDependencies = {
|
|
11
11
|
"@types/eslint": "^8.44.7",
|
|
12
12
|
"@types/fs-extra": "^11.0.4",
|
|
13
|
-
"@types/node": "^20.
|
|
14
|
-
"@types/prompts": "^2.4.
|
|
13
|
+
"@types/node": "^20.10.0",
|
|
14
|
+
"@types/prompts": "^2.4.9",
|
|
15
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
15
16
|
bumpp: "^9.2.0",
|
|
16
17
|
eslint: "^8.54.0",
|
|
17
18
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
@@ -20,8 +21,8 @@ var devDependencies = {
|
|
|
20
21
|
"fs-extra": "^11.1.1",
|
|
21
22
|
"lint-staged": "^15.1.0",
|
|
22
23
|
"simple-git-hooks": "^2.9.0",
|
|
23
|
-
tsup: "^8.0.
|
|
24
|
-
typescript: "^5.
|
|
24
|
+
tsup: "^8.0.1",
|
|
25
|
+
typescript: "^5.3.2",
|
|
25
26
|
vitest: "^0.34.6"
|
|
26
27
|
};
|
|
27
28
|
|
package/dist/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ __export(src_exports, {
|
|
|
58
58
|
comments: () => comments,
|
|
59
59
|
config: () => config,
|
|
60
60
|
default: () => src_default,
|
|
61
|
+
ensurePackages: () => ensurePackages,
|
|
61
62
|
ignores: () => ignores,
|
|
62
63
|
imports: () => imports,
|
|
63
64
|
interopDefault: () => interopDefault,
|
|
@@ -83,10 +84,13 @@ module.exports = __toCommonJS(src_exports);
|
|
|
83
84
|
|
|
84
85
|
// src/factory.ts
|
|
85
86
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
86
|
-
var
|
|
87
|
-
var
|
|
87
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
88
|
+
var import_local_pkg2 = require("local-pkg");
|
|
88
89
|
|
|
89
90
|
// src/utils.ts
|
|
91
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
92
|
+
var import_local_pkg = require("local-pkg");
|
|
93
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
90
94
|
async function combine(...configs) {
|
|
91
95
|
const resolved = await Promise.all(configs);
|
|
92
96
|
return resolved.flat();
|
|
@@ -107,6 +111,24 @@ async function interopDefault(m) {
|
|
|
107
111
|
const resolved = await m;
|
|
108
112
|
return resolved.default || resolved;
|
|
109
113
|
}
|
|
114
|
+
async function ensurePackages(packages) {
|
|
115
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
|
|
116
|
+
return;
|
|
117
|
+
const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
|
|
118
|
+
if (nonExistingPackages.length === 0)
|
|
119
|
+
return;
|
|
120
|
+
const { default: prompts } = await import("prompts");
|
|
121
|
+
const { result } = await prompts([
|
|
122
|
+
{
|
|
123
|
+
initial: true,
|
|
124
|
+
message: `The following ${nonExistingPackages.length === 1 ? "package is" : "packages are"} required for this config: ${import_picocolors.default.green(nonExistingPackages.join(import_picocolors.default.white(", ")))}. Do you want to install them?`,
|
|
125
|
+
name: "result",
|
|
126
|
+
type: "confirm"
|
|
127
|
+
}
|
|
128
|
+
]);
|
|
129
|
+
if (result)
|
|
130
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
131
|
+
}
|
|
110
132
|
|
|
111
133
|
// src/configs/comments.ts
|
|
112
134
|
async function comments() {
|
|
@@ -344,7 +366,6 @@ async function javascript(options = {}) {
|
|
|
344
366
|
"no-implied-eval": "error",
|
|
345
367
|
"no-import-assign": "error",
|
|
346
368
|
"no-invalid-regexp": "error",
|
|
347
|
-
"no-invalid-this": "error",
|
|
348
369
|
"no-irregular-whitespace": "error",
|
|
349
370
|
"no-iterator": "error",
|
|
350
371
|
"no-labels": ["error", {
|
|
@@ -537,6 +558,7 @@ async function jsdoc(options = {}) {
|
|
|
537
558
|
// src/configs/jsonc.ts
|
|
538
559
|
async function jsonc(options = {}) {
|
|
539
560
|
const {
|
|
561
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
540
562
|
overrides = {},
|
|
541
563
|
stylistic: stylistic2 = true
|
|
542
564
|
} = options;
|
|
@@ -558,7 +580,7 @@ async function jsonc(options = {}) {
|
|
|
558
580
|
}
|
|
559
581
|
},
|
|
560
582
|
{
|
|
561
|
-
files
|
|
583
|
+
files,
|
|
562
584
|
languageOptions: {
|
|
563
585
|
parser: parserJsonc
|
|
564
586
|
},
|
|
@@ -620,6 +642,7 @@ async function jsonc(options = {}) {
|
|
|
620
642
|
async function markdown(options = {}) {
|
|
621
643
|
const {
|
|
622
644
|
componentExts = [],
|
|
645
|
+
files = [GLOB_MARKDOWN],
|
|
623
646
|
overrides = {}
|
|
624
647
|
} = options;
|
|
625
648
|
const pluginMarkdown = await interopDefault(import("eslint-plugin-markdown"));
|
|
@@ -631,7 +654,7 @@ async function markdown(options = {}) {
|
|
|
631
654
|
}
|
|
632
655
|
},
|
|
633
656
|
{
|
|
634
|
-
files
|
|
657
|
+
files,
|
|
635
658
|
name: "config:markdown:processor",
|
|
636
659
|
processor: "markdown/markdown"
|
|
637
660
|
},
|
|
@@ -1002,7 +1025,7 @@ function sortTsconfig() {
|
|
|
1002
1025
|
}
|
|
1003
1026
|
|
|
1004
1027
|
// src/configs/stylistic.ts
|
|
1005
|
-
async function stylistic(options) {
|
|
1028
|
+
async function stylistic(options = {}) {
|
|
1006
1029
|
const {
|
|
1007
1030
|
indent = 4,
|
|
1008
1031
|
jsx = true,
|
|
@@ -1047,6 +1070,7 @@ async function stylistic(options) {
|
|
|
1047
1070
|
// src/configs/test.ts
|
|
1048
1071
|
async function test(options = {}) {
|
|
1049
1072
|
const {
|
|
1073
|
+
files = GLOB_TESTS,
|
|
1050
1074
|
isInEditor = false,
|
|
1051
1075
|
overrides = {}
|
|
1052
1076
|
} = options;
|
|
@@ -1073,7 +1097,7 @@ async function test(options = {}) {
|
|
|
1073
1097
|
}
|
|
1074
1098
|
},
|
|
1075
1099
|
{
|
|
1076
|
-
files
|
|
1100
|
+
files,
|
|
1077
1101
|
name: "config:test:rules",
|
|
1078
1102
|
rules: {
|
|
1079
1103
|
"node/prefer-global/process": "off",
|
|
@@ -1089,13 +1113,17 @@ async function test(options = {}) {
|
|
|
1089
1113
|
}
|
|
1090
1114
|
|
|
1091
1115
|
// src/configs/typescript.ts
|
|
1092
|
-
var
|
|
1093
|
-
async function typescript(options) {
|
|
1116
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
1117
|
+
async function typescript(options = {}) {
|
|
1094
1118
|
const {
|
|
1095
1119
|
componentExts = [],
|
|
1096
1120
|
overrides = {},
|
|
1097
1121
|
parserOptions = {}
|
|
1098
|
-
} = options
|
|
1122
|
+
} = options;
|
|
1123
|
+
const files = options.files ?? [
|
|
1124
|
+
GLOB_SRC,
|
|
1125
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1126
|
+
];
|
|
1099
1127
|
const typeAwareRules = {
|
|
1100
1128
|
"dot-notation": "off",
|
|
1101
1129
|
"no-implied-eval": "off",
|
|
@@ -1135,10 +1163,7 @@ async function typescript(options) {
|
|
|
1135
1163
|
}
|
|
1136
1164
|
},
|
|
1137
1165
|
{
|
|
1138
|
-
files
|
|
1139
|
-
GLOB_SRC,
|
|
1140
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1141
|
-
],
|
|
1166
|
+
files,
|
|
1142
1167
|
languageOptions: {
|
|
1143
1168
|
parser: parserTs,
|
|
1144
1169
|
parserOptions: {
|
|
@@ -1146,7 +1171,7 @@ async function typescript(options) {
|
|
|
1146
1171
|
sourceType: "module",
|
|
1147
1172
|
...tsconfigPath ? {
|
|
1148
1173
|
project: tsconfigPath,
|
|
1149
|
-
tsconfigRootDir:
|
|
1174
|
+
tsconfigRootDir: import_node_process2.default.cwd()
|
|
1150
1175
|
} : {},
|
|
1151
1176
|
...parserOptions
|
|
1152
1177
|
}
|
|
@@ -1166,7 +1191,6 @@ async function typescript(options) {
|
|
|
1166
1191
|
"antfu/generic-spacing": "error",
|
|
1167
1192
|
"antfu/named-tuple-spacing": "error",
|
|
1168
1193
|
"no-dupe-class-members": "off",
|
|
1169
|
-
"no-invalid-this": "off",
|
|
1170
1194
|
"no-loss-of-precision": "off",
|
|
1171
1195
|
"no-redeclare": "off",
|
|
1172
1196
|
"no-use-before-define": "off",
|
|
@@ -1191,7 +1215,6 @@ async function typescript(options) {
|
|
|
1191
1215
|
"ts/no-explicit-any": "off",
|
|
1192
1216
|
"ts/no-extraneous-class": "off",
|
|
1193
1217
|
"ts/no-import-type-side-effects": "error",
|
|
1194
|
-
"ts/no-invalid-this": "error",
|
|
1195
1218
|
"ts/no-invalid-void-type": "off",
|
|
1196
1219
|
"ts/no-loss-of-precision": "error",
|
|
1197
1220
|
"ts/no-non-null-assertion": "off",
|
|
@@ -1315,7 +1338,14 @@ async function unicorn() {
|
|
|
1315
1338
|
}
|
|
1316
1339
|
|
|
1317
1340
|
// src/configs/unocss.ts
|
|
1318
|
-
async function unocss() {
|
|
1341
|
+
async function unocss(options = {}) {
|
|
1342
|
+
const {
|
|
1343
|
+
attributify = true,
|
|
1344
|
+
strict = false
|
|
1345
|
+
} = options;
|
|
1346
|
+
await ensurePackages([
|
|
1347
|
+
"@unocss/eslint-plugin"
|
|
1348
|
+
]);
|
|
1319
1349
|
const pluginUnocss = await interopDefault(import("@unocss/eslint-plugin"));
|
|
1320
1350
|
return [
|
|
1321
1351
|
{
|
|
@@ -1324,7 +1354,13 @@ async function unocss() {
|
|
|
1324
1354
|
"@unocss": pluginUnocss
|
|
1325
1355
|
},
|
|
1326
1356
|
rules: {
|
|
1327
|
-
|
|
1357
|
+
"unocss/order": "warn",
|
|
1358
|
+
...attributify ? {
|
|
1359
|
+
"unocss/order-attributify": "warn"
|
|
1360
|
+
} : {},
|
|
1361
|
+
...strict ? {
|
|
1362
|
+
"unocss/blocklist": "error"
|
|
1363
|
+
} : {}
|
|
1328
1364
|
}
|
|
1329
1365
|
}
|
|
1330
1366
|
];
|
|
@@ -1333,6 +1369,7 @@ async function unocss() {
|
|
|
1333
1369
|
// src/configs/vue.ts
|
|
1334
1370
|
async function vue(options = {}) {
|
|
1335
1371
|
const {
|
|
1372
|
+
files = [GLOB_VUE],
|
|
1336
1373
|
overrides = {},
|
|
1337
1374
|
stylistic: stylistic2 = true
|
|
1338
1375
|
} = options;
|
|
@@ -1355,7 +1392,7 @@ async function vue(options = {}) {
|
|
|
1355
1392
|
}
|
|
1356
1393
|
},
|
|
1357
1394
|
{
|
|
1358
|
-
files
|
|
1395
|
+
files,
|
|
1359
1396
|
languageOptions: {
|
|
1360
1397
|
parser: parserVue,
|
|
1361
1398
|
parserOptions: {
|
|
@@ -1480,6 +1517,7 @@ async function vue(options = {}) {
|
|
|
1480
1517
|
// src/configs/yaml.ts
|
|
1481
1518
|
async function yaml(options = {}) {
|
|
1482
1519
|
const {
|
|
1520
|
+
files = [GLOB_YAML],
|
|
1483
1521
|
overrides = {},
|
|
1484
1522
|
stylistic: stylistic2 = true
|
|
1485
1523
|
} = options;
|
|
@@ -1502,7 +1540,7 @@ async function yaml(options = {}) {
|
|
|
1502
1540
|
}
|
|
1503
1541
|
},
|
|
1504
1542
|
{
|
|
1505
|
-
files
|
|
1543
|
+
files,
|
|
1506
1544
|
languageOptions: {
|
|
1507
1545
|
parser: parserYaml
|
|
1508
1546
|
},
|
|
@@ -1563,11 +1601,11 @@ async function config(options = {}, ...userConfigs) {
|
|
|
1563
1601
|
const {
|
|
1564
1602
|
componentExts = [],
|
|
1565
1603
|
gitignore: enableGitignore = true,
|
|
1566
|
-
isInEditor = !!((
|
|
1604
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
1567
1605
|
overrides = {},
|
|
1568
|
-
typescript: enableTypeScript = (0,
|
|
1569
|
-
unocss:
|
|
1570
|
-
vue: enableVue = VuePackages.some((i) => (0,
|
|
1606
|
+
typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
|
|
1607
|
+
unocss: enableUnoCSS = UnocssPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
1608
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg2.isPackageExists)(i))
|
|
1571
1609
|
} = options;
|
|
1572
1610
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1573
1611
|
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
@@ -1613,8 +1651,11 @@ async function config(options = {}, ...userConfigs) {
|
|
|
1613
1651
|
}
|
|
1614
1652
|
if (stylisticOptions)
|
|
1615
1653
|
configs.push(stylistic(stylisticOptions));
|
|
1616
|
-
if (
|
|
1617
|
-
configs.push(unocss(
|
|
1654
|
+
if (enableUnoCSS) {
|
|
1655
|
+
configs.push(unocss(
|
|
1656
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1657
|
+
));
|
|
1658
|
+
}
|
|
1618
1659
|
if (options.test ?? true) {
|
|
1619
1660
|
configs.push(test({
|
|
1620
1661
|
isInEditor,
|
|
@@ -1695,6 +1736,7 @@ var src_default = config;
|
|
|
1695
1736
|
combine,
|
|
1696
1737
|
comments,
|
|
1697
1738
|
config,
|
|
1739
|
+
ensurePackages,
|
|
1698
1740
|
ignores,
|
|
1699
1741
|
imports,
|
|
1700
1742
|
interopDefault,
|
package/dist/index.d.cts
CHANGED
|
@@ -30,6 +30,12 @@ type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
|
|
|
30
30
|
plugins?: Record<string, any>;
|
|
31
31
|
};
|
|
32
32
|
type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
|
|
33
|
+
interface OptionsFiles {
|
|
34
|
+
/**
|
|
35
|
+
* Override the `files` option to provide custom globs.
|
|
36
|
+
*/
|
|
37
|
+
files?: string[];
|
|
38
|
+
}
|
|
33
39
|
interface OptionsComponentExts {
|
|
34
40
|
/**
|
|
35
41
|
* Additional extensions for components.
|
|
@@ -66,6 +72,18 @@ interface OptionsOverrides {
|
|
|
66
72
|
interface OptionsIsInEditor {
|
|
67
73
|
isInEditor?: boolean;
|
|
68
74
|
}
|
|
75
|
+
interface OptionsUnoCSS {
|
|
76
|
+
/**
|
|
77
|
+
* Enable attributify support.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
attributify?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Enable strict mode by throwing errors about blocklisted classes.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
strict?: boolean;
|
|
86
|
+
}
|
|
69
87
|
interface OptionsConfig extends OptionsComponentExts {
|
|
70
88
|
/**
|
|
71
89
|
* Enable gitignore support.
|
|
@@ -137,9 +155,12 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
137
155
|
/**
|
|
138
156
|
* Enable unocss rules.
|
|
139
157
|
*
|
|
158
|
+
* Requires installing:
|
|
159
|
+
* - `@unocss/eslint-plugin`
|
|
160
|
+
*
|
|
140
161
|
* @default auto-detect based on the dependencies
|
|
141
162
|
*/
|
|
142
|
-
unocss?: boolean;
|
|
163
|
+
unocss?: boolean | OptionsUnoCSS;
|
|
143
164
|
/**
|
|
144
165
|
* Enable Vue support.
|
|
145
166
|
*
|
|
@@ -169,9 +190,9 @@ declare function javascript(options?: OptionsIsInEditor & OptionsOverrides): Pro
|
|
|
169
190
|
|
|
170
191
|
declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
171
192
|
|
|
172
|
-
declare function jsonc(options?: OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
193
|
+
declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
173
194
|
|
|
174
|
-
declare function markdown(options?: OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
195
|
+
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
175
196
|
|
|
176
197
|
declare function node(): Promise<FlatConfigItem[]>;
|
|
177
198
|
|
|
@@ -190,19 +211,19 @@ declare function sortPackageJson(): FlatConfigItem[];
|
|
|
190
211
|
*/
|
|
191
212
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
192
213
|
|
|
193
|
-
declare function stylistic(options
|
|
214
|
+
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
194
215
|
|
|
195
|
-
declare function test(options?: OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
216
|
+
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
196
217
|
|
|
197
|
-
declare function typescript(options?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
218
|
+
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
198
219
|
|
|
199
220
|
declare function unicorn(): Promise<FlatConfigItem[]>;
|
|
200
221
|
|
|
201
|
-
declare function unocss(): Promise<FlatConfigItem[]>;
|
|
222
|
+
declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
|
|
202
223
|
|
|
203
|
-
declare function vue(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
224
|
+
declare function vue(options?: OptionsFiles & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
204
225
|
|
|
205
|
-
declare function yaml(options?: OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
226
|
+
declare function yaml(options?: OptionsFiles & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
206
227
|
|
|
207
228
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
208
229
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
@@ -240,5 +261,6 @@ declare function toArray<T>(value: T | T[]): T[];
|
|
|
240
261
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
241
262
|
default: infer U;
|
|
242
263
|
} ? U : T>;
|
|
264
|
+
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
243
265
|
|
|
244
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_NODE_MODULES, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type Rules, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, config, config as default, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
|
266
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_NODE_MODULES, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type Rules, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, config, config as default, ensurePackages, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ type FlatConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
|
|
|
30
30
|
plugins?: Record<string, any>;
|
|
31
31
|
};
|
|
32
32
|
type UserConfigItem = FlatConfigItem | Linter.FlatConfig;
|
|
33
|
+
interface OptionsFiles {
|
|
34
|
+
/**
|
|
35
|
+
* Override the `files` option to provide custom globs.
|
|
36
|
+
*/
|
|
37
|
+
files?: string[];
|
|
38
|
+
}
|
|
33
39
|
interface OptionsComponentExts {
|
|
34
40
|
/**
|
|
35
41
|
* Additional extensions for components.
|
|
@@ -66,6 +72,18 @@ interface OptionsOverrides {
|
|
|
66
72
|
interface OptionsIsInEditor {
|
|
67
73
|
isInEditor?: boolean;
|
|
68
74
|
}
|
|
75
|
+
interface OptionsUnoCSS {
|
|
76
|
+
/**
|
|
77
|
+
* Enable attributify support.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
attributify?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Enable strict mode by throwing errors about blocklisted classes.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
strict?: boolean;
|
|
86
|
+
}
|
|
69
87
|
interface OptionsConfig extends OptionsComponentExts {
|
|
70
88
|
/**
|
|
71
89
|
* Enable gitignore support.
|
|
@@ -137,9 +155,12 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
137
155
|
/**
|
|
138
156
|
* Enable unocss rules.
|
|
139
157
|
*
|
|
158
|
+
* Requires installing:
|
|
159
|
+
* - `@unocss/eslint-plugin`
|
|
160
|
+
*
|
|
140
161
|
* @default auto-detect based on the dependencies
|
|
141
162
|
*/
|
|
142
|
-
unocss?: boolean;
|
|
163
|
+
unocss?: boolean | OptionsUnoCSS;
|
|
143
164
|
/**
|
|
144
165
|
* Enable Vue support.
|
|
145
166
|
*
|
|
@@ -169,9 +190,9 @@ declare function javascript(options?: OptionsIsInEditor & OptionsOverrides): Pro
|
|
|
169
190
|
|
|
170
191
|
declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
171
192
|
|
|
172
|
-
declare function jsonc(options?: OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
193
|
+
declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
173
194
|
|
|
174
|
-
declare function markdown(options?: OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
195
|
+
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
175
196
|
|
|
176
197
|
declare function node(): Promise<FlatConfigItem[]>;
|
|
177
198
|
|
|
@@ -190,19 +211,19 @@ declare function sortPackageJson(): FlatConfigItem[];
|
|
|
190
211
|
*/
|
|
191
212
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
192
213
|
|
|
193
|
-
declare function stylistic(options
|
|
214
|
+
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
194
215
|
|
|
195
|
-
declare function test(options?: OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
216
|
+
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
196
217
|
|
|
197
|
-
declare function typescript(options?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
218
|
+
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<FlatConfigItem[]>;
|
|
198
219
|
|
|
199
220
|
declare function unicorn(): Promise<FlatConfigItem[]>;
|
|
200
221
|
|
|
201
|
-
declare function unocss(): Promise<FlatConfigItem[]>;
|
|
222
|
+
declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
|
|
202
223
|
|
|
203
|
-
declare function vue(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
224
|
+
declare function vue(options?: OptionsFiles & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
204
225
|
|
|
205
|
-
declare function yaml(options?: OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
226
|
+
declare function yaml(options?: OptionsFiles & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
206
227
|
|
|
207
228
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
208
229
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
@@ -240,5 +261,6 @@ declare function toArray<T>(value: T | T[]): T[];
|
|
|
240
261
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
241
262
|
default: infer U;
|
|
242
263
|
} ? U : T>;
|
|
264
|
+
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
243
265
|
|
|
244
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_NODE_MODULES, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type Rules, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, config, config as default, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
|
266
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_NODE_MODULES, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type Rules, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, config, config as default, ensurePackages, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import
|
|
4
|
-
import { isPackageExists } from "local-pkg";
|
|
3
|
+
import process3 from "node:process";
|
|
4
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
5
5
|
|
|
6
6
|
// src/utils.ts
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { isPackageExists } from "local-pkg";
|
|
9
|
+
import c from "picocolors";
|
|
7
10
|
async function combine(...configs) {
|
|
8
11
|
const resolved = await Promise.all(configs);
|
|
9
12
|
return resolved.flat();
|
|
@@ -24,6 +27,24 @@ async function interopDefault(m) {
|
|
|
24
27
|
const resolved = await m;
|
|
25
28
|
return resolved.default || resolved;
|
|
26
29
|
}
|
|
30
|
+
async function ensurePackages(packages) {
|
|
31
|
+
if (process.env.CI || process.stdout.isTTY === false)
|
|
32
|
+
return;
|
|
33
|
+
const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
|
|
34
|
+
if (nonExistingPackages.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
const { default: prompts } = await import("prompts");
|
|
37
|
+
const { result } = await prompts([
|
|
38
|
+
{
|
|
39
|
+
initial: true,
|
|
40
|
+
message: `The following ${nonExistingPackages.length === 1 ? "package is" : "packages are"} required for this config: ${c.green(nonExistingPackages.join(c.white(", ")))}. Do you want to install them?`,
|
|
41
|
+
name: "result",
|
|
42
|
+
type: "confirm"
|
|
43
|
+
}
|
|
44
|
+
]);
|
|
45
|
+
if (result)
|
|
46
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
47
|
+
}
|
|
27
48
|
|
|
28
49
|
// src/configs/comments.ts
|
|
29
50
|
async function comments() {
|
|
@@ -261,7 +282,6 @@ async function javascript(options = {}) {
|
|
|
261
282
|
"no-implied-eval": "error",
|
|
262
283
|
"no-import-assign": "error",
|
|
263
284
|
"no-invalid-regexp": "error",
|
|
264
|
-
"no-invalid-this": "error",
|
|
265
285
|
"no-irregular-whitespace": "error",
|
|
266
286
|
"no-iterator": "error",
|
|
267
287
|
"no-labels": ["error", {
|
|
@@ -454,6 +474,7 @@ async function jsdoc(options = {}) {
|
|
|
454
474
|
// src/configs/jsonc.ts
|
|
455
475
|
async function jsonc(options = {}) {
|
|
456
476
|
const {
|
|
477
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
457
478
|
overrides = {},
|
|
458
479
|
stylistic: stylistic2 = true
|
|
459
480
|
} = options;
|
|
@@ -475,7 +496,7 @@ async function jsonc(options = {}) {
|
|
|
475
496
|
}
|
|
476
497
|
},
|
|
477
498
|
{
|
|
478
|
-
files
|
|
499
|
+
files,
|
|
479
500
|
languageOptions: {
|
|
480
501
|
parser: parserJsonc
|
|
481
502
|
},
|
|
@@ -537,6 +558,7 @@ async function jsonc(options = {}) {
|
|
|
537
558
|
async function markdown(options = {}) {
|
|
538
559
|
const {
|
|
539
560
|
componentExts = [],
|
|
561
|
+
files = [GLOB_MARKDOWN],
|
|
540
562
|
overrides = {}
|
|
541
563
|
} = options;
|
|
542
564
|
const pluginMarkdown = await interopDefault(import("eslint-plugin-markdown"));
|
|
@@ -548,7 +570,7 @@ async function markdown(options = {}) {
|
|
|
548
570
|
}
|
|
549
571
|
},
|
|
550
572
|
{
|
|
551
|
-
files
|
|
573
|
+
files,
|
|
552
574
|
name: "config:markdown:processor",
|
|
553
575
|
processor: "markdown/markdown"
|
|
554
576
|
},
|
|
@@ -919,7 +941,7 @@ function sortTsconfig() {
|
|
|
919
941
|
}
|
|
920
942
|
|
|
921
943
|
// src/configs/stylistic.ts
|
|
922
|
-
async function stylistic(options) {
|
|
944
|
+
async function stylistic(options = {}) {
|
|
923
945
|
const {
|
|
924
946
|
indent = 4,
|
|
925
947
|
jsx = true,
|
|
@@ -964,6 +986,7 @@ async function stylistic(options) {
|
|
|
964
986
|
// src/configs/test.ts
|
|
965
987
|
async function test(options = {}) {
|
|
966
988
|
const {
|
|
989
|
+
files = GLOB_TESTS,
|
|
967
990
|
isInEditor = false,
|
|
968
991
|
overrides = {}
|
|
969
992
|
} = options;
|
|
@@ -990,7 +1013,7 @@ async function test(options = {}) {
|
|
|
990
1013
|
}
|
|
991
1014
|
},
|
|
992
1015
|
{
|
|
993
|
-
files
|
|
1016
|
+
files,
|
|
994
1017
|
name: "config:test:rules",
|
|
995
1018
|
rules: {
|
|
996
1019
|
"node/prefer-global/process": "off",
|
|
@@ -1006,13 +1029,17 @@ async function test(options = {}) {
|
|
|
1006
1029
|
}
|
|
1007
1030
|
|
|
1008
1031
|
// src/configs/typescript.ts
|
|
1009
|
-
import
|
|
1010
|
-
async function typescript(options) {
|
|
1032
|
+
import process2 from "node:process";
|
|
1033
|
+
async function typescript(options = {}) {
|
|
1011
1034
|
const {
|
|
1012
1035
|
componentExts = [],
|
|
1013
1036
|
overrides = {},
|
|
1014
1037
|
parserOptions = {}
|
|
1015
|
-
} = options
|
|
1038
|
+
} = options;
|
|
1039
|
+
const files = options.files ?? [
|
|
1040
|
+
GLOB_SRC,
|
|
1041
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1042
|
+
];
|
|
1016
1043
|
const typeAwareRules = {
|
|
1017
1044
|
"dot-notation": "off",
|
|
1018
1045
|
"no-implied-eval": "off",
|
|
@@ -1052,10 +1079,7 @@ async function typescript(options) {
|
|
|
1052
1079
|
}
|
|
1053
1080
|
},
|
|
1054
1081
|
{
|
|
1055
|
-
files
|
|
1056
|
-
GLOB_SRC,
|
|
1057
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1058
|
-
],
|
|
1082
|
+
files,
|
|
1059
1083
|
languageOptions: {
|
|
1060
1084
|
parser: parserTs,
|
|
1061
1085
|
parserOptions: {
|
|
@@ -1063,7 +1087,7 @@ async function typescript(options) {
|
|
|
1063
1087
|
sourceType: "module",
|
|
1064
1088
|
...tsconfigPath ? {
|
|
1065
1089
|
project: tsconfigPath,
|
|
1066
|
-
tsconfigRootDir:
|
|
1090
|
+
tsconfigRootDir: process2.cwd()
|
|
1067
1091
|
} : {},
|
|
1068
1092
|
...parserOptions
|
|
1069
1093
|
}
|
|
@@ -1083,7 +1107,6 @@ async function typescript(options) {
|
|
|
1083
1107
|
"antfu/generic-spacing": "error",
|
|
1084
1108
|
"antfu/named-tuple-spacing": "error",
|
|
1085
1109
|
"no-dupe-class-members": "off",
|
|
1086
|
-
"no-invalid-this": "off",
|
|
1087
1110
|
"no-loss-of-precision": "off",
|
|
1088
1111
|
"no-redeclare": "off",
|
|
1089
1112
|
"no-use-before-define": "off",
|
|
@@ -1108,7 +1131,6 @@ async function typescript(options) {
|
|
|
1108
1131
|
"ts/no-explicit-any": "off",
|
|
1109
1132
|
"ts/no-extraneous-class": "off",
|
|
1110
1133
|
"ts/no-import-type-side-effects": "error",
|
|
1111
|
-
"ts/no-invalid-this": "error",
|
|
1112
1134
|
"ts/no-invalid-void-type": "off",
|
|
1113
1135
|
"ts/no-loss-of-precision": "error",
|
|
1114
1136
|
"ts/no-non-null-assertion": "off",
|
|
@@ -1232,7 +1254,14 @@ async function unicorn() {
|
|
|
1232
1254
|
}
|
|
1233
1255
|
|
|
1234
1256
|
// src/configs/unocss.ts
|
|
1235
|
-
async function unocss() {
|
|
1257
|
+
async function unocss(options = {}) {
|
|
1258
|
+
const {
|
|
1259
|
+
attributify = true,
|
|
1260
|
+
strict = false
|
|
1261
|
+
} = options;
|
|
1262
|
+
await ensurePackages([
|
|
1263
|
+
"@unocss/eslint-plugin"
|
|
1264
|
+
]);
|
|
1236
1265
|
const pluginUnocss = await interopDefault(import("@unocss/eslint-plugin"));
|
|
1237
1266
|
return [
|
|
1238
1267
|
{
|
|
@@ -1241,7 +1270,13 @@ async function unocss() {
|
|
|
1241
1270
|
"@unocss": pluginUnocss
|
|
1242
1271
|
},
|
|
1243
1272
|
rules: {
|
|
1244
|
-
|
|
1273
|
+
"unocss/order": "warn",
|
|
1274
|
+
...attributify ? {
|
|
1275
|
+
"unocss/order-attributify": "warn"
|
|
1276
|
+
} : {},
|
|
1277
|
+
...strict ? {
|
|
1278
|
+
"unocss/blocklist": "error"
|
|
1279
|
+
} : {}
|
|
1245
1280
|
}
|
|
1246
1281
|
}
|
|
1247
1282
|
];
|
|
@@ -1250,6 +1285,7 @@ async function unocss() {
|
|
|
1250
1285
|
// src/configs/vue.ts
|
|
1251
1286
|
async function vue(options = {}) {
|
|
1252
1287
|
const {
|
|
1288
|
+
files = [GLOB_VUE],
|
|
1253
1289
|
overrides = {},
|
|
1254
1290
|
stylistic: stylistic2 = true
|
|
1255
1291
|
} = options;
|
|
@@ -1272,7 +1308,7 @@ async function vue(options = {}) {
|
|
|
1272
1308
|
}
|
|
1273
1309
|
},
|
|
1274
1310
|
{
|
|
1275
|
-
files
|
|
1311
|
+
files,
|
|
1276
1312
|
languageOptions: {
|
|
1277
1313
|
parser: parserVue,
|
|
1278
1314
|
parserOptions: {
|
|
@@ -1397,6 +1433,7 @@ async function vue(options = {}) {
|
|
|
1397
1433
|
// src/configs/yaml.ts
|
|
1398
1434
|
async function yaml(options = {}) {
|
|
1399
1435
|
const {
|
|
1436
|
+
files = [GLOB_YAML],
|
|
1400
1437
|
overrides = {},
|
|
1401
1438
|
stylistic: stylistic2 = true
|
|
1402
1439
|
} = options;
|
|
@@ -1419,7 +1456,7 @@ async function yaml(options = {}) {
|
|
|
1419
1456
|
}
|
|
1420
1457
|
},
|
|
1421
1458
|
{
|
|
1422
|
-
files
|
|
1459
|
+
files,
|
|
1423
1460
|
languageOptions: {
|
|
1424
1461
|
parser: parserYaml
|
|
1425
1462
|
},
|
|
@@ -1480,11 +1517,11 @@ async function config(options = {}, ...userConfigs) {
|
|
|
1480
1517
|
const {
|
|
1481
1518
|
componentExts = [],
|
|
1482
1519
|
gitignore: enableGitignore = true,
|
|
1483
|
-
isInEditor = !!((
|
|
1520
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
|
|
1484
1521
|
overrides = {},
|
|
1485
|
-
typescript: enableTypeScript =
|
|
1486
|
-
unocss:
|
|
1487
|
-
vue: enableVue = VuePackages.some((i) =>
|
|
1522
|
+
typescript: enableTypeScript = isPackageExists2("typescript"),
|
|
1523
|
+
unocss: enableUnoCSS = UnocssPackages.some((i) => isPackageExists2(i)),
|
|
1524
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists2(i))
|
|
1488
1525
|
} = options;
|
|
1489
1526
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1490
1527
|
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
@@ -1530,8 +1567,11 @@ async function config(options = {}, ...userConfigs) {
|
|
|
1530
1567
|
}
|
|
1531
1568
|
if (stylisticOptions)
|
|
1532
1569
|
configs.push(stylistic(stylisticOptions));
|
|
1533
|
-
if (
|
|
1534
|
-
configs.push(unocss(
|
|
1570
|
+
if (enableUnoCSS) {
|
|
1571
|
+
configs.push(unocss(
|
|
1572
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1573
|
+
));
|
|
1574
|
+
}
|
|
1535
1575
|
if (options.test ?? true) {
|
|
1536
1576
|
configs.push(test({
|
|
1537
1577
|
isInEditor,
|
|
@@ -1612,6 +1652,7 @@ export {
|
|
|
1612
1652
|
comments,
|
|
1613
1653
|
config,
|
|
1614
1654
|
src_default as default,
|
|
1655
|
+
ensurePackages,
|
|
1615
1656
|
ignores,
|
|
1616
1657
|
imports,
|
|
1617
1658
|
interopDefault,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ivanmaxlogiudice/eslint-config",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"packageManager": "pnpm@8.
|
|
3
|
+
"version": "1.0.11",
|
|
4
|
+
"packageManager": "pnpm@8.11.0",
|
|
5
5
|
"description": "Personal ESLint config",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
@@ -33,22 +33,27 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"eslint": ">=
|
|
36
|
+
"@unocss/eslint-plugin": ">=0.57.0",
|
|
37
|
+
"eslint": ">=8.40.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"@unocss/eslint-plugin": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
37
43
|
},
|
|
38
44
|
"dependencies": {
|
|
39
45
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
46
|
+
"@antfu/install-pkg": "^0.3.0",
|
|
40
47
|
"@eslint-types/jsdoc": "46.9.0",
|
|
41
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
48
|
+
"@eslint-types/typescript-eslint": "^6.12.0",
|
|
42
49
|
"@eslint-types/unicorn": "^49.0.0",
|
|
43
|
-
"@eslint
|
|
44
|
-
"@
|
|
45
|
-
"@typescript-eslint/
|
|
46
|
-
"@typescript-eslint/parser": "^6.11.0",
|
|
47
|
-
"@unocss/eslint-plugin": "^0.57.6",
|
|
50
|
+
"@stylistic/eslint-plugin": "^1.4.1",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^6.13.0",
|
|
52
|
+
"@typescript-eslint/parser": "^6.13.0",
|
|
48
53
|
"cac": "^6.7.14",
|
|
49
54
|
"detect-indent": "^7.0.1",
|
|
50
55
|
"eslint-config-flat-gitignore": "^0.1.1",
|
|
51
|
-
"eslint-plugin-antfu": "^1.0.
|
|
56
|
+
"eslint-plugin-antfu": "^1.0.11",
|
|
52
57
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
53
58
|
"eslint-plugin-i": "^2.29.0",
|
|
54
59
|
"eslint-plugin-jsdoc": "^46.9.0",
|
|
@@ -56,11 +61,11 @@
|
|
|
56
61
|
"eslint-plugin-markdown": "^3.0.1",
|
|
57
62
|
"eslint-plugin-n": "^16.3.1",
|
|
58
63
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
59
|
-
"eslint-plugin-perfectionist": "^2.
|
|
64
|
+
"eslint-plugin-perfectionist": "^2.5.0",
|
|
60
65
|
"eslint-plugin-promise": "^6.1.1",
|
|
61
66
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
62
67
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
63
|
-
"eslint-plugin-vitest": "^0.3.
|
|
68
|
+
"eslint-plugin-vitest": "^0.3.10",
|
|
64
69
|
"eslint-plugin-vue": "^9.18.1",
|
|
65
70
|
"eslint-plugin-yml": "^1.10.0",
|
|
66
71
|
"globals": "^13.23.0",
|
|
@@ -75,8 +80,9 @@
|
|
|
75
80
|
"devDependencies": {
|
|
76
81
|
"@types/eslint": "^8.44.7",
|
|
77
82
|
"@types/fs-extra": "^11.0.4",
|
|
78
|
-
"@types/node": "^20.
|
|
79
|
-
"@types/prompts": "^2.4.
|
|
83
|
+
"@types/node": "^20.10.0",
|
|
84
|
+
"@types/prompts": "^2.4.9",
|
|
85
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
80
86
|
"bumpp": "^9.2.0",
|
|
81
87
|
"eslint": "^8.54.0",
|
|
82
88
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
@@ -85,13 +91,10 @@
|
|
|
85
91
|
"fs-extra": "^11.1.1",
|
|
86
92
|
"lint-staged": "^15.1.0",
|
|
87
93
|
"simple-git-hooks": "^2.9.0",
|
|
88
|
-
"tsup": "^8.0.
|
|
89
|
-
"typescript": "^5.
|
|
94
|
+
"tsup": "^8.0.1",
|
|
95
|
+
"typescript": "^5.3.2",
|
|
90
96
|
"vitest": "^0.34.6"
|
|
91
97
|
},
|
|
92
|
-
"workspaces": [
|
|
93
|
-
"fixtures/*"
|
|
94
|
-
],
|
|
95
98
|
"engines": {
|
|
96
99
|
"node": ">=18.12.0"
|
|
97
100
|
},
|