@lincy/eslint-config 4.0.3 → 4.1.0
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 +101 -44
- package/dist/index.cjs +130 -27
- package/dist/index.d.cts +75 -35
- package/dist/index.d.ts +75 -35
- package/dist/index.js +126 -25
- package/package.json +33 -10
package/README.md
CHANGED
|
@@ -46,9 +46,9 @@ For example:
|
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
## VS Code support (
|
|
49
|
+
## VS Code support (自动修复)
|
|
50
50
|
|
|
51
|
-
安装[VS Code ESLint扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
51
|
+
安装 [VS Code ESLint扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
52
52
|
|
|
53
53
|
将以下设置添加到您的“settings.json”:
|
|
54
54
|
|
|
@@ -130,47 +130,75 @@ module.exports = lincy()
|
|
|
130
130
|
import lincy from '@lincy/eslint-config'
|
|
131
131
|
|
|
132
132
|
export default lincy({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
/**
|
|
134
|
+
* 是否启用 stylistic 格式化规则
|
|
135
|
+
* @default 默认值: true
|
|
136
|
+
* @example 可选: false | { indent?: number | 'tab'; quotes?: 'single' | 'double'; jsx?: boolean; files?: string[]}
|
|
137
|
+
*/
|
|
136
138
|
stylistic: true,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
/**
|
|
140
|
+
* 是否启用 typescript 规则
|
|
141
|
+
* @default 默认值: 检测是否安装typescript依赖,
|
|
142
|
+
* @example 可选: false | true | { parserOptions: {}; files?: string[] }
|
|
143
|
+
*/
|
|
140
144
|
typescript: true,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
/**
|
|
146
|
+
* 是否启用 vue 规则
|
|
147
|
+
* @default 默认值: 检测是否安装vue依赖,
|
|
148
|
+
* @example 可选: false | true | { files?: string[] }
|
|
149
|
+
*/
|
|
144
150
|
vue: true,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
/**
|
|
152
|
+
* 是否启用 jsx 规则
|
|
153
|
+
* @default 默认值: true,
|
|
154
|
+
* @example 可选: false
|
|
155
|
+
*/
|
|
148
156
|
jsx: true,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
/**
|
|
158
|
+
* 是否启用 react 规则
|
|
159
|
+
* @default 默认值: 检测是否安装react依赖,
|
|
160
|
+
* @example 可选: false | true | { jsx?: boolean; version?: string; files?: string[] }
|
|
161
|
+
*/
|
|
152
162
|
react: true,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
163
|
+
/**
|
|
164
|
+
* 是否启用 unocss 规则
|
|
165
|
+
* @default 默认值: false,
|
|
166
|
+
* @example 可选: true | { attributify?: boolean; strict?: boolean }
|
|
167
|
+
*/
|
|
168
|
+
unocss: true,
|
|
169
|
+
/**
|
|
170
|
+
* 是否启用 jsonc 规则
|
|
171
|
+
* @default 默认值: true,
|
|
172
|
+
* @example 可选: false | { files?: string[] }
|
|
173
|
+
*/
|
|
156
174
|
jsonc: false,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
175
|
+
/**
|
|
176
|
+
* 是否启用 yaml 规则
|
|
177
|
+
* @default 默认值: true,
|
|
178
|
+
* @example 可选: false | { files?: string[] }
|
|
179
|
+
*/
|
|
160
180
|
yaml: false,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
181
|
+
/**
|
|
182
|
+
* 是否启用 .gitignore 文件
|
|
183
|
+
* @default 默认值: true,
|
|
184
|
+
* @example 可选: false | { ignores?: string[] }
|
|
185
|
+
*/
|
|
164
186
|
gitignore: false,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
187
|
+
/**
|
|
188
|
+
* 是否启用 test 规则
|
|
189
|
+
* @default 默认值: true,
|
|
190
|
+
* @example 可选: false | { files?: string[] }
|
|
191
|
+
*/
|
|
168
192
|
test: false,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
193
|
+
/**
|
|
194
|
+
* 是否启用 markdown 规则
|
|
195
|
+
* @default 默认值: true,
|
|
196
|
+
* @example 可选: false | { files?: string[] }
|
|
197
|
+
*/
|
|
172
198
|
markdown: false,
|
|
173
|
-
|
|
199
|
+
/**
|
|
200
|
+
* 覆盖规则
|
|
201
|
+
*/
|
|
174
202
|
overrides: {},
|
|
175
203
|
|
|
176
204
|
// 工厂函数第一个参数默认为各规则的开关, 但是也可以作为追加规则使用, 当包含以下键名将会自动整合到一个规则里
|
|
@@ -185,7 +213,8 @@ export default lincy({
|
|
|
185
213
|
})
|
|
186
214
|
```
|
|
187
215
|
|
|
188
|
-
`lincy`
|
|
216
|
+
`lincy` 工厂函数还接受任意数量的自定义配置覆盖
|
|
217
|
+
下面示例为添加`auto-import`生成的全局方法
|
|
189
218
|
|
|
190
219
|
```js
|
|
191
220
|
// eslint.config.js
|
|
@@ -200,16 +229,8 @@ const autoImport = JSON.parse(
|
|
|
200
229
|
export default lincy(
|
|
201
230
|
{
|
|
202
231
|
// 配置, 参考上一个代码块
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
{
|
|
206
|
-
plugins: {
|
|
207
|
-
'@unocss': plugin,
|
|
208
|
-
},
|
|
209
|
-
rules: {
|
|
210
|
-
...plugin.configs.recommended.rules,
|
|
211
|
-
'@unocss/order': 'off',
|
|
212
|
-
},
|
|
232
|
+
// 启用 unocss
|
|
233
|
+
unocss: true
|
|
213
234
|
},
|
|
214
235
|
// 启用 auto-import 生成的 .eslintrc-auto-import.json
|
|
215
236
|
{
|
|
@@ -251,6 +272,7 @@ import {
|
|
|
251
272
|
stylistic,
|
|
252
273
|
typescript,
|
|
253
274
|
unicorn,
|
|
275
|
+
unocss,
|
|
254
276
|
vue,
|
|
255
277
|
yaml,
|
|
256
278
|
} from '@lincy/eslint-config'
|
|
@@ -268,6 +290,7 @@ export default combine(
|
|
|
268
290
|
stylistic(/* Options */),
|
|
269
291
|
vue(),
|
|
270
292
|
react(/* Options */),
|
|
293
|
+
unocss(/* Options */),
|
|
271
294
|
jsonc(),
|
|
272
295
|
yaml(),
|
|
273
296
|
markdown(),
|
|
@@ -382,6 +405,40 @@ export default lincy({
|
|
|
382
405
|
})
|
|
383
406
|
```
|
|
384
407
|
|
|
408
|
+
### 可选配置
|
|
409
|
+
|
|
410
|
+
提供了一些可选配置,默认情况下不包含它们的依赖项
|
|
411
|
+
|
|
412
|
+
#### React
|
|
413
|
+
|
|
414
|
+
当检测到依赖安装了`react`, 则默认开启
|
|
415
|
+
|
|
416
|
+
运行“npx eslint”会提示您安装所需的依赖项,当然,您也可以手动安装它们:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
pnpm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### UnoCSS
|
|
423
|
+
|
|
424
|
+
要启用 UnoCSS 支持,需要显式打开它
|
|
425
|
+
|
|
426
|
+
```js
|
|
427
|
+
// eslint.config.js
|
|
428
|
+
import lincy from '@lincy/eslint-config'
|
|
429
|
+
|
|
430
|
+
export default lincy({
|
|
431
|
+
unocss: true,
|
|
432
|
+
})
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
运行“npx eslint”会提示您安装所需的依赖项,当然,您也可以手动安装它们:
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
pnpm i -D @unocss/eslint-plugin
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
|
|
385
442
|
#### `perfectionist` (sorting)
|
|
386
443
|
|
|
387
444
|
这个插件 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 允许你排序对象键名,导入,自动修复等。
|
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,7 @@ __export(src_exports, {
|
|
|
54
54
|
combine: () => combine,
|
|
55
55
|
comments: () => comments,
|
|
56
56
|
default: () => src_default,
|
|
57
|
+
ensurePackages: () => ensurePackages,
|
|
57
58
|
ignores: () => ignores,
|
|
58
59
|
imports: () => imports,
|
|
59
60
|
interopDefault: () => interopDefault,
|
|
@@ -73,15 +74,16 @@ __export(src_exports, {
|
|
|
73
74
|
toArray: () => toArray,
|
|
74
75
|
typescript: () => typescript,
|
|
75
76
|
unicorn: () => unicorn,
|
|
77
|
+
unocss: () => unocss,
|
|
76
78
|
vue: () => vue,
|
|
77
79
|
yaml: () => yaml
|
|
78
80
|
});
|
|
79
81
|
module.exports = __toCommonJS(src_exports);
|
|
80
82
|
|
|
81
83
|
// src/factory.ts
|
|
82
|
-
var
|
|
84
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
83
85
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
84
|
-
var
|
|
86
|
+
var import_local_pkg4 = require("local-pkg");
|
|
85
87
|
|
|
86
88
|
// src/plugins.ts
|
|
87
89
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
@@ -442,6 +444,8 @@ async function javascript(options = {}) {
|
|
|
442
444
|
}
|
|
443
445
|
|
|
444
446
|
// src/utils.ts
|
|
447
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
448
|
+
var import_local_pkg = require("local-pkg");
|
|
445
449
|
async function combine(...configs) {
|
|
446
450
|
const resolved = await Promise.all(configs);
|
|
447
451
|
return resolved.flat();
|
|
@@ -462,6 +466,23 @@ async function interopDefault(m) {
|
|
|
462
466
|
const resolved = await m;
|
|
463
467
|
return resolved.default || resolved;
|
|
464
468
|
}
|
|
469
|
+
async function ensurePackages(packages) {
|
|
470
|
+
if (import_node_process.default.stdout.isTTY === false)
|
|
471
|
+
return;
|
|
472
|
+
const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
|
|
473
|
+
if (nonExistingPackages.length === 0)
|
|
474
|
+
return;
|
|
475
|
+
const { default: prompts } = await import("prompts");
|
|
476
|
+
const { result } = await prompts([
|
|
477
|
+
{
|
|
478
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
479
|
+
name: "result",
|
|
480
|
+
type: "confirm"
|
|
481
|
+
}
|
|
482
|
+
]);
|
|
483
|
+
if (result)
|
|
484
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
485
|
+
}
|
|
465
486
|
|
|
466
487
|
// src/configs/jsdoc.ts
|
|
467
488
|
async function jsdoc(options = {}) {
|
|
@@ -503,6 +524,7 @@ async function jsdoc(options = {}) {
|
|
|
503
524
|
// src/configs/jsonc.ts
|
|
504
525
|
async function jsonc(options = {}) {
|
|
505
526
|
const {
|
|
527
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
506
528
|
overrides = {},
|
|
507
529
|
stylistic: stylistic2 = true
|
|
508
530
|
} = options;
|
|
@@ -521,7 +543,7 @@ async function jsonc(options = {}) {
|
|
|
521
543
|
}
|
|
522
544
|
},
|
|
523
545
|
{
|
|
524
|
-
files
|
|
546
|
+
files,
|
|
525
547
|
languageOptions: {
|
|
526
548
|
parser: parserJsonc
|
|
527
549
|
},
|
|
@@ -575,6 +597,7 @@ async function jsonc(options = {}) {
|
|
|
575
597
|
async function markdown(options = {}) {
|
|
576
598
|
const {
|
|
577
599
|
componentExts = [],
|
|
600
|
+
files = [GLOB_MARKDOWN],
|
|
578
601
|
overrides = {}
|
|
579
602
|
} = options;
|
|
580
603
|
return [
|
|
@@ -586,7 +609,7 @@ async function markdown(options = {}) {
|
|
|
586
609
|
}
|
|
587
610
|
},
|
|
588
611
|
{
|
|
589
|
-
files
|
|
612
|
+
files,
|
|
590
613
|
name: "eslint:markdown:processor",
|
|
591
614
|
processor: "markdown/markdown"
|
|
592
615
|
},
|
|
@@ -1030,7 +1053,7 @@ async function stylistic(options = {}) {
|
|
|
1030
1053
|
"style/jsx-first-prop-new-line": "error",
|
|
1031
1054
|
"style/jsx-indent": ["error", indent, { checkAttributes: true, indentLogicalExpressions: true }],
|
|
1032
1055
|
"style/jsx-indent-props": ["error", indent],
|
|
1033
|
-
"style/jsx-max-props-per-line": ["error", { maximum:
|
|
1056
|
+
"style/jsx-max-props-per-line": ["error", { maximum: 4 }],
|
|
1034
1057
|
// 在 JSX 中的单行上强制执行最多 props 数量
|
|
1035
1058
|
"style/jsx-newline": "off",
|
|
1036
1059
|
// 在 jsx 元素和表达式之后换行
|
|
@@ -1060,13 +1083,17 @@ async function stylistic(options = {}) {
|
|
|
1060
1083
|
}
|
|
1061
1084
|
|
|
1062
1085
|
// src/configs/typescript.ts
|
|
1063
|
-
var
|
|
1064
|
-
async function typescript(options) {
|
|
1086
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
1087
|
+
async function typescript(options = {}) {
|
|
1065
1088
|
const {
|
|
1066
1089
|
componentExts = [],
|
|
1067
1090
|
overrides = {},
|
|
1068
1091
|
parserOptions = {}
|
|
1069
|
-
} = options
|
|
1092
|
+
} = options;
|
|
1093
|
+
const files = options.files ?? [
|
|
1094
|
+
GLOB_SRC,
|
|
1095
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1096
|
+
];
|
|
1070
1097
|
const typeAwareRules = {
|
|
1071
1098
|
"dot-notation": "off",
|
|
1072
1099
|
"no-implied-eval": "off",
|
|
@@ -1106,10 +1133,7 @@ async function typescript(options) {
|
|
|
1106
1133
|
}
|
|
1107
1134
|
},
|
|
1108
1135
|
{
|
|
1109
|
-
files
|
|
1110
|
-
GLOB_SRC,
|
|
1111
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1112
|
-
],
|
|
1136
|
+
files,
|
|
1113
1137
|
languageOptions: {
|
|
1114
1138
|
parser: parserTs,
|
|
1115
1139
|
parserOptions: {
|
|
@@ -1117,7 +1141,7 @@ async function typescript(options) {
|
|
|
1117
1141
|
sourceType: "module",
|
|
1118
1142
|
...tsconfigPath ? {
|
|
1119
1143
|
project: tsconfigPath,
|
|
1120
|
-
tsconfigRootDir:
|
|
1144
|
+
tsconfigRootDir: import_node_process2.default.cwd()
|
|
1121
1145
|
} : {},
|
|
1122
1146
|
...parserOptions
|
|
1123
1147
|
}
|
|
@@ -1238,13 +1262,14 @@ async function unicorn() {
|
|
|
1238
1262
|
}
|
|
1239
1263
|
|
|
1240
1264
|
// src/configs/vue.ts
|
|
1241
|
-
var
|
|
1242
|
-
var pkg = (0,
|
|
1265
|
+
var import_local_pkg2 = require("local-pkg");
|
|
1266
|
+
var pkg = (0, import_local_pkg2.getPackageInfoSync)("vue");
|
|
1243
1267
|
var vueVersion = pkg && pkg.version;
|
|
1244
1268
|
vueVersion = vueVersion && vueVersion[0];
|
|
1245
1269
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
1246
1270
|
async function vue(options = {}) {
|
|
1247
1271
|
const {
|
|
1272
|
+
files = [GLOB_VUE],
|
|
1248
1273
|
overrides = {},
|
|
1249
1274
|
stylistic: stylistic2 = true
|
|
1250
1275
|
} = options;
|
|
@@ -1267,7 +1292,7 @@ async function vue(options = {}) {
|
|
|
1267
1292
|
}
|
|
1268
1293
|
},
|
|
1269
1294
|
{
|
|
1270
|
-
files
|
|
1295
|
+
files,
|
|
1271
1296
|
languageOptions: {
|
|
1272
1297
|
parser: parserVue,
|
|
1273
1298
|
parserOptions: {
|
|
@@ -1386,6 +1411,7 @@ async function vue(options = {}) {
|
|
|
1386
1411
|
// src/configs/yaml.ts
|
|
1387
1412
|
async function yaml(options = {}) {
|
|
1388
1413
|
const {
|
|
1414
|
+
files = [GLOB_YAML],
|
|
1389
1415
|
overrides = {},
|
|
1390
1416
|
stylistic: stylistic2 = true
|
|
1391
1417
|
} = options;
|
|
@@ -1404,7 +1430,7 @@ async function yaml(options = {}) {
|
|
|
1404
1430
|
}
|
|
1405
1431
|
},
|
|
1406
1432
|
{
|
|
1407
|
-
files
|
|
1433
|
+
files,
|
|
1408
1434
|
languageOptions: {
|
|
1409
1435
|
parser: parserYaml
|
|
1410
1436
|
},
|
|
@@ -1440,6 +1466,7 @@ async function yaml(options = {}) {
|
|
|
1440
1466
|
// src/configs/test.ts
|
|
1441
1467
|
async function test(options = {}) {
|
|
1442
1468
|
const {
|
|
1469
|
+
files = GLOB_TESTS,
|
|
1443
1470
|
isInEditor = false,
|
|
1444
1471
|
overrides = {}
|
|
1445
1472
|
} = options;
|
|
@@ -1466,7 +1493,7 @@ async function test(options = {}) {
|
|
|
1466
1493
|
}
|
|
1467
1494
|
},
|
|
1468
1495
|
{
|
|
1469
|
-
files
|
|
1496
|
+
files,
|
|
1470
1497
|
name: "eslint:test:rules",
|
|
1471
1498
|
rules: {
|
|
1472
1499
|
"node/prefer-global/process": "off",
|
|
@@ -1494,31 +1521,49 @@ async function perfectionist() {
|
|
|
1494
1521
|
}
|
|
1495
1522
|
|
|
1496
1523
|
// src/configs/react.ts
|
|
1524
|
+
var import_local_pkg3 = require("local-pkg");
|
|
1525
|
+
var ReactRefreshAllowConstantExportPackages = [
|
|
1526
|
+
"vite"
|
|
1527
|
+
];
|
|
1497
1528
|
async function react(options = {}) {
|
|
1498
1529
|
const {
|
|
1530
|
+
files = [GLOB_JSX, GLOB_TSX],
|
|
1499
1531
|
jsx = true,
|
|
1500
1532
|
overrides = {},
|
|
1533
|
+
typescript: typescript2 = true,
|
|
1501
1534
|
version = "17.0"
|
|
1502
1535
|
} = options;
|
|
1536
|
+
await ensurePackages([
|
|
1537
|
+
"eslint-plugin-react",
|
|
1538
|
+
"eslint-plugin-react-hooks",
|
|
1539
|
+
"eslint-plugin-react-refresh"
|
|
1540
|
+
]);
|
|
1503
1541
|
const [
|
|
1504
1542
|
pluginReact,
|
|
1505
|
-
pluginReactHooks
|
|
1543
|
+
pluginReactHooks,
|
|
1544
|
+
pluginReactRefresh
|
|
1506
1545
|
] = await Promise.all([
|
|
1507
1546
|
// @ts-expect-error missing types
|
|
1508
1547
|
interopDefault(import("eslint-plugin-react")),
|
|
1509
1548
|
// @ts-expect-error missing types
|
|
1510
|
-
interopDefault(import("eslint-plugin-react-hooks"))
|
|
1549
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1550
|
+
// @ts-expect-error missing types
|
|
1551
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1511
1552
|
]);
|
|
1553
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1554
|
+
(i) => (0, import_local_pkg3.isPackageExists)(i)
|
|
1555
|
+
);
|
|
1512
1556
|
return [
|
|
1513
1557
|
{
|
|
1514
1558
|
name: "eslint:react:setup",
|
|
1515
1559
|
plugins: {
|
|
1516
1560
|
"react": pluginReact,
|
|
1517
|
-
"react-hooks": pluginReactHooks
|
|
1561
|
+
"react-hooks": pluginReactHooks,
|
|
1562
|
+
"react-refresh": pluginReactRefresh
|
|
1518
1563
|
}
|
|
1519
1564
|
},
|
|
1520
1565
|
{
|
|
1521
|
-
files
|
|
1566
|
+
files,
|
|
1522
1567
|
languageOptions: {
|
|
1523
1568
|
parserOptions: {
|
|
1524
1569
|
ecmaFeatures: {
|
|
@@ -1528,8 +1573,15 @@ async function react(options = {}) {
|
|
|
1528
1573
|
},
|
|
1529
1574
|
name: "eslint:react:rules",
|
|
1530
1575
|
rules: {
|
|
1576
|
+
// react-hooks
|
|
1531
1577
|
"react-hooks/exhaustive-deps": "warn",
|
|
1532
1578
|
"react-hooks/rules-of-hooks": "error",
|
|
1579
|
+
// react-refresh
|
|
1580
|
+
"react-refresh/only-export-components": [
|
|
1581
|
+
"warn",
|
|
1582
|
+
{ allowConstantExport: isAllowConstantExport }
|
|
1583
|
+
],
|
|
1584
|
+
// react
|
|
1533
1585
|
"react/boolean-prop-naming": "error",
|
|
1534
1586
|
"react/button-has-type": "error",
|
|
1535
1587
|
"react/default-props-match-prop-types": "error",
|
|
@@ -1622,6 +1674,10 @@ async function react(options = {}) {
|
|
|
1622
1674
|
"react/static-property-placement": "error",
|
|
1623
1675
|
"react/style-prop-object": "error",
|
|
1624
1676
|
"react/void-dom-elements-no-children": "error",
|
|
1677
|
+
...typescript2 ? {
|
|
1678
|
+
"react/jsx-no-undef": "off",
|
|
1679
|
+
"react/prop-type": "off"
|
|
1680
|
+
} : {},
|
|
1625
1681
|
...overrides
|
|
1626
1682
|
},
|
|
1627
1683
|
settings: {
|
|
@@ -1633,6 +1689,39 @@ async function react(options = {}) {
|
|
|
1633
1689
|
];
|
|
1634
1690
|
}
|
|
1635
1691
|
|
|
1692
|
+
// src/configs/unocss.ts
|
|
1693
|
+
async function unocss(options = {}) {
|
|
1694
|
+
const {
|
|
1695
|
+
attributify = true,
|
|
1696
|
+
strict = false
|
|
1697
|
+
} = options;
|
|
1698
|
+
await ensurePackages([
|
|
1699
|
+
"@unocss/eslint-plugin"
|
|
1700
|
+
]);
|
|
1701
|
+
const [
|
|
1702
|
+
pluginUnoCSS
|
|
1703
|
+
] = await Promise.all([
|
|
1704
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1705
|
+
]);
|
|
1706
|
+
return [
|
|
1707
|
+
{
|
|
1708
|
+
name: "eslint:unocss",
|
|
1709
|
+
plugins: {
|
|
1710
|
+
unocss: pluginUnoCSS
|
|
1711
|
+
},
|
|
1712
|
+
rules: {
|
|
1713
|
+
"unocss/order": "off",
|
|
1714
|
+
...attributify ? {
|
|
1715
|
+
"unocss/order-attributify": "warn"
|
|
1716
|
+
} : {},
|
|
1717
|
+
...strict ? {
|
|
1718
|
+
"unocss/blocklist": "error"
|
|
1719
|
+
} : {}
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
];
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1636
1725
|
// src/factory.ts
|
|
1637
1726
|
var flatConfigProps = [
|
|
1638
1727
|
"files",
|
|
@@ -1658,11 +1747,12 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1658
1747
|
const {
|
|
1659
1748
|
componentExts = [],
|
|
1660
1749
|
gitignore: enableGitignore = true,
|
|
1661
|
-
isInEditor = !!((
|
|
1750
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
1662
1751
|
overrides = {},
|
|
1663
|
-
react: enableReact = ReactPackages.some((i) => (0,
|
|
1664
|
-
typescript: enableTypeScript = (0,
|
|
1665
|
-
|
|
1752
|
+
react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
|
|
1753
|
+
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
1754
|
+
unocss: enableUnoCSS = false,
|
|
1755
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
1666
1756
|
} = options;
|
|
1667
1757
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1668
1758
|
if (stylisticOptions) {
|
|
@@ -1715,12 +1805,14 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1715
1805
|
}
|
|
1716
1806
|
if (options.test ?? true) {
|
|
1717
1807
|
configs.push(test({
|
|
1808
|
+
...typeof options.test !== "boolean" ? options.test : {},
|
|
1718
1809
|
isInEditor,
|
|
1719
1810
|
overrides: overrides.test
|
|
1720
1811
|
}));
|
|
1721
1812
|
}
|
|
1722
1813
|
if (enableVue) {
|
|
1723
1814
|
configs.push(vue({
|
|
1815
|
+
...typeof options.vue !== "boolean" ? options.vue : {},
|
|
1724
1816
|
overrides: overrides.vue,
|
|
1725
1817
|
stylistic: stylisticOptions,
|
|
1726
1818
|
typescript: !!enableTypeScript
|
|
@@ -1728,13 +1820,20 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1728
1820
|
}
|
|
1729
1821
|
if (enableReact) {
|
|
1730
1822
|
configs.push(react({
|
|
1823
|
+
...typeof enableReact !== "boolean" ? enableReact : {},
|
|
1731
1824
|
overrides: overrides.react,
|
|
1732
|
-
|
|
1825
|
+
typescript: !!enableTypeScript
|
|
1733
1826
|
}));
|
|
1734
1827
|
}
|
|
1828
|
+
if (enableUnoCSS) {
|
|
1829
|
+
configs.push(unocss(
|
|
1830
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1831
|
+
));
|
|
1832
|
+
}
|
|
1735
1833
|
if (options.jsonc ?? true) {
|
|
1736
1834
|
configs.push(
|
|
1737
1835
|
jsonc({
|
|
1836
|
+
...typeof options.jsonc !== "boolean" ? options.jsonc : {},
|
|
1738
1837
|
overrides: overrides.jsonc,
|
|
1739
1838
|
stylistic: stylisticOptions
|
|
1740
1839
|
}),
|
|
@@ -1744,12 +1843,14 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1744
1843
|
}
|
|
1745
1844
|
if (options.yaml ?? true) {
|
|
1746
1845
|
configs.push(yaml({
|
|
1846
|
+
...typeof options.yaml !== "boolean" ? options.yaml : {},
|
|
1747
1847
|
overrides: overrides.yaml,
|
|
1748
1848
|
stylistic: stylisticOptions
|
|
1749
1849
|
}));
|
|
1750
1850
|
}
|
|
1751
1851
|
if (options.markdown ?? true) {
|
|
1752
1852
|
configs.push(markdown({
|
|
1853
|
+
...typeof options.markdown !== "boolean" ? options.markdown : {},
|
|
1753
1854
|
componentExts,
|
|
1754
1855
|
overrides: overrides.markdown
|
|
1755
1856
|
}));
|
|
@@ -1795,6 +1896,7 @@ var src_default = lincy;
|
|
|
1795
1896
|
GLOB_YAML,
|
|
1796
1897
|
combine,
|
|
1797
1898
|
comments,
|
|
1899
|
+
ensurePackages,
|
|
1798
1900
|
ignores,
|
|
1799
1901
|
imports,
|
|
1800
1902
|
interopDefault,
|
|
@@ -1814,6 +1916,7 @@ var src_default = lincy;
|
|
|
1814
1916
|
toArray,
|
|
1815
1917
|
typescript,
|
|
1816
1918
|
unicorn,
|
|
1919
|
+
unocss,
|
|
1817
1920
|
vue,
|
|
1818
1921
|
yaml
|
|
1819
1922
|
});
|