@antfu/eslint-config 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -6
- package/dist/cli.cjs +7 -6
- package/dist/cli.js +7 -6
- package/dist/index.cjs +41 -3
- package/dist/index.d.cts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.js +40 -3
- package/package.json +20 -15
package/README.md
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
- Lints also for json, yaml, markdown
|
|
9
9
|
- Sorted imports, dangling commas
|
|
10
10
|
- Reasonable defaults, best practices, only one-line of config
|
|
11
|
-
-
|
|
11
|
+
- Opinionated, but [very customizable](#customization)
|
|
12
12
|
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
|
|
13
13
|
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
14
|
+
- Respects `.gitignore` by default
|
|
14
15
|
- **Style principle**: Minimal for reading, stable for diff, consistent
|
|
15
16
|
|
|
16
17
|
> [!IMPORTANT]
|
|
@@ -334,9 +335,9 @@ export default antfu({
|
|
|
334
335
|
|
|
335
336
|
### Optional Configs
|
|
336
337
|
|
|
337
|
-
|
|
338
|
+
We provide some optional configs for specific use cases, that we don't include their dependencies by default.
|
|
338
339
|
|
|
339
|
-
|
|
340
|
+
#### React
|
|
340
341
|
|
|
341
342
|
To enable React support, need to explicitly turn it on:
|
|
342
343
|
|
|
@@ -349,12 +350,31 @@ export default antfu({
|
|
|
349
350
|
})
|
|
350
351
|
```
|
|
351
352
|
|
|
352
|
-
Running `npx eslint` should prompt you to install the required dependencies, otherwise you can install them manually:
|
|
353
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
353
354
|
|
|
354
355
|
```bash
|
|
355
356
|
npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
356
357
|
```
|
|
357
358
|
|
|
359
|
+
#### UnoCSS
|
|
360
|
+
|
|
361
|
+
To enable UnoCSS support, need to explicitly turn it on:
|
|
362
|
+
|
|
363
|
+
```js
|
|
364
|
+
// eslint.config.js
|
|
365
|
+
import antfu from '@antfu/eslint-config'
|
|
366
|
+
|
|
367
|
+
export default antfu({
|
|
368
|
+
unocss: true,
|
|
369
|
+
})
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
npm i -D @unocss/eslint-plugin
|
|
376
|
+
```
|
|
377
|
+
|
|
358
378
|
### Optional Rules
|
|
359
379
|
|
|
360
380
|
This config also provides some optional plugins/rules for extended usages.
|
|
@@ -413,9 +433,19 @@ and then
|
|
|
413
433
|
npm i -D lint-staged simple-git-hooks
|
|
414
434
|
```
|
|
415
435
|
|
|
436
|
+
## View what rules are enabled
|
|
437
|
+
|
|
438
|
+
I built a visual tool to help you view what rules are enabled in your project and apply them to what files, [eslint-flat-config-viewer](https://github.com/antfu/eslint-flat-config-viewer)
|
|
439
|
+
|
|
440
|
+
Go to your project root that contains `eslint.config.js` and run:
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
npx eslint-flat-config-viewer
|
|
444
|
+
```
|
|
445
|
+
|
|
416
446
|
## Versioning Policy
|
|
417
447
|
|
|
418
|
-
This project follows [Semantic Versioning](https://semver.org/) for releases. However, since this is just a config and
|
|
448
|
+
This project follows [Semantic Versioning](https://semver.org/) for releases. However, since this is just a config and involves opinions and many moving parts, we don't treat rules changes as breaking changes.
|
|
419
449
|
|
|
420
450
|
### Changes Considered as Breaking Changes
|
|
421
451
|
|
|
@@ -452,7 +482,7 @@ This config does NOT lint CSS. I personally use [UnoCSS](https://github.com/unoc
|
|
|
452
482
|
|
|
453
483
|
### I prefer XXX...
|
|
454
484
|
|
|
455
|
-
Sure, you can
|
|
485
|
+
Sure, you can configure and override rules locally in your project to fit your needs. If that still does not work for you, you can always fork this repo and maintain your own.
|
|
456
486
|
|
|
457
487
|
## Check Also
|
|
458
488
|
|
package/dist/cli.cjs
CHANGED
|
@@ -46,16 +46,17 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.1.
|
|
49
|
+
var version = "2.1.2";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/eslint-config": "workspace:*",
|
|
52
|
-
"@antfu/ni": "^0.21.
|
|
53
|
-
"@stylistic/eslint-plugin-migrate": "^1.4.
|
|
54
|
-
"@types/eslint": "^8.44.
|
|
52
|
+
"@antfu/ni": "^0.21.12",
|
|
53
|
+
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
54
|
+
"@types/eslint": "^8.44.8",
|
|
55
55
|
"@types/fs-extra": "^11.0.4",
|
|
56
|
-
"@types/node": "^20.
|
|
56
|
+
"@types/node": "^20.10.1",
|
|
57
57
|
"@types/prompts": "^2.4.9",
|
|
58
58
|
"@types/yargs": "^17.0.32",
|
|
59
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
59
60
|
bumpp: "^9.2.0",
|
|
60
61
|
eslint: "^8.54.0",
|
|
61
62
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
@@ -65,7 +66,7 @@ var devDependencies = {
|
|
|
65
66
|
esno: "^4.0.0",
|
|
66
67
|
execa: "^8.0.1",
|
|
67
68
|
"fast-glob": "^3.3.2",
|
|
68
|
-
"fs-extra": "^11.
|
|
69
|
+
"fs-extra": "^11.2.0",
|
|
69
70
|
"lint-staged": "^15.1.0",
|
|
70
71
|
rimraf: "^5.0.5",
|
|
71
72
|
"simple-git-hooks": "^2.9.0",
|
package/dist/cli.js
CHANGED
|
@@ -17,16 +17,17 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.1.
|
|
20
|
+
var version = "2.1.2";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/eslint-config": "workspace:*",
|
|
23
|
-
"@antfu/ni": "^0.21.
|
|
24
|
-
"@stylistic/eslint-plugin-migrate": "^1.4.
|
|
25
|
-
"@types/eslint": "^8.44.
|
|
23
|
+
"@antfu/ni": "^0.21.12",
|
|
24
|
+
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
25
|
+
"@types/eslint": "^8.44.8",
|
|
26
26
|
"@types/fs-extra": "^11.0.4",
|
|
27
|
-
"@types/node": "^20.
|
|
27
|
+
"@types/node": "^20.10.1",
|
|
28
28
|
"@types/prompts": "^2.4.9",
|
|
29
29
|
"@types/yargs": "^17.0.32",
|
|
30
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
30
31
|
bumpp: "^9.2.0",
|
|
31
32
|
eslint: "^8.54.0",
|
|
32
33
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
@@ -36,7 +37,7 @@ var devDependencies = {
|
|
|
36
37
|
esno: "^4.0.0",
|
|
37
38
|
execa: "^8.0.1",
|
|
38
39
|
"fast-glob": "^3.3.2",
|
|
39
|
-
"fs-extra": "^11.
|
|
40
|
+
"fs-extra": "^11.2.0",
|
|
40
41
|
"lint-staged": "^15.1.0",
|
|
41
42
|
rimraf: "^5.0.5",
|
|
42
43
|
"simple-git-hooks": "^2.9.0",
|
package/dist/index.cjs
CHANGED
|
@@ -74,6 +74,7 @@ __export(src_exports, {
|
|
|
74
74
|
toArray: () => toArray,
|
|
75
75
|
typescript: () => typescript,
|
|
76
76
|
unicorn: () => unicorn,
|
|
77
|
+
unocss: () => unocss,
|
|
77
78
|
vue: () => vue,
|
|
78
79
|
yaml: () => yaml
|
|
79
80
|
});
|
|
@@ -293,7 +294,6 @@ async function javascript(options = {}) {
|
|
|
293
294
|
"no-implied-eval": "error",
|
|
294
295
|
"no-import-assign": "error",
|
|
295
296
|
"no-invalid-regexp": "error",
|
|
296
|
-
"no-invalid-this": "error",
|
|
297
297
|
"no-irregular-whitespace": "error",
|
|
298
298
|
"no-iterator": "error",
|
|
299
299
|
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
@@ -1024,7 +1024,6 @@ async function typescript(options = {}) {
|
|
|
1024
1024
|
"antfu/generic-spacing": "error",
|
|
1025
1025
|
"antfu/named-tuple-spacing": "error",
|
|
1026
1026
|
"no-dupe-class-members": "off",
|
|
1027
|
-
"no-invalid-this": "off",
|
|
1028
1027
|
"no-loss-of-precision": "off",
|
|
1029
1028
|
"no-redeclare": "off",
|
|
1030
1029
|
"no-use-before-define": "off",
|
|
@@ -1038,7 +1037,6 @@ async function typescript(options = {}) {
|
|
|
1038
1037
|
"ts/no-explicit-any": "off",
|
|
1039
1038
|
"ts/no-extraneous-class": "off",
|
|
1040
1039
|
"ts/no-import-type-side-effects": "error",
|
|
1041
|
-
"ts/no-invalid-this": "error",
|
|
1042
1040
|
"ts/no-invalid-void-type": "off",
|
|
1043
1041
|
"ts/no-loss-of-precision": "error",
|
|
1044
1042
|
"ts/no-non-null-assertion": "off",
|
|
@@ -1454,6 +1452,39 @@ async function react(options = {}) {
|
|
|
1454
1452
|
];
|
|
1455
1453
|
}
|
|
1456
1454
|
|
|
1455
|
+
// src/configs/unocss.ts
|
|
1456
|
+
async function unocss(options = {}) {
|
|
1457
|
+
const {
|
|
1458
|
+
attributify = true,
|
|
1459
|
+
strict = false
|
|
1460
|
+
} = options;
|
|
1461
|
+
await ensurePackages([
|
|
1462
|
+
"@unocss/eslint-plugin"
|
|
1463
|
+
]);
|
|
1464
|
+
const [
|
|
1465
|
+
pluginUnoCSS
|
|
1466
|
+
] = await Promise.all([
|
|
1467
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1468
|
+
]);
|
|
1469
|
+
return [
|
|
1470
|
+
{
|
|
1471
|
+
name: "antfu:unocss",
|
|
1472
|
+
plugins: {
|
|
1473
|
+
unocss: pluginUnoCSS
|
|
1474
|
+
},
|
|
1475
|
+
rules: {
|
|
1476
|
+
"unocss/order": "warn",
|
|
1477
|
+
...attributify ? {
|
|
1478
|
+
"unocss/order-attributify": "warn"
|
|
1479
|
+
} : {},
|
|
1480
|
+
...strict ? {
|
|
1481
|
+
"unocss/blocklist": "error"
|
|
1482
|
+
} : {}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
];
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1457
1488
|
// src/factory.ts
|
|
1458
1489
|
var flatConfigProps = [
|
|
1459
1490
|
"files",
|
|
@@ -1479,6 +1510,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1479
1510
|
overrides = {},
|
|
1480
1511
|
react: enableReact = false,
|
|
1481
1512
|
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
1513
|
+
unocss: enableUnoCSS = false,
|
|
1482
1514
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
|
|
1483
1515
|
} = options;
|
|
1484
1516
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
@@ -1541,6 +1573,11 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1541
1573
|
typescript: !!enableTypeScript
|
|
1542
1574
|
}));
|
|
1543
1575
|
}
|
|
1576
|
+
if (enableUnoCSS) {
|
|
1577
|
+
configs.push(unocss(
|
|
1578
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1579
|
+
));
|
|
1580
|
+
}
|
|
1544
1581
|
if (options.jsonc ?? true) {
|
|
1545
1582
|
configs.push(
|
|
1546
1583
|
jsonc({
|
|
@@ -1624,6 +1661,7 @@ var src_default = antfu;
|
|
|
1624
1661
|
toArray,
|
|
1625
1662
|
typescript,
|
|
1626
1663
|
unicorn,
|
|
1664
|
+
unocss,
|
|
1627
1665
|
vue,
|
|
1628
1666
|
yaml
|
|
1629
1667
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -72,6 +72,18 @@ interface OptionsOverrides {
|
|
|
72
72
|
interface OptionsIsInEditor {
|
|
73
73
|
isInEditor?: boolean;
|
|
74
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
|
+
}
|
|
75
87
|
interface OptionsConfig extends OptionsComponentExts {
|
|
76
88
|
/**
|
|
77
89
|
* Enable gitignore support.
|
|
@@ -137,9 +149,23 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
137
149
|
/**
|
|
138
150
|
* Enable react rules.
|
|
139
151
|
*
|
|
140
|
-
*
|
|
152
|
+
* Requires installing:
|
|
153
|
+
* - `eslint-plugin-react`
|
|
154
|
+
* - `eslint-plugin-react-hooks`
|
|
155
|
+
* - `eslint-plugin-react-refresh`
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
141
158
|
*/
|
|
142
159
|
react?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Enable unocss rules.
|
|
162
|
+
*
|
|
163
|
+
* Requires installing:
|
|
164
|
+
* - `@unocss/eslint-plugin`
|
|
165
|
+
*
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
168
|
+
unocss?: boolean | OptionsUnoCSS;
|
|
143
169
|
/**
|
|
144
170
|
* Control to disable some rules in editors.
|
|
145
171
|
* @default auto-detect based on the process.env
|
|
@@ -215,6 +241,8 @@ declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
|
215
241
|
|
|
216
242
|
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
217
243
|
|
|
244
|
+
declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
|
|
245
|
+
|
|
218
246
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
219
247
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
220
248
|
declare const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -250,4 +278,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
250
278
|
} ? U : T>;
|
|
251
279
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
252
280
|
|
|
253
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, 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 Rules, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
|
|
281
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, 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, antfu, combine, comments, antfu as default, ensurePackages, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,18 @@ interface OptionsOverrides {
|
|
|
72
72
|
interface OptionsIsInEditor {
|
|
73
73
|
isInEditor?: boolean;
|
|
74
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
|
+
}
|
|
75
87
|
interface OptionsConfig extends OptionsComponentExts {
|
|
76
88
|
/**
|
|
77
89
|
* Enable gitignore support.
|
|
@@ -137,9 +149,23 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
137
149
|
/**
|
|
138
150
|
* Enable react rules.
|
|
139
151
|
*
|
|
140
|
-
*
|
|
152
|
+
* Requires installing:
|
|
153
|
+
* - `eslint-plugin-react`
|
|
154
|
+
* - `eslint-plugin-react-hooks`
|
|
155
|
+
* - `eslint-plugin-react-refresh`
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
141
158
|
*/
|
|
142
159
|
react?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Enable unocss rules.
|
|
162
|
+
*
|
|
163
|
+
* Requires installing:
|
|
164
|
+
* - `@unocss/eslint-plugin`
|
|
165
|
+
*
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
168
|
+
unocss?: boolean | OptionsUnoCSS;
|
|
143
169
|
/**
|
|
144
170
|
* Control to disable some rules in editors.
|
|
145
171
|
* @default auto-detect based on the process.env
|
|
@@ -215,6 +241,8 @@ declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
|
215
241
|
|
|
216
242
|
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
217
243
|
|
|
244
|
+
declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
|
|
245
|
+
|
|
218
246
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
219
247
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
220
248
|
declare const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -250,4 +278,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
250
278
|
} ? U : T>;
|
|
251
279
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
252
280
|
|
|
253
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, 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 Rules, type StylisticConfig, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
|
|
281
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, 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, antfu, combine, comments, antfu as default, ensurePackages, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -212,7 +212,6 @@ async function javascript(options = {}) {
|
|
|
212
212
|
"no-implied-eval": "error",
|
|
213
213
|
"no-import-assign": "error",
|
|
214
214
|
"no-invalid-regexp": "error",
|
|
215
|
-
"no-invalid-this": "error",
|
|
216
215
|
"no-irregular-whitespace": "error",
|
|
217
216
|
"no-iterator": "error",
|
|
218
217
|
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
@@ -943,7 +942,6 @@ async function typescript(options = {}) {
|
|
|
943
942
|
"antfu/generic-spacing": "error",
|
|
944
943
|
"antfu/named-tuple-spacing": "error",
|
|
945
944
|
"no-dupe-class-members": "off",
|
|
946
|
-
"no-invalid-this": "off",
|
|
947
945
|
"no-loss-of-precision": "off",
|
|
948
946
|
"no-redeclare": "off",
|
|
949
947
|
"no-use-before-define": "off",
|
|
@@ -957,7 +955,6 @@ async function typescript(options = {}) {
|
|
|
957
955
|
"ts/no-explicit-any": "off",
|
|
958
956
|
"ts/no-extraneous-class": "off",
|
|
959
957
|
"ts/no-import-type-side-effects": "error",
|
|
960
|
-
"ts/no-invalid-this": "error",
|
|
961
958
|
"ts/no-invalid-void-type": "off",
|
|
962
959
|
"ts/no-loss-of-precision": "error",
|
|
963
960
|
"ts/no-non-null-assertion": "off",
|
|
@@ -1373,6 +1370,39 @@ async function react(options = {}) {
|
|
|
1373
1370
|
];
|
|
1374
1371
|
}
|
|
1375
1372
|
|
|
1373
|
+
// src/configs/unocss.ts
|
|
1374
|
+
async function unocss(options = {}) {
|
|
1375
|
+
const {
|
|
1376
|
+
attributify = true,
|
|
1377
|
+
strict = false
|
|
1378
|
+
} = options;
|
|
1379
|
+
await ensurePackages([
|
|
1380
|
+
"@unocss/eslint-plugin"
|
|
1381
|
+
]);
|
|
1382
|
+
const [
|
|
1383
|
+
pluginUnoCSS
|
|
1384
|
+
] = await Promise.all([
|
|
1385
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1386
|
+
]);
|
|
1387
|
+
return [
|
|
1388
|
+
{
|
|
1389
|
+
name: "antfu:unocss",
|
|
1390
|
+
plugins: {
|
|
1391
|
+
unocss: pluginUnoCSS
|
|
1392
|
+
},
|
|
1393
|
+
rules: {
|
|
1394
|
+
"unocss/order": "warn",
|
|
1395
|
+
...attributify ? {
|
|
1396
|
+
"unocss/order-attributify": "warn"
|
|
1397
|
+
} : {},
|
|
1398
|
+
...strict ? {
|
|
1399
|
+
"unocss/blocklist": "error"
|
|
1400
|
+
} : {}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
];
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1376
1406
|
// src/factory.ts
|
|
1377
1407
|
var flatConfigProps = [
|
|
1378
1408
|
"files",
|
|
@@ -1398,6 +1428,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1398
1428
|
overrides = {},
|
|
1399
1429
|
react: enableReact = false,
|
|
1400
1430
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
1431
|
+
unocss: enableUnoCSS = false,
|
|
1401
1432
|
vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
|
|
1402
1433
|
} = options;
|
|
1403
1434
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
@@ -1460,6 +1491,11 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1460
1491
|
typescript: !!enableTypeScript
|
|
1461
1492
|
}));
|
|
1462
1493
|
}
|
|
1494
|
+
if (enableUnoCSS) {
|
|
1495
|
+
configs.push(unocss(
|
|
1496
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1497
|
+
));
|
|
1498
|
+
}
|
|
1463
1499
|
if (options.jsonc ?? true) {
|
|
1464
1500
|
configs.push(
|
|
1465
1501
|
jsonc({
|
|
@@ -1543,6 +1579,7 @@ export {
|
|
|
1543
1579
|
toArray,
|
|
1544
1580
|
typescript,
|
|
1545
1581
|
unicorn,
|
|
1582
|
+
unocss,
|
|
1546
1583
|
vue,
|
|
1547
1584
|
yaml
|
|
1548
1585
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antfu/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
5
|
-
"packageManager": "pnpm@8.
|
|
4
|
+
"version": "2.1.2",
|
|
5
|
+
"packageManager": "pnpm@8.11.0",
|
|
6
6
|
"description": "Anthony's ESLint config",
|
|
7
7
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
8
8
|
"license": "MIT",
|
|
@@ -25,12 +25,16 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"peerDependencies": {
|
|
28
|
+
"@unocss/eslint-plugin": ">=0.50.0",
|
|
28
29
|
"eslint": ">=8.40.0",
|
|
29
30
|
"eslint-plugin-react": "^7.33.2",
|
|
30
31
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
31
32
|
"eslint-plugin-react-refresh": "^0.4.4"
|
|
32
33
|
},
|
|
33
34
|
"peerDependenciesMeta": {
|
|
35
|
+
"@unocss/eslint-plugin": {
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
34
38
|
"eslint-plugin-react": {
|
|
35
39
|
"optional": true
|
|
36
40
|
},
|
|
@@ -43,15 +47,15 @@
|
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
45
49
|
"@antfu/eslint-define-config": "^1.23.0-2",
|
|
46
|
-
"@antfu/install-pkg": "^0.
|
|
50
|
+
"@antfu/install-pkg": "^0.3.0",
|
|
47
51
|
"@eslint-types/jsdoc": "46.8.2-1",
|
|
48
52
|
"@eslint-types/typescript-eslint": "^6.12.0",
|
|
49
53
|
"@eslint-types/unicorn": "^49.0.0",
|
|
50
|
-
"@stylistic/eslint-plugin": "^1.4.
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
52
|
-
"@typescript-eslint/parser": "^6.
|
|
54
|
+
"@stylistic/eslint-plugin": "^1.4.1",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
56
|
+
"@typescript-eslint/parser": "^6.13.1",
|
|
53
57
|
"eslint-config-flat-gitignore": "^0.1.1",
|
|
54
|
-
"eslint-plugin-antfu": "^1.0.
|
|
58
|
+
"eslint-plugin-antfu": "^1.0.11",
|
|
55
59
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
56
60
|
"eslint-plugin-i": "^2.29.0",
|
|
57
61
|
"eslint-plugin-jsdoc": "^46.9.0",
|
|
@@ -59,11 +63,11 @@
|
|
|
59
63
|
"eslint-plugin-markdown": "^3.0.1",
|
|
60
64
|
"eslint-plugin-n": "^16.3.1",
|
|
61
65
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
62
|
-
"eslint-plugin-perfectionist": "^2.
|
|
66
|
+
"eslint-plugin-perfectionist": "^2.5.0",
|
|
63
67
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
64
68
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
65
69
|
"eslint-plugin-vitest": "^0.3.10",
|
|
66
|
-
"eslint-plugin-vue": "^9.
|
|
70
|
+
"eslint-plugin-vue": "^9.19.1",
|
|
67
71
|
"eslint-plugin-yml": "^1.10.0",
|
|
68
72
|
"globals": "^13.23.0",
|
|
69
73
|
"jsonc-eslint-parser": "^2.4.0",
|
|
@@ -76,13 +80,14 @@
|
|
|
76
80
|
"yargs": "^17.7.2"
|
|
77
81
|
},
|
|
78
82
|
"devDependencies": {
|
|
79
|
-
"@antfu/ni": "^0.21.
|
|
80
|
-
"@stylistic/eslint-plugin-migrate": "^1.4.
|
|
81
|
-
"@types/eslint": "^8.44.
|
|
83
|
+
"@antfu/ni": "^0.21.12",
|
|
84
|
+
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
85
|
+
"@types/eslint": "^8.44.8",
|
|
82
86
|
"@types/fs-extra": "^11.0.4",
|
|
83
|
-
"@types/node": "^20.
|
|
87
|
+
"@types/node": "^20.10.1",
|
|
84
88
|
"@types/prompts": "^2.4.9",
|
|
85
89
|
"@types/yargs": "^17.0.32",
|
|
90
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
86
91
|
"bumpp": "^9.2.0",
|
|
87
92
|
"eslint": "^8.54.0",
|
|
88
93
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
@@ -92,14 +97,14 @@
|
|
|
92
97
|
"esno": "^4.0.0",
|
|
93
98
|
"execa": "^8.0.1",
|
|
94
99
|
"fast-glob": "^3.3.2",
|
|
95
|
-
"fs-extra": "^11.
|
|
100
|
+
"fs-extra": "^11.2.0",
|
|
96
101
|
"lint-staged": "^15.1.0",
|
|
97
102
|
"rimraf": "^5.0.5",
|
|
98
103
|
"simple-git-hooks": "^2.9.0",
|
|
99
104
|
"tsup": "^8.0.1",
|
|
100
105
|
"typescript": "^5.3.2",
|
|
101
106
|
"vitest": "^0.34.6",
|
|
102
|
-
"@antfu/eslint-config": "2.1.
|
|
107
|
+
"@antfu/eslint-config": "2.1.2"
|
|
103
108
|
},
|
|
104
109
|
"simple-git-hooks": {
|
|
105
110
|
"pre-commit": "pnpm lint-staged"
|