@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.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,100 +1573,111 @@ 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",
|
|
1533
|
-
|
|
1534
|
-
"react/
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1579
|
+
// react-refresh
|
|
1580
|
+
"react-refresh/only-export-components": [
|
|
1581
|
+
"warn",
|
|
1582
|
+
{ allowConstantExport: isAllowConstantExport }
|
|
1583
|
+
],
|
|
1584
|
+
// react
|
|
1585
|
+
"react/boolean-prop-naming": "error",
|
|
1586
|
+
"react/button-has-type": "error",
|
|
1587
|
+
"react/default-props-match-prop-types": "error",
|
|
1588
|
+
"react/destructuring-assignment": "error",
|
|
1589
|
+
"react/display-name": "error",
|
|
1538
1590
|
"react/forbid-component-props": "off",
|
|
1539
1591
|
// 禁止组件上使用某些 props
|
|
1540
|
-
"react/forbid-dom-props":
|
|
1541
|
-
"react/forbid-elements":
|
|
1542
|
-
"react/forbid-foreign-prop-types":
|
|
1543
|
-
"react/forbid-prop-types":
|
|
1544
|
-
"react/function-component-definition":
|
|
1592
|
+
"react/forbid-dom-props": "error",
|
|
1593
|
+
"react/forbid-elements": "error",
|
|
1594
|
+
"react/forbid-foreign-prop-types": "error",
|
|
1595
|
+
"react/forbid-prop-types": "error",
|
|
1596
|
+
"react/function-component-definition": "error",
|
|
1545
1597
|
"react/hook-use-state": "off",
|
|
1546
1598
|
// useState 钩子值和 setter 变量的解构和对称命名
|
|
1547
|
-
"react/iframe-missing-sandbox":
|
|
1548
|
-
"react/jsx-boolean-value":
|
|
1599
|
+
"react/iframe-missing-sandbox": "error",
|
|
1600
|
+
"react/jsx-boolean-value": "error",
|
|
1549
1601
|
"react/jsx-filename-extension": "off",
|
|
1550
1602
|
// 禁止可能包含 JSX 文件扩展名
|
|
1551
|
-
"react/jsx-fragments":
|
|
1552
|
-
"react/jsx-handler-names":
|
|
1553
|
-
"react/jsx-key":
|
|
1603
|
+
"react/jsx-fragments": "error",
|
|
1604
|
+
"react/jsx-handler-names": "error",
|
|
1605
|
+
"react/jsx-key": "error",
|
|
1554
1606
|
"react/jsx-max-depth": "off",
|
|
1555
1607
|
// 强制 JSX 最大深度
|
|
1556
1608
|
"react/jsx-no-bind": "off",
|
|
1557
1609
|
// .bind()JSX 属性中禁止使用箭头函数
|
|
1558
|
-
"react/jsx-no-comment-textnodes":
|
|
1559
|
-
"react/jsx-no-constructed-context-values":
|
|
1560
|
-
"react/jsx-no-duplicate-props":
|
|
1561
|
-
"react/jsx-no-leaked-render":
|
|
1610
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
1611
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
1612
|
+
"react/jsx-no-duplicate-props": "error",
|
|
1613
|
+
"react/jsx-no-leaked-render": "error",
|
|
1562
1614
|
"react/jsx-no-literals": "off",
|
|
1563
1615
|
// 禁止在 JSX 中使用字符串文字
|
|
1564
|
-
"react/jsx-no-script-url":
|
|
1565
|
-
"react/jsx-no-target-blank":
|
|
1566
|
-
"react/jsx-no-undef":
|
|
1567
|
-
"react/jsx-no-useless-fragment":
|
|
1568
|
-
"react/jsx-pascal-case":
|
|
1616
|
+
"react/jsx-no-script-url": "error",
|
|
1617
|
+
"react/jsx-no-target-blank": "error",
|
|
1618
|
+
"react/jsx-no-undef": "error",
|
|
1619
|
+
"react/jsx-no-useless-fragment": "error",
|
|
1620
|
+
"react/jsx-pascal-case": "error",
|
|
1569
1621
|
"react/jsx-props-no-spreading": "off",
|
|
1570
1622
|
// 强制任何 JSX 属性都不会传播
|
|
1571
|
-
"react/jsx-uses-react":
|
|
1572
|
-
"react/jsx-uses-vars":
|
|
1573
|
-
"react/no-access-state-in-setstate":
|
|
1574
|
-
"react/no-adjacent-inline-elements":
|
|
1575
|
-
"react/no-array-index-key":
|
|
1576
|
-
"react/no-arrow-function-lifecycle":
|
|
1577
|
-
"react/no-children-prop":
|
|
1623
|
+
"react/jsx-uses-react": "error",
|
|
1624
|
+
"react/jsx-uses-vars": "error",
|
|
1625
|
+
"react/no-access-state-in-setstate": "error",
|
|
1626
|
+
"react/no-adjacent-inline-elements": "error",
|
|
1627
|
+
"react/no-array-index-key": "error",
|
|
1628
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
1629
|
+
"react/no-children-prop": "error",
|
|
1578
1630
|
"react/no-danger": "off",
|
|
1579
1631
|
// 禁止使用 dangerouslySetInnerHTML
|
|
1580
|
-
"react/no-danger-with-children":
|
|
1581
|
-
"react/no-deprecated":
|
|
1582
|
-
"react/no-did-mount-set-state":
|
|
1583
|
-
"react/no-did-update-set-state":
|
|
1584
|
-
"react/no-direct-mutation-state":
|
|
1585
|
-
"react/no-find-dom-node":
|
|
1586
|
-
"react/no-invalid-html-attribute":
|
|
1587
|
-
"react/no-is-mounted":
|
|
1588
|
-
"react/no-multi-comp":
|
|
1589
|
-
"react/no-namespace":
|
|
1590
|
-
"react/no-object-type-as-default-prop":
|
|
1591
|
-
"react/no-redundant-should-component-update":
|
|
1592
|
-
"react/no-render-return-value":
|
|
1593
|
-
"react/no-set-state":
|
|
1594
|
-
"react/no-string-refs":
|
|
1595
|
-
"react/no-this-in-sfc":
|
|
1596
|
-
"react/no-typos":
|
|
1597
|
-
"react/no-unescaped-entities":
|
|
1598
|
-
"react/no-unknown-property":
|
|
1632
|
+
"react/no-danger-with-children": "error",
|
|
1633
|
+
"react/no-deprecated": "error",
|
|
1634
|
+
"react/no-did-mount-set-state": "error",
|
|
1635
|
+
"react/no-did-update-set-state": "error",
|
|
1636
|
+
"react/no-direct-mutation-state": "error",
|
|
1637
|
+
"react/no-find-dom-node": "error",
|
|
1638
|
+
"react/no-invalid-html-attribute": "error",
|
|
1639
|
+
"react/no-is-mounted": "error",
|
|
1640
|
+
"react/no-multi-comp": "error",
|
|
1641
|
+
"react/no-namespace": "error",
|
|
1642
|
+
"react/no-object-type-as-default-prop": "error",
|
|
1643
|
+
"react/no-redundant-should-component-update": "error",
|
|
1644
|
+
"react/no-render-return-value": "error",
|
|
1645
|
+
"react/no-set-state": "error",
|
|
1646
|
+
"react/no-string-refs": "error",
|
|
1647
|
+
"react/no-this-in-sfc": "error",
|
|
1648
|
+
"react/no-typos": "error",
|
|
1649
|
+
"react/no-unescaped-entities": "error",
|
|
1650
|
+
"react/no-unknown-property": "error",
|
|
1599
1651
|
"react/no-unsafe": "off",
|
|
1600
1652
|
// 禁止使用不安全的生命周期方法
|
|
1601
|
-
"react/no-unstable-nested-components":
|
|
1602
|
-
"react/no-unused-class-component-methods":
|
|
1603
|
-
"react/no-unused-prop-types":
|
|
1604
|
-
"react/no-unused-state":
|
|
1605
|
-
"react/no-will-update-set-state":
|
|
1606
|
-
"react/prefer-es6-class":
|
|
1607
|
-
"react/prefer-exact-props":
|
|
1608
|
-
"react/prefer-read-only-props":
|
|
1609
|
-
"react/prefer-stateless-function":
|
|
1610
|
-
"react/prop-types":
|
|
1653
|
+
"react/no-unstable-nested-components": "error",
|
|
1654
|
+
"react/no-unused-class-component-methods": "error",
|
|
1655
|
+
"react/no-unused-prop-types": "error",
|
|
1656
|
+
"react/no-unused-state": "error",
|
|
1657
|
+
"react/no-will-update-set-state": "error",
|
|
1658
|
+
"react/prefer-es6-class": "error",
|
|
1659
|
+
"react/prefer-exact-props": "error",
|
|
1660
|
+
"react/prefer-read-only-props": "error",
|
|
1661
|
+
"react/prefer-stateless-function": "error",
|
|
1662
|
+
"react/prop-types": "error",
|
|
1611
1663
|
"react/react-in-jsx-scope": "off",
|
|
1612
1664
|
// 使用 JSX 时需要引入 React
|
|
1613
1665
|
"react/require-default-props": "off",
|
|
1614
1666
|
// 为每个非必需 prop 强制执行 defaultProps 定义
|
|
1615
|
-
"react/require-optimization":
|
|
1616
|
-
"react/require-render-return":
|
|
1617
|
-
"react/self-closing-comp":
|
|
1618
|
-
"react/sort-comp":
|
|
1619
|
-
"react/sort-default-props":
|
|
1620
|
-
"react/sort-prop-types":
|
|
1621
|
-
"react/state-in-constructor":
|
|
1622
|
-
"react/static-property-placement":
|
|
1623
|
-
"react/style-prop-object":
|
|
1624
|
-
"react/void-dom-elements-no-children":
|
|
1667
|
+
"react/require-optimization": "error",
|
|
1668
|
+
"react/require-render-return": "error",
|
|
1669
|
+
"react/self-closing-comp": "error",
|
|
1670
|
+
"react/sort-comp": "error",
|
|
1671
|
+
"react/sort-default-props": "error",
|
|
1672
|
+
"react/sort-prop-types": "error",
|
|
1673
|
+
"react/state-in-constructor": "error",
|
|
1674
|
+
"react/static-property-placement": "error",
|
|
1675
|
+
"react/style-prop-object": "error",
|
|
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
|
});
|