@lincy/eslint-config 4.0.2 → 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 +200 -97
- package/dist/index.d.cts +75 -35
- package/dist/index.d.ts +75 -35
- package/dist/index.js +196 -95
- package/package.json +38 -15
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
|
-
import
|
|
2
|
+
import process3 from "process";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { isPackageExists } from "local-pkg";
|
|
4
|
+
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
5
5
|
|
|
6
6
|
// src/plugins.ts
|
|
7
7
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
@@ -362,6 +362,8 @@ async function javascript(options = {}) {
|
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
// src/utils.ts
|
|
365
|
+
import process from "process";
|
|
366
|
+
import { isPackageExists } from "local-pkg";
|
|
365
367
|
async function combine(...configs) {
|
|
366
368
|
const resolved = await Promise.all(configs);
|
|
367
369
|
return resolved.flat();
|
|
@@ -382,6 +384,23 @@ async function interopDefault(m) {
|
|
|
382
384
|
const resolved = await m;
|
|
383
385
|
return resolved.default || resolved;
|
|
384
386
|
}
|
|
387
|
+
async function ensurePackages(packages) {
|
|
388
|
+
if (process.stdout.isTTY === false)
|
|
389
|
+
return;
|
|
390
|
+
const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
|
|
391
|
+
if (nonExistingPackages.length === 0)
|
|
392
|
+
return;
|
|
393
|
+
const { default: prompts } = await import("prompts");
|
|
394
|
+
const { result } = await prompts([
|
|
395
|
+
{
|
|
396
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
397
|
+
name: "result",
|
|
398
|
+
type: "confirm"
|
|
399
|
+
}
|
|
400
|
+
]);
|
|
401
|
+
if (result)
|
|
402
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
403
|
+
}
|
|
385
404
|
|
|
386
405
|
// src/configs/jsdoc.ts
|
|
387
406
|
async function jsdoc(options = {}) {
|
|
@@ -423,6 +442,7 @@ async function jsdoc(options = {}) {
|
|
|
423
442
|
// src/configs/jsonc.ts
|
|
424
443
|
async function jsonc(options = {}) {
|
|
425
444
|
const {
|
|
445
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
426
446
|
overrides = {},
|
|
427
447
|
stylistic: stylistic2 = true
|
|
428
448
|
} = options;
|
|
@@ -441,7 +461,7 @@ async function jsonc(options = {}) {
|
|
|
441
461
|
}
|
|
442
462
|
},
|
|
443
463
|
{
|
|
444
|
-
files
|
|
464
|
+
files,
|
|
445
465
|
languageOptions: {
|
|
446
466
|
parser: parserJsonc
|
|
447
467
|
},
|
|
@@ -495,6 +515,7 @@ async function jsonc(options = {}) {
|
|
|
495
515
|
async function markdown(options = {}) {
|
|
496
516
|
const {
|
|
497
517
|
componentExts = [],
|
|
518
|
+
files = [GLOB_MARKDOWN],
|
|
498
519
|
overrides = {}
|
|
499
520
|
} = options;
|
|
500
521
|
return [
|
|
@@ -506,7 +527,7 @@ async function markdown(options = {}) {
|
|
|
506
527
|
}
|
|
507
528
|
},
|
|
508
529
|
{
|
|
509
|
-
files
|
|
530
|
+
files,
|
|
510
531
|
name: "eslint:markdown:processor",
|
|
511
532
|
processor: "markdown/markdown"
|
|
512
533
|
},
|
|
@@ -950,7 +971,7 @@ async function stylistic(options = {}) {
|
|
|
950
971
|
"style/jsx-first-prop-new-line": "error",
|
|
951
972
|
"style/jsx-indent": ["error", indent, { checkAttributes: true, indentLogicalExpressions: true }],
|
|
952
973
|
"style/jsx-indent-props": ["error", indent],
|
|
953
|
-
"style/jsx-max-props-per-line": ["error", { maximum:
|
|
974
|
+
"style/jsx-max-props-per-line": ["error", { maximum: 4 }],
|
|
954
975
|
// 在 JSX 中的单行上强制执行最多 props 数量
|
|
955
976
|
"style/jsx-newline": "off",
|
|
956
977
|
// 在 jsx 元素和表达式之后换行
|
|
@@ -980,13 +1001,17 @@ async function stylistic(options = {}) {
|
|
|
980
1001
|
}
|
|
981
1002
|
|
|
982
1003
|
// src/configs/typescript.ts
|
|
983
|
-
import
|
|
984
|
-
async function typescript(options) {
|
|
1004
|
+
import process2 from "process";
|
|
1005
|
+
async function typescript(options = {}) {
|
|
985
1006
|
const {
|
|
986
1007
|
componentExts = [],
|
|
987
1008
|
overrides = {},
|
|
988
1009
|
parserOptions = {}
|
|
989
|
-
} = options
|
|
1010
|
+
} = options;
|
|
1011
|
+
const files = options.files ?? [
|
|
1012
|
+
GLOB_SRC,
|
|
1013
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1014
|
+
];
|
|
990
1015
|
const typeAwareRules = {
|
|
991
1016
|
"dot-notation": "off",
|
|
992
1017
|
"no-implied-eval": "off",
|
|
@@ -1026,10 +1051,7 @@ async function typescript(options) {
|
|
|
1026
1051
|
}
|
|
1027
1052
|
},
|
|
1028
1053
|
{
|
|
1029
|
-
files
|
|
1030
|
-
GLOB_SRC,
|
|
1031
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1032
|
-
],
|
|
1054
|
+
files,
|
|
1033
1055
|
languageOptions: {
|
|
1034
1056
|
parser: parserTs,
|
|
1035
1057
|
parserOptions: {
|
|
@@ -1037,7 +1059,7 @@ async function typescript(options) {
|
|
|
1037
1059
|
sourceType: "module",
|
|
1038
1060
|
...tsconfigPath ? {
|
|
1039
1061
|
project: tsconfigPath,
|
|
1040
|
-
tsconfigRootDir:
|
|
1062
|
+
tsconfigRootDir: process2.cwd()
|
|
1041
1063
|
} : {},
|
|
1042
1064
|
...parserOptions
|
|
1043
1065
|
}
|
|
@@ -1165,6 +1187,7 @@ vueVersion = vueVersion && vueVersion[0];
|
|
|
1165
1187
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
1166
1188
|
async function vue(options = {}) {
|
|
1167
1189
|
const {
|
|
1190
|
+
files = [GLOB_VUE],
|
|
1168
1191
|
overrides = {},
|
|
1169
1192
|
stylistic: stylistic2 = true
|
|
1170
1193
|
} = options;
|
|
@@ -1187,7 +1210,7 @@ async function vue(options = {}) {
|
|
|
1187
1210
|
}
|
|
1188
1211
|
},
|
|
1189
1212
|
{
|
|
1190
|
-
files
|
|
1213
|
+
files,
|
|
1191
1214
|
languageOptions: {
|
|
1192
1215
|
parser: parserVue,
|
|
1193
1216
|
parserOptions: {
|
|
@@ -1306,6 +1329,7 @@ async function vue(options = {}) {
|
|
|
1306
1329
|
// src/configs/yaml.ts
|
|
1307
1330
|
async function yaml(options = {}) {
|
|
1308
1331
|
const {
|
|
1332
|
+
files = [GLOB_YAML],
|
|
1309
1333
|
overrides = {},
|
|
1310
1334
|
stylistic: stylistic2 = true
|
|
1311
1335
|
} = options;
|
|
@@ -1324,7 +1348,7 @@ async function yaml(options = {}) {
|
|
|
1324
1348
|
}
|
|
1325
1349
|
},
|
|
1326
1350
|
{
|
|
1327
|
-
files
|
|
1351
|
+
files,
|
|
1328
1352
|
languageOptions: {
|
|
1329
1353
|
parser: parserYaml
|
|
1330
1354
|
},
|
|
@@ -1360,6 +1384,7 @@ async function yaml(options = {}) {
|
|
|
1360
1384
|
// src/configs/test.ts
|
|
1361
1385
|
async function test(options = {}) {
|
|
1362
1386
|
const {
|
|
1387
|
+
files = GLOB_TESTS,
|
|
1363
1388
|
isInEditor = false,
|
|
1364
1389
|
overrides = {}
|
|
1365
1390
|
} = options;
|
|
@@ -1386,7 +1411,7 @@ async function test(options = {}) {
|
|
|
1386
1411
|
}
|
|
1387
1412
|
},
|
|
1388
1413
|
{
|
|
1389
|
-
files
|
|
1414
|
+
files,
|
|
1390
1415
|
name: "eslint:test:rules",
|
|
1391
1416
|
rules: {
|
|
1392
1417
|
"node/prefer-global/process": "off",
|
|
@@ -1414,31 +1439,49 @@ async function perfectionist() {
|
|
|
1414
1439
|
}
|
|
1415
1440
|
|
|
1416
1441
|
// src/configs/react.ts
|
|
1442
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1443
|
+
var ReactRefreshAllowConstantExportPackages = [
|
|
1444
|
+
"vite"
|
|
1445
|
+
];
|
|
1417
1446
|
async function react(options = {}) {
|
|
1418
1447
|
const {
|
|
1448
|
+
files = [GLOB_JSX, GLOB_TSX],
|
|
1419
1449
|
jsx = true,
|
|
1420
1450
|
overrides = {},
|
|
1451
|
+
typescript: typescript2 = true,
|
|
1421
1452
|
version = "17.0"
|
|
1422
1453
|
} = options;
|
|
1454
|
+
await ensurePackages([
|
|
1455
|
+
"eslint-plugin-react",
|
|
1456
|
+
"eslint-plugin-react-hooks",
|
|
1457
|
+
"eslint-plugin-react-refresh"
|
|
1458
|
+
]);
|
|
1423
1459
|
const [
|
|
1424
1460
|
pluginReact,
|
|
1425
|
-
pluginReactHooks
|
|
1461
|
+
pluginReactHooks,
|
|
1462
|
+
pluginReactRefresh
|
|
1426
1463
|
] = await Promise.all([
|
|
1427
1464
|
// @ts-expect-error missing types
|
|
1428
1465
|
interopDefault(import("eslint-plugin-react")),
|
|
1429
1466
|
// @ts-expect-error missing types
|
|
1430
|
-
interopDefault(import("eslint-plugin-react-hooks"))
|
|
1467
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1468
|
+
// @ts-expect-error missing types
|
|
1469
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1431
1470
|
]);
|
|
1471
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1472
|
+
(i) => isPackageExists2(i)
|
|
1473
|
+
);
|
|
1432
1474
|
return [
|
|
1433
1475
|
{
|
|
1434
1476
|
name: "eslint:react:setup",
|
|
1435
1477
|
plugins: {
|
|
1436
1478
|
"react": pluginReact,
|
|
1437
|
-
"react-hooks": pluginReactHooks
|
|
1479
|
+
"react-hooks": pluginReactHooks,
|
|
1480
|
+
"react-refresh": pluginReactRefresh
|
|
1438
1481
|
}
|
|
1439
1482
|
},
|
|
1440
1483
|
{
|
|
1441
|
-
files
|
|
1484
|
+
files,
|
|
1442
1485
|
languageOptions: {
|
|
1443
1486
|
parserOptions: {
|
|
1444
1487
|
ecmaFeatures: {
|
|
@@ -1448,100 +1491,111 @@ async function react(options = {}) {
|
|
|
1448
1491
|
},
|
|
1449
1492
|
name: "eslint:react:rules",
|
|
1450
1493
|
rules: {
|
|
1494
|
+
// react-hooks
|
|
1451
1495
|
"react-hooks/exhaustive-deps": "warn",
|
|
1452
1496
|
"react-hooks/rules-of-hooks": "error",
|
|
1453
|
-
|
|
1454
|
-
"react/
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1497
|
+
// react-refresh
|
|
1498
|
+
"react-refresh/only-export-components": [
|
|
1499
|
+
"warn",
|
|
1500
|
+
{ allowConstantExport: isAllowConstantExport }
|
|
1501
|
+
],
|
|
1502
|
+
// react
|
|
1503
|
+
"react/boolean-prop-naming": "error",
|
|
1504
|
+
"react/button-has-type": "error",
|
|
1505
|
+
"react/default-props-match-prop-types": "error",
|
|
1506
|
+
"react/destructuring-assignment": "error",
|
|
1507
|
+
"react/display-name": "error",
|
|
1458
1508
|
"react/forbid-component-props": "off",
|
|
1459
1509
|
// 禁止组件上使用某些 props
|
|
1460
|
-
"react/forbid-dom-props":
|
|
1461
|
-
"react/forbid-elements":
|
|
1462
|
-
"react/forbid-foreign-prop-types":
|
|
1463
|
-
"react/forbid-prop-types":
|
|
1464
|
-
"react/function-component-definition":
|
|
1510
|
+
"react/forbid-dom-props": "error",
|
|
1511
|
+
"react/forbid-elements": "error",
|
|
1512
|
+
"react/forbid-foreign-prop-types": "error",
|
|
1513
|
+
"react/forbid-prop-types": "error",
|
|
1514
|
+
"react/function-component-definition": "error",
|
|
1465
1515
|
"react/hook-use-state": "off",
|
|
1466
1516
|
// useState 钩子值和 setter 变量的解构和对称命名
|
|
1467
|
-
"react/iframe-missing-sandbox":
|
|
1468
|
-
"react/jsx-boolean-value":
|
|
1517
|
+
"react/iframe-missing-sandbox": "error",
|
|
1518
|
+
"react/jsx-boolean-value": "error",
|
|
1469
1519
|
"react/jsx-filename-extension": "off",
|
|
1470
1520
|
// 禁止可能包含 JSX 文件扩展名
|
|
1471
|
-
"react/jsx-fragments":
|
|
1472
|
-
"react/jsx-handler-names":
|
|
1473
|
-
"react/jsx-key":
|
|
1521
|
+
"react/jsx-fragments": "error",
|
|
1522
|
+
"react/jsx-handler-names": "error",
|
|
1523
|
+
"react/jsx-key": "error",
|
|
1474
1524
|
"react/jsx-max-depth": "off",
|
|
1475
1525
|
// 强制 JSX 最大深度
|
|
1476
1526
|
"react/jsx-no-bind": "off",
|
|
1477
1527
|
// .bind()JSX 属性中禁止使用箭头函数
|
|
1478
|
-
"react/jsx-no-comment-textnodes":
|
|
1479
|
-
"react/jsx-no-constructed-context-values":
|
|
1480
|
-
"react/jsx-no-duplicate-props":
|
|
1481
|
-
"react/jsx-no-leaked-render":
|
|
1528
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
1529
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
1530
|
+
"react/jsx-no-duplicate-props": "error",
|
|
1531
|
+
"react/jsx-no-leaked-render": "error",
|
|
1482
1532
|
"react/jsx-no-literals": "off",
|
|
1483
1533
|
// 禁止在 JSX 中使用字符串文字
|
|
1484
|
-
"react/jsx-no-script-url":
|
|
1485
|
-
"react/jsx-no-target-blank":
|
|
1486
|
-
"react/jsx-no-undef":
|
|
1487
|
-
"react/jsx-no-useless-fragment":
|
|
1488
|
-
"react/jsx-pascal-case":
|
|
1534
|
+
"react/jsx-no-script-url": "error",
|
|
1535
|
+
"react/jsx-no-target-blank": "error",
|
|
1536
|
+
"react/jsx-no-undef": "error",
|
|
1537
|
+
"react/jsx-no-useless-fragment": "error",
|
|
1538
|
+
"react/jsx-pascal-case": "error",
|
|
1489
1539
|
"react/jsx-props-no-spreading": "off",
|
|
1490
1540
|
// 强制任何 JSX 属性都不会传播
|
|
1491
|
-
"react/jsx-uses-react":
|
|
1492
|
-
"react/jsx-uses-vars":
|
|
1493
|
-
"react/no-access-state-in-setstate":
|
|
1494
|
-
"react/no-adjacent-inline-elements":
|
|
1495
|
-
"react/no-array-index-key":
|
|
1496
|
-
"react/no-arrow-function-lifecycle":
|
|
1497
|
-
"react/no-children-prop":
|
|
1541
|
+
"react/jsx-uses-react": "error",
|
|
1542
|
+
"react/jsx-uses-vars": "error",
|
|
1543
|
+
"react/no-access-state-in-setstate": "error",
|
|
1544
|
+
"react/no-adjacent-inline-elements": "error",
|
|
1545
|
+
"react/no-array-index-key": "error",
|
|
1546
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
1547
|
+
"react/no-children-prop": "error",
|
|
1498
1548
|
"react/no-danger": "off",
|
|
1499
1549
|
// 禁止使用 dangerouslySetInnerHTML
|
|
1500
|
-
"react/no-danger-with-children":
|
|
1501
|
-
"react/no-deprecated":
|
|
1502
|
-
"react/no-did-mount-set-state":
|
|
1503
|
-
"react/no-did-update-set-state":
|
|
1504
|
-
"react/no-direct-mutation-state":
|
|
1505
|
-
"react/no-find-dom-node":
|
|
1506
|
-
"react/no-invalid-html-attribute":
|
|
1507
|
-
"react/no-is-mounted":
|
|
1508
|
-
"react/no-multi-comp":
|
|
1509
|
-
"react/no-namespace":
|
|
1510
|
-
"react/no-object-type-as-default-prop":
|
|
1511
|
-
"react/no-redundant-should-component-update":
|
|
1512
|
-
"react/no-render-return-value":
|
|
1513
|
-
"react/no-set-state":
|
|
1514
|
-
"react/no-string-refs":
|
|
1515
|
-
"react/no-this-in-sfc":
|
|
1516
|
-
"react/no-typos":
|
|
1517
|
-
"react/no-unescaped-entities":
|
|
1518
|
-
"react/no-unknown-property":
|
|
1550
|
+
"react/no-danger-with-children": "error",
|
|
1551
|
+
"react/no-deprecated": "error",
|
|
1552
|
+
"react/no-did-mount-set-state": "error",
|
|
1553
|
+
"react/no-did-update-set-state": "error",
|
|
1554
|
+
"react/no-direct-mutation-state": "error",
|
|
1555
|
+
"react/no-find-dom-node": "error",
|
|
1556
|
+
"react/no-invalid-html-attribute": "error",
|
|
1557
|
+
"react/no-is-mounted": "error",
|
|
1558
|
+
"react/no-multi-comp": "error",
|
|
1559
|
+
"react/no-namespace": "error",
|
|
1560
|
+
"react/no-object-type-as-default-prop": "error",
|
|
1561
|
+
"react/no-redundant-should-component-update": "error",
|
|
1562
|
+
"react/no-render-return-value": "error",
|
|
1563
|
+
"react/no-set-state": "error",
|
|
1564
|
+
"react/no-string-refs": "error",
|
|
1565
|
+
"react/no-this-in-sfc": "error",
|
|
1566
|
+
"react/no-typos": "error",
|
|
1567
|
+
"react/no-unescaped-entities": "error",
|
|
1568
|
+
"react/no-unknown-property": "error",
|
|
1519
1569
|
"react/no-unsafe": "off",
|
|
1520
1570
|
// 禁止使用不安全的生命周期方法
|
|
1521
|
-
"react/no-unstable-nested-components":
|
|
1522
|
-
"react/no-unused-class-component-methods":
|
|
1523
|
-
"react/no-unused-prop-types":
|
|
1524
|
-
"react/no-unused-state":
|
|
1525
|
-
"react/no-will-update-set-state":
|
|
1526
|
-
"react/prefer-es6-class":
|
|
1527
|
-
"react/prefer-exact-props":
|
|
1528
|
-
"react/prefer-read-only-props":
|
|
1529
|
-
"react/prefer-stateless-function":
|
|
1530
|
-
"react/prop-types":
|
|
1571
|
+
"react/no-unstable-nested-components": "error",
|
|
1572
|
+
"react/no-unused-class-component-methods": "error",
|
|
1573
|
+
"react/no-unused-prop-types": "error",
|
|
1574
|
+
"react/no-unused-state": "error",
|
|
1575
|
+
"react/no-will-update-set-state": "error",
|
|
1576
|
+
"react/prefer-es6-class": "error",
|
|
1577
|
+
"react/prefer-exact-props": "error",
|
|
1578
|
+
"react/prefer-read-only-props": "error",
|
|
1579
|
+
"react/prefer-stateless-function": "error",
|
|
1580
|
+
"react/prop-types": "error",
|
|
1531
1581
|
"react/react-in-jsx-scope": "off",
|
|
1532
1582
|
// 使用 JSX 时需要引入 React
|
|
1533
1583
|
"react/require-default-props": "off",
|
|
1534
1584
|
// 为每个非必需 prop 强制执行 defaultProps 定义
|
|
1535
|
-
"react/require-optimization":
|
|
1536
|
-
"react/require-render-return":
|
|
1537
|
-
"react/self-closing-comp":
|
|
1538
|
-
"react/sort-comp":
|
|
1539
|
-
"react/sort-default-props":
|
|
1540
|
-
"react/sort-prop-types":
|
|
1541
|
-
"react/state-in-constructor":
|
|
1542
|
-
"react/static-property-placement":
|
|
1543
|
-
"react/style-prop-object":
|
|
1544
|
-
"react/void-dom-elements-no-children":
|
|
1585
|
+
"react/require-optimization": "error",
|
|
1586
|
+
"react/require-render-return": "error",
|
|
1587
|
+
"react/self-closing-comp": "error",
|
|
1588
|
+
"react/sort-comp": "error",
|
|
1589
|
+
"react/sort-default-props": "error",
|
|
1590
|
+
"react/sort-prop-types": "error",
|
|
1591
|
+
"react/state-in-constructor": "error",
|
|
1592
|
+
"react/static-property-placement": "error",
|
|
1593
|
+
"react/style-prop-object": "error",
|
|
1594
|
+
"react/void-dom-elements-no-children": "error",
|
|
1595
|
+
...typescript2 ? {
|
|
1596
|
+
"react/jsx-no-undef": "off",
|
|
1597
|
+
"react/prop-type": "off"
|
|
1598
|
+
} : {},
|
|
1545
1599
|
...overrides
|
|
1546
1600
|
},
|
|
1547
1601
|
settings: {
|
|
@@ -1553,6 +1607,39 @@ async function react(options = {}) {
|
|
|
1553
1607
|
];
|
|
1554
1608
|
}
|
|
1555
1609
|
|
|
1610
|
+
// src/configs/unocss.ts
|
|
1611
|
+
async function unocss(options = {}) {
|
|
1612
|
+
const {
|
|
1613
|
+
attributify = true,
|
|
1614
|
+
strict = false
|
|
1615
|
+
} = options;
|
|
1616
|
+
await ensurePackages([
|
|
1617
|
+
"@unocss/eslint-plugin"
|
|
1618
|
+
]);
|
|
1619
|
+
const [
|
|
1620
|
+
pluginUnoCSS
|
|
1621
|
+
] = await Promise.all([
|
|
1622
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1623
|
+
]);
|
|
1624
|
+
return [
|
|
1625
|
+
{
|
|
1626
|
+
name: "eslint:unocss",
|
|
1627
|
+
plugins: {
|
|
1628
|
+
unocss: pluginUnoCSS
|
|
1629
|
+
},
|
|
1630
|
+
rules: {
|
|
1631
|
+
"unocss/order": "off",
|
|
1632
|
+
...attributify ? {
|
|
1633
|
+
"unocss/order-attributify": "warn"
|
|
1634
|
+
} : {},
|
|
1635
|
+
...strict ? {
|
|
1636
|
+
"unocss/blocklist": "error"
|
|
1637
|
+
} : {}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
];
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1556
1643
|
// src/factory.ts
|
|
1557
1644
|
var flatConfigProps = [
|
|
1558
1645
|
"files",
|
|
@@ -1578,11 +1665,12 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1578
1665
|
const {
|
|
1579
1666
|
componentExts = [],
|
|
1580
1667
|
gitignore: enableGitignore = true,
|
|
1581
|
-
isInEditor = !!((
|
|
1668
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
|
|
1582
1669
|
overrides = {},
|
|
1583
|
-
react: enableReact = ReactPackages.some((i) =>
|
|
1584
|
-
typescript: enableTypeScript =
|
|
1585
|
-
|
|
1670
|
+
react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
|
|
1671
|
+
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
1672
|
+
unocss: enableUnoCSS = false,
|
|
1673
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
|
|
1586
1674
|
} = options;
|
|
1587
1675
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1588
1676
|
if (stylisticOptions) {
|
|
@@ -1635,12 +1723,14 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1635
1723
|
}
|
|
1636
1724
|
if (options.test ?? true) {
|
|
1637
1725
|
configs.push(test({
|
|
1726
|
+
...typeof options.test !== "boolean" ? options.test : {},
|
|
1638
1727
|
isInEditor,
|
|
1639
1728
|
overrides: overrides.test
|
|
1640
1729
|
}));
|
|
1641
1730
|
}
|
|
1642
1731
|
if (enableVue) {
|
|
1643
1732
|
configs.push(vue({
|
|
1733
|
+
...typeof options.vue !== "boolean" ? options.vue : {},
|
|
1644
1734
|
overrides: overrides.vue,
|
|
1645
1735
|
stylistic: stylisticOptions,
|
|
1646
1736
|
typescript: !!enableTypeScript
|
|
@@ -1648,13 +1738,20 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1648
1738
|
}
|
|
1649
1739
|
if (enableReact) {
|
|
1650
1740
|
configs.push(react({
|
|
1741
|
+
...typeof enableReact !== "boolean" ? enableReact : {},
|
|
1651
1742
|
overrides: overrides.react,
|
|
1652
|
-
|
|
1743
|
+
typescript: !!enableTypeScript
|
|
1653
1744
|
}));
|
|
1654
1745
|
}
|
|
1746
|
+
if (enableUnoCSS) {
|
|
1747
|
+
configs.push(unocss(
|
|
1748
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1749
|
+
));
|
|
1750
|
+
}
|
|
1655
1751
|
if (options.jsonc ?? true) {
|
|
1656
1752
|
configs.push(
|
|
1657
1753
|
jsonc({
|
|
1754
|
+
...typeof options.jsonc !== "boolean" ? options.jsonc : {},
|
|
1658
1755
|
overrides: overrides.jsonc,
|
|
1659
1756
|
stylistic: stylisticOptions
|
|
1660
1757
|
}),
|
|
@@ -1664,12 +1761,14 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1664
1761
|
}
|
|
1665
1762
|
if (options.yaml ?? true) {
|
|
1666
1763
|
configs.push(yaml({
|
|
1764
|
+
...typeof options.yaml !== "boolean" ? options.yaml : {},
|
|
1667
1765
|
overrides: overrides.yaml,
|
|
1668
1766
|
stylistic: stylisticOptions
|
|
1669
1767
|
}));
|
|
1670
1768
|
}
|
|
1671
1769
|
if (options.markdown ?? true) {
|
|
1672
1770
|
configs.push(markdown({
|
|
1771
|
+
...typeof options.markdown !== "boolean" ? options.markdown : {},
|
|
1673
1772
|
componentExts,
|
|
1674
1773
|
overrides: overrides.markdown
|
|
1675
1774
|
}));
|
|
@@ -1715,6 +1814,7 @@ export {
|
|
|
1715
1814
|
combine,
|
|
1716
1815
|
comments,
|
|
1717
1816
|
src_default as default,
|
|
1817
|
+
ensurePackages,
|
|
1718
1818
|
ignores,
|
|
1719
1819
|
imports,
|
|
1720
1820
|
interopDefault,
|
|
@@ -1734,6 +1834,7 @@ export {
|
|
|
1734
1834
|
toArray,
|
|
1735
1835
|
typescript,
|
|
1736
1836
|
unicorn,
|
|
1837
|
+
unocss,
|
|
1737
1838
|
vue,
|
|
1738
1839
|
yaml
|
|
1739
1840
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"packageManager": "pnpm@8.7.6",
|
|
6
6
|
"description": "LinCenYing's ESLint config",
|
|
7
7
|
"author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
|
|
@@ -36,15 +36,34 @@
|
|
|
36
36
|
"prepare": "sh simple-git-hooks.sh"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"eslint": ">=
|
|
39
|
+
"@unocss/eslint-plugin": ">=0.50.0",
|
|
40
|
+
"eslint": ">=8.40.0",
|
|
41
|
+
"eslint-plugin-react": "^7.33.2",
|
|
42
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
43
|
+
"eslint-plugin-react-refresh": "^0.4.4"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@unocss/eslint-plugin": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"eslint-plugin-react": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"eslint-plugin-react-hooks": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"eslint-plugin-react-refresh": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
40
58
|
},
|
|
41
59
|
"dependencies": {
|
|
42
60
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@typescript-eslint/
|
|
61
|
+
"@antfu/install-pkg": "^0.3.0",
|
|
62
|
+
"@stylistic/eslint-plugin": "1.4.1",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
64
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
46
65
|
"eslint-config-flat-gitignore": "^0.1.1",
|
|
47
|
-
"eslint-plugin-antfu": "^1.0.
|
|
66
|
+
"eslint-plugin-antfu": "^1.0.11",
|
|
48
67
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
49
68
|
"eslint-plugin-i": "^2.29.0",
|
|
50
69
|
"eslint-plugin-jsdoc": "^46.9.0",
|
|
@@ -52,9 +71,7 @@
|
|
|
52
71
|
"eslint-plugin-markdown": "^3.0.1",
|
|
53
72
|
"eslint-plugin-n": "^16.3.1",
|
|
54
73
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
55
|
-
"eslint-plugin-perfectionist": "^2.4.
|
|
56
|
-
"eslint-plugin-react": "^7.33.2",
|
|
57
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
74
|
+
"eslint-plugin-perfectionist": "^2.4.2",
|
|
58
75
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
59
76
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
60
77
|
"eslint-plugin-vitest": "^0.3.10",
|
|
@@ -63,29 +80,35 @@
|
|
|
63
80
|
"globals": "^13.23.0",
|
|
64
81
|
"jsonc-eslint-parser": "^2.4.0",
|
|
65
82
|
"local-pkg": "^0.5.0",
|
|
83
|
+
"prompts": "^2.4.2",
|
|
66
84
|
"vue-eslint-parser": "^9.3.2",
|
|
67
85
|
"yaml-eslint-parser": "^1.2.2"
|
|
68
86
|
},
|
|
69
87
|
"devDependencies": {
|
|
70
|
-
"@antfu/ni": "^0.21.
|
|
88
|
+
"@antfu/ni": "^0.21.10",
|
|
71
89
|
"@eslint-types/jsdoc": "46.9.0",
|
|
72
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
90
|
+
"@eslint-types/typescript-eslint": "^6.12.0",
|
|
73
91
|
"@eslint-types/unicorn": "^49.0.0",
|
|
74
92
|
"@lincy/eslint-config": "workspace:*",
|
|
75
|
-
"@stylistic/eslint-plugin-migrate": "^1.4.
|
|
93
|
+
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
76
94
|
"@types/eslint": "^8.44.7",
|
|
77
|
-
"@types/node": "^20.
|
|
95
|
+
"@types/node": "^20.10.0",
|
|
96
|
+
"@types/prompts": "^2.4.9",
|
|
97
|
+
"@unocss/eslint-plugin": "^0.57.7",
|
|
78
98
|
"bumpp": "^9.2.0",
|
|
79
99
|
"eslint": "^8.54.0",
|
|
80
100
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
101
|
+
"eslint-plugin-react": "^7.33.2",
|
|
102
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
103
|
+
"eslint-plugin-react-refresh": "^0.4.4",
|
|
81
104
|
"esno": "^4.0.0",
|
|
82
105
|
"lint-staged": "^15.1.0",
|
|
83
106
|
"rimraf": "^5.0.5",
|
|
84
107
|
"simple-git-hooks": "^2.9.0",
|
|
85
108
|
"simple-open-url": "^3.0.1",
|
|
86
109
|
"sucrase": "^3.34.0",
|
|
87
|
-
"tsup": "^8.0.
|
|
88
|
-
"typescript": "^5.
|
|
110
|
+
"tsup": "^8.0.1",
|
|
111
|
+
"typescript": "^5.3.2",
|
|
89
112
|
"unbuild": "^2.0.0",
|
|
90
113
|
"vitest": "^0.34.6"
|
|
91
114
|
},
|