@lincy/eslint-config 3.7.1 → 4.0.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 +65 -96
- package/dist/index.cjs +206 -117
- package/dist/index.d.cts +51 -55
- package/dist/index.d.ts +51 -55
- package/dist/index.js +212 -105
- package/package.json +14 -12
package/dist/index.js
CHANGED
|
@@ -2,32 +2,18 @@
|
|
|
2
2
|
import process2 from "process";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { isPackageExists } from "local-pkg";
|
|
5
|
-
import gitignore from "eslint-config-flat-gitignore";
|
|
6
5
|
|
|
7
6
|
// src/plugins.ts
|
|
8
7
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
9
8
|
import { default as default3 } from "eslint-plugin-eslint-comments";
|
|
10
9
|
import * as pluginImport from "eslint-plugin-i";
|
|
11
|
-
import { default as default4 } from "eslint-plugin-
|
|
12
|
-
import
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as default7 } from "@stylistic/eslint-plugin";
|
|
16
|
-
import { default as default8 } from "@typescript-eslint/eslint-plugin";
|
|
17
|
-
import { default as default9 } from "eslint-plugin-unicorn";
|
|
18
|
-
import { default as default10 } from "eslint-plugin-unused-imports";
|
|
19
|
-
import { default as default11 } from "eslint-plugin-vue";
|
|
20
|
-
import * as pluginYaml from "eslint-plugin-yml";
|
|
21
|
-
import { default as default12 } from "eslint-plugin-no-only-tests";
|
|
22
|
-
import { default as default13 } from "eslint-plugin-vitest";
|
|
23
|
-
import { default as default14 } from "eslint-plugin-perfectionist";
|
|
24
|
-
import * as parserTs from "@typescript-eslint/parser";
|
|
25
|
-
import { default as default15 } from "vue-eslint-parser";
|
|
26
|
-
import { default as default16 } from "yaml-eslint-parser";
|
|
27
|
-
import { default as default17 } from "jsonc-eslint-parser";
|
|
10
|
+
import { default as default4 } from "eslint-plugin-n";
|
|
11
|
+
import { default as default5 } from "eslint-plugin-unicorn";
|
|
12
|
+
import { default as default6 } from "eslint-plugin-unused-imports";
|
|
13
|
+
import { default as default7 } from "eslint-plugin-perfectionist";
|
|
28
14
|
|
|
29
15
|
// src/configs/comments.ts
|
|
30
|
-
function comments() {
|
|
16
|
+
async function comments() {
|
|
31
17
|
return [
|
|
32
18
|
{
|
|
33
19
|
name: "eslint:comments",
|
|
@@ -108,7 +94,7 @@ var GLOB_EXCLUDE = [
|
|
|
108
94
|
];
|
|
109
95
|
|
|
110
96
|
// src/configs/ignores.ts
|
|
111
|
-
function ignores(options = {}) {
|
|
97
|
+
async function ignores(options = {}) {
|
|
112
98
|
const {
|
|
113
99
|
ignores: ignores2 = []
|
|
114
100
|
} = options;
|
|
@@ -123,7 +109,7 @@ function ignores(options = {}) {
|
|
|
123
109
|
}
|
|
124
110
|
|
|
125
111
|
// src/configs/imports.ts
|
|
126
|
-
function imports(options = {}) {
|
|
112
|
+
async function imports(options = {}) {
|
|
127
113
|
const {
|
|
128
114
|
stylistic: stylistic2 = true
|
|
129
115
|
} = options;
|
|
@@ -154,7 +140,7 @@ function imports(options = {}) {
|
|
|
154
140
|
|
|
155
141
|
// src/configs/javascript.ts
|
|
156
142
|
import globals from "globals";
|
|
157
|
-
function javascript(options = {}) {
|
|
143
|
+
async function javascript(options = {}) {
|
|
158
144
|
const {
|
|
159
145
|
isInEditor = false,
|
|
160
146
|
overrides = {}
|
|
@@ -186,7 +172,7 @@ function javascript(options = {}) {
|
|
|
186
172
|
name: "eslint:javascript",
|
|
187
173
|
plugins: {
|
|
188
174
|
"antfu": default2,
|
|
189
|
-
"unused-imports":
|
|
175
|
+
"unused-imports": default6
|
|
190
176
|
},
|
|
191
177
|
rules: {
|
|
192
178
|
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
@@ -375,8 +361,30 @@ function javascript(options = {}) {
|
|
|
375
361
|
];
|
|
376
362
|
}
|
|
377
363
|
|
|
364
|
+
// src/utils.ts
|
|
365
|
+
async function combine(...configs) {
|
|
366
|
+
const resolved = await Promise.all(configs);
|
|
367
|
+
return resolved.flat();
|
|
368
|
+
}
|
|
369
|
+
function renameRules(rules, from, to) {
|
|
370
|
+
return Object.fromEntries(
|
|
371
|
+
Object.entries(rules).map(([key, value]) => {
|
|
372
|
+
if (key.startsWith(from))
|
|
373
|
+
return [to + key.slice(from.length), value];
|
|
374
|
+
return [key, value];
|
|
375
|
+
})
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
function toArray(value) {
|
|
379
|
+
return Array.isArray(value) ? value : [value];
|
|
380
|
+
}
|
|
381
|
+
async function interopDefault(m) {
|
|
382
|
+
const resolved = await m;
|
|
383
|
+
return resolved.default || resolved;
|
|
384
|
+
}
|
|
385
|
+
|
|
378
386
|
// src/configs/jsdoc.ts
|
|
379
|
-
function jsdoc(options = {}) {
|
|
387
|
+
async function jsdoc(options = {}) {
|
|
380
388
|
const {
|
|
381
389
|
stylistic: stylistic2 = true
|
|
382
390
|
} = options;
|
|
@@ -384,7 +392,8 @@ function jsdoc(options = {}) {
|
|
|
384
392
|
{
|
|
385
393
|
name: "eslint:jsdoc",
|
|
386
394
|
plugins: {
|
|
387
|
-
|
|
395
|
+
// @ts-expect-error missing types
|
|
396
|
+
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
388
397
|
},
|
|
389
398
|
rules: {
|
|
390
399
|
"jsdoc/check-access": "warn",
|
|
@@ -412,11 +421,18 @@ function jsdoc(options = {}) {
|
|
|
412
421
|
}
|
|
413
422
|
|
|
414
423
|
// src/configs/jsonc.ts
|
|
415
|
-
function jsonc(options = {}) {
|
|
424
|
+
async function jsonc(options = {}) {
|
|
416
425
|
const {
|
|
417
426
|
overrides = {},
|
|
418
427
|
stylistic: stylistic2 = true
|
|
419
428
|
} = options;
|
|
429
|
+
const [
|
|
430
|
+
pluginJsonc,
|
|
431
|
+
parserJsonc
|
|
432
|
+
] = await Promise.all([
|
|
433
|
+
interopDefault(import("eslint-plugin-jsonc")),
|
|
434
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
435
|
+
]);
|
|
420
436
|
return [
|
|
421
437
|
{
|
|
422
438
|
name: "eslint:jsonc:setup",
|
|
@@ -427,7 +443,7 @@ function jsonc(options = {}) {
|
|
|
427
443
|
{
|
|
428
444
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
429
445
|
languageOptions: {
|
|
430
|
-
parser:
|
|
446
|
+
parser: parserJsonc
|
|
431
447
|
},
|
|
432
448
|
name: "eslint:jsonc:rules",
|
|
433
449
|
rules: {
|
|
@@ -476,7 +492,7 @@ function jsonc(options = {}) {
|
|
|
476
492
|
}
|
|
477
493
|
|
|
478
494
|
// src/configs/markdown.ts
|
|
479
|
-
function markdown(options = {}) {
|
|
495
|
+
async function markdown(options = {}) {
|
|
480
496
|
const {
|
|
481
497
|
componentExts = [],
|
|
482
498
|
overrides = {}
|
|
@@ -485,7 +501,8 @@ function markdown(options = {}) {
|
|
|
485
501
|
{
|
|
486
502
|
name: "eslint:markdown:setup",
|
|
487
503
|
plugins: {
|
|
488
|
-
|
|
504
|
+
// @ts-expect-error missing types
|
|
505
|
+
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
489
506
|
}
|
|
490
507
|
},
|
|
491
508
|
{
|
|
@@ -557,12 +574,12 @@ function markdown(options = {}) {
|
|
|
557
574
|
}
|
|
558
575
|
|
|
559
576
|
// src/configs/node.ts
|
|
560
|
-
function node() {
|
|
577
|
+
async function node() {
|
|
561
578
|
return [
|
|
562
579
|
{
|
|
563
580
|
name: "eslint:node",
|
|
564
581
|
plugins: {
|
|
565
|
-
node:
|
|
582
|
+
node: default4
|
|
566
583
|
},
|
|
567
584
|
rules: {
|
|
568
585
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
@@ -579,7 +596,7 @@ function node() {
|
|
|
579
596
|
}
|
|
580
597
|
|
|
581
598
|
// src/configs/sort.ts
|
|
582
|
-
function sortPackageJson() {
|
|
599
|
+
async function sortPackageJson() {
|
|
583
600
|
return [
|
|
584
601
|
{
|
|
585
602
|
files: ["**/package.json"],
|
|
@@ -795,7 +812,7 @@ function sortTsconfig() {
|
|
|
795
812
|
}
|
|
796
813
|
|
|
797
814
|
// src/configs/stylistic.ts
|
|
798
|
-
function stylistic(options = {}) {
|
|
815
|
+
async function stylistic(options = {}) {
|
|
799
816
|
const {
|
|
800
817
|
overrides = {},
|
|
801
818
|
stylistic: stylistic2 = {}
|
|
@@ -805,12 +822,13 @@ function stylistic(options = {}) {
|
|
|
805
822
|
jsx = true,
|
|
806
823
|
quotes = "single"
|
|
807
824
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
825
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
808
826
|
return [
|
|
809
827
|
{
|
|
810
828
|
name: "eslint:stylistic",
|
|
811
829
|
plugins: {
|
|
812
830
|
antfu: default2,
|
|
813
|
-
style:
|
|
831
|
+
style: pluginStylistic
|
|
814
832
|
},
|
|
815
833
|
rules: {
|
|
816
834
|
"antfu/consistent-list-newline": "off",
|
|
@@ -853,6 +871,8 @@ function stylistic(options = {}) {
|
|
|
853
871
|
"JSXText",
|
|
854
872
|
"JSXEmptyExpression",
|
|
855
873
|
"JSXSpreadChild",
|
|
874
|
+
"TSUnionType",
|
|
875
|
+
"TSIntersectionType",
|
|
856
876
|
"TSTypeParameterInstantiation",
|
|
857
877
|
"FunctionExpression > .params[decorators.length > 0]",
|
|
858
878
|
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
@@ -957,26 +977,7 @@ function stylistic(options = {}) {
|
|
|
957
977
|
|
|
958
978
|
// src/configs/typescript.ts
|
|
959
979
|
import process from "process";
|
|
960
|
-
|
|
961
|
-
// src/utils.ts
|
|
962
|
-
function combine(...configs) {
|
|
963
|
-
return configs.flat();
|
|
964
|
-
}
|
|
965
|
-
function renameRules(rules, from, to) {
|
|
966
|
-
return Object.fromEntries(
|
|
967
|
-
Object.entries(rules).map(([key, value]) => {
|
|
968
|
-
if (key.startsWith(from))
|
|
969
|
-
return [to + key.slice(from.length), value];
|
|
970
|
-
return [key, value];
|
|
971
|
-
})
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
function toArray(value) {
|
|
975
|
-
return Array.isArray(value) ? value : [value];
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
// src/configs/typescript.ts
|
|
979
|
-
function typescript(options) {
|
|
980
|
+
async function typescript(options) {
|
|
980
981
|
const {
|
|
981
982
|
componentExts = [],
|
|
982
983
|
overrides = {},
|
|
@@ -1004,14 +1005,20 @@ function typescript(options) {
|
|
|
1004
1005
|
"ts/unbound-method": "error"
|
|
1005
1006
|
};
|
|
1006
1007
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1008
|
+
const [
|
|
1009
|
+
pluginTs,
|
|
1010
|
+
parserTs
|
|
1011
|
+
] = await Promise.all([
|
|
1012
|
+
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
1013
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
1014
|
+
]);
|
|
1007
1015
|
return [
|
|
1008
1016
|
{
|
|
1009
1017
|
// Install the plugins without globs, so they can be configured separately.
|
|
1010
1018
|
name: "eslint:typescript:setup",
|
|
1011
1019
|
plugins: {
|
|
1012
1020
|
antfu: default2,
|
|
1013
|
-
|
|
1014
|
-
ts: default8
|
|
1021
|
+
ts: pluginTs
|
|
1015
1022
|
}
|
|
1016
1023
|
},
|
|
1017
1024
|
{
|
|
@@ -1034,12 +1041,12 @@ function typescript(options) {
|
|
|
1034
1041
|
name: "eslint:typescript:rules",
|
|
1035
1042
|
rules: {
|
|
1036
1043
|
...renameRules(
|
|
1037
|
-
|
|
1044
|
+
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1038
1045
|
"@typescript-eslint/",
|
|
1039
1046
|
"ts/"
|
|
1040
1047
|
),
|
|
1041
1048
|
...renameRules(
|
|
1042
|
-
|
|
1049
|
+
pluginTs.configs.strict.rules,
|
|
1043
1050
|
"@typescript-eslint/",
|
|
1044
1051
|
"ts/"
|
|
1045
1052
|
),
|
|
@@ -1105,12 +1112,12 @@ function typescript(options) {
|
|
|
1105
1112
|
}
|
|
1106
1113
|
|
|
1107
1114
|
// src/configs/unicorn.ts
|
|
1108
|
-
function unicorn() {
|
|
1115
|
+
async function unicorn() {
|
|
1109
1116
|
return [
|
|
1110
1117
|
{
|
|
1111
1118
|
name: "eslint:unicorn",
|
|
1112
1119
|
plugins: {
|
|
1113
|
-
unicorn:
|
|
1120
|
+
unicorn: default5
|
|
1114
1121
|
},
|
|
1115
1122
|
rules: {
|
|
1116
1123
|
// Pass error message when throwing errors
|
|
@@ -1152,7 +1159,7 @@ var pkg = getPackageInfoSync("vue");
|
|
|
1152
1159
|
var vueVersion = pkg && pkg.version;
|
|
1153
1160
|
vueVersion = vueVersion && vueVersion[0];
|
|
1154
1161
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
1155
|
-
function vue(options = {}) {
|
|
1162
|
+
async function vue(options = {}) {
|
|
1156
1163
|
const {
|
|
1157
1164
|
overrides = {},
|
|
1158
1165
|
stylistic: stylistic2 = true
|
|
@@ -1160,38 +1167,46 @@ function vue(options = {}) {
|
|
|
1160
1167
|
const {
|
|
1161
1168
|
indent = 4
|
|
1162
1169
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1170
|
+
const [
|
|
1171
|
+
pluginVue,
|
|
1172
|
+
parserVue
|
|
1173
|
+
] = await Promise.all([
|
|
1174
|
+
// @ts-expect-error missing types
|
|
1175
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
1176
|
+
interopDefault(import("vue-eslint-parser"))
|
|
1177
|
+
]);
|
|
1163
1178
|
return [
|
|
1164
1179
|
{
|
|
1165
1180
|
name: "eslint:vue:setup",
|
|
1166
1181
|
plugins: {
|
|
1167
|
-
vue:
|
|
1182
|
+
vue: pluginVue
|
|
1168
1183
|
}
|
|
1169
1184
|
},
|
|
1170
1185
|
{
|
|
1171
1186
|
files: [GLOB_VUE],
|
|
1172
1187
|
languageOptions: {
|
|
1173
|
-
parser:
|
|
1188
|
+
parser: parserVue,
|
|
1174
1189
|
parserOptions: {
|
|
1175
1190
|
ecmaFeatures: {
|
|
1176
1191
|
jsx: true
|
|
1177
1192
|
},
|
|
1178
1193
|
extraFileExtensions: [".vue"],
|
|
1179
|
-
parser: options.typescript ?
|
|
1194
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1180
1195
|
sourceType: "module"
|
|
1181
1196
|
}
|
|
1182
1197
|
},
|
|
1183
1198
|
name: "eslint:vue:rules",
|
|
1184
|
-
processor:
|
|
1199
|
+
processor: pluginVue.processors[".vue"],
|
|
1185
1200
|
rules: {
|
|
1186
|
-
...
|
|
1201
|
+
...pluginVue.configs.base.rules,
|
|
1187
1202
|
...vueVersion === "3" ? {
|
|
1188
|
-
...
|
|
1189
|
-
...
|
|
1190
|
-
...
|
|
1203
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1204
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1205
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
1191
1206
|
} : {
|
|
1192
|
-
...
|
|
1193
|
-
...
|
|
1194
|
-
...
|
|
1207
|
+
...pluginVue.configs.essential.rules,
|
|
1208
|
+
...pluginVue.configs["strongly-recommended"].rules,
|
|
1209
|
+
...pluginVue.configs.recommended.rules
|
|
1195
1210
|
},
|
|
1196
1211
|
"node/prefer-global/process": "off",
|
|
1197
1212
|
"vue/block-order": ["error", {
|
|
@@ -1285,11 +1300,18 @@ function vue(options = {}) {
|
|
|
1285
1300
|
}
|
|
1286
1301
|
|
|
1287
1302
|
// src/configs/yaml.ts
|
|
1288
|
-
function yaml(options = {}) {
|
|
1303
|
+
async function yaml(options = {}) {
|
|
1289
1304
|
const {
|
|
1290
1305
|
overrides = {},
|
|
1291
1306
|
stylistic: stylistic2 = true
|
|
1292
1307
|
} = options;
|
|
1308
|
+
const [
|
|
1309
|
+
pluginYaml,
|
|
1310
|
+
parserYaml
|
|
1311
|
+
] = await Promise.all([
|
|
1312
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1313
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1314
|
+
]);
|
|
1293
1315
|
return [
|
|
1294
1316
|
{
|
|
1295
1317
|
name: "eslint:yaml:setup",
|
|
@@ -1300,7 +1322,7 @@ function yaml(options = {}) {
|
|
|
1300
1322
|
{
|
|
1301
1323
|
files: [GLOB_YAML],
|
|
1302
1324
|
languageOptions: {
|
|
1303
|
-
parser:
|
|
1325
|
+
parser: parserYaml
|
|
1304
1326
|
},
|
|
1305
1327
|
name: "eslint:yaml:rules",
|
|
1306
1328
|
rules: {
|
|
@@ -1332,21 +1354,29 @@ function yaml(options = {}) {
|
|
|
1332
1354
|
}
|
|
1333
1355
|
|
|
1334
1356
|
// src/configs/test.ts
|
|
1335
|
-
function test(options = {}) {
|
|
1357
|
+
async function test(options = {}) {
|
|
1336
1358
|
const {
|
|
1337
1359
|
isInEditor = false,
|
|
1338
1360
|
overrides = {}
|
|
1339
1361
|
} = options;
|
|
1362
|
+
const [
|
|
1363
|
+
pluginVitest,
|
|
1364
|
+
pluginNoOnlyTests
|
|
1365
|
+
] = await Promise.all([
|
|
1366
|
+
interopDefault(import("eslint-plugin-vitest")),
|
|
1367
|
+
// @ts-expect-error missing types
|
|
1368
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1369
|
+
]);
|
|
1340
1370
|
return [
|
|
1341
1371
|
{
|
|
1342
1372
|
name: "eslint:test:setup",
|
|
1343
1373
|
plugins: {
|
|
1344
1374
|
test: {
|
|
1345
|
-
...
|
|
1375
|
+
...pluginVitest,
|
|
1346
1376
|
rules: {
|
|
1347
|
-
...
|
|
1377
|
+
...pluginVitest.rules,
|
|
1348
1378
|
// extend `test/no-only-tests` rule
|
|
1349
|
-
...
|
|
1379
|
+
...pluginNoOnlyTests.rules
|
|
1350
1380
|
}
|
|
1351
1381
|
}
|
|
1352
1382
|
}
|
|
@@ -1368,12 +1398,92 @@ function test(options = {}) {
|
|
|
1368
1398
|
}
|
|
1369
1399
|
|
|
1370
1400
|
// src/configs/perfectionist.ts
|
|
1371
|
-
function perfectionist() {
|
|
1401
|
+
async function perfectionist() {
|
|
1372
1402
|
return [
|
|
1373
1403
|
{
|
|
1374
1404
|
name: "eslint:perfectionist",
|
|
1375
1405
|
plugins: {
|
|
1376
|
-
perfectionist:
|
|
1406
|
+
perfectionist: default7
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
];
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// src/configs/react.ts
|
|
1413
|
+
async function react(options = {}) {
|
|
1414
|
+
const {
|
|
1415
|
+
jsx = true,
|
|
1416
|
+
overrides = {},
|
|
1417
|
+
version = "17.0"
|
|
1418
|
+
} = options;
|
|
1419
|
+
const [
|
|
1420
|
+
pluginReact,
|
|
1421
|
+
pluginReactHooks
|
|
1422
|
+
] = await Promise.all([
|
|
1423
|
+
// @ts-expect-error missing types
|
|
1424
|
+
interopDefault(import("eslint-plugin-react")),
|
|
1425
|
+
// @ts-expect-error missing types
|
|
1426
|
+
interopDefault(import("eslint-plugin-react-hooks"))
|
|
1427
|
+
]);
|
|
1428
|
+
return [
|
|
1429
|
+
{
|
|
1430
|
+
name: "eslint:react:setup",
|
|
1431
|
+
plugins: {
|
|
1432
|
+
"react": pluginReact,
|
|
1433
|
+
"react-hooks": pluginReactHooks
|
|
1434
|
+
}
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
1438
|
+
languageOptions: {
|
|
1439
|
+
parserOptions: {
|
|
1440
|
+
ecmaFeatures: {
|
|
1441
|
+
jsx
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
name: "eslint:react:rules",
|
|
1446
|
+
rules: {
|
|
1447
|
+
...pluginReact.configs.all.rules,
|
|
1448
|
+
...pluginReactHooks.configs.recommended.rules,
|
|
1449
|
+
"react/forbid-component-props": "off",
|
|
1450
|
+
// 禁止组件上使用某些 props
|
|
1451
|
+
"react/hook-use-state": "off",
|
|
1452
|
+
// useState 钩子值和 setter 变量的解构和对称命名
|
|
1453
|
+
"react/jsx-filename-extension": "off",
|
|
1454
|
+
// 禁止可能包含 JSX 文件扩展名
|
|
1455
|
+
"react/jsx-max-depth": "off",
|
|
1456
|
+
// 强制 JSX 最大深度
|
|
1457
|
+
"react/jsx-no-bind": "off",
|
|
1458
|
+
// .bind()JSX 属性中禁止使用箭头函数
|
|
1459
|
+
"react/jsx-no-literals": "off",
|
|
1460
|
+
// 禁止在 JSX 中使用字符串文字
|
|
1461
|
+
"react/jsx-props-no-spreading": "off",
|
|
1462
|
+
// 强制任何 JSX 属性都不会传播
|
|
1463
|
+
"react/no-danger": "off",
|
|
1464
|
+
// 禁止使用 dangerouslySetInnerHTML
|
|
1465
|
+
"react/no-unsafe": "off",
|
|
1466
|
+
// 禁止使用不安全的生命周期方法
|
|
1467
|
+
"react/react-in-jsx-scope": "off",
|
|
1468
|
+
// 使用 JSX 时需要引入 React
|
|
1469
|
+
"react/require-default-props": "off",
|
|
1470
|
+
// 为每个非必需 prop 强制执行 defaultProps 定义
|
|
1471
|
+
"style/jsx-first-prop-new-line": "off",
|
|
1472
|
+
// 强制 JSX 中第一个属性的正确位置
|
|
1473
|
+
"style/jsx-max-props-per-line": ["error", { maximum: 4 }],
|
|
1474
|
+
// 在 JSX 中的单行上强制执行最多 props 数量
|
|
1475
|
+
"style/jsx-newline": "off",
|
|
1476
|
+
// 在 jsx 元素和表达式之后换行
|
|
1477
|
+
"style/jsx-one-expression-per-line": "off",
|
|
1478
|
+
// 每行一个 JSX 元素
|
|
1479
|
+
"style/jsx-quotes": ["error", "prefer-double"],
|
|
1480
|
+
// 强制在 JSX 属性中一致使用双引号或单引号
|
|
1481
|
+
...overrides
|
|
1482
|
+
},
|
|
1483
|
+
settings: {
|
|
1484
|
+
react: {
|
|
1485
|
+
version
|
|
1486
|
+
}
|
|
1377
1487
|
}
|
|
1378
1488
|
}
|
|
1379
1489
|
];
|
|
@@ -1396,25 +1506,34 @@ var VuePackages = [
|
|
|
1396
1506
|
"vitepress",
|
|
1397
1507
|
"@slidev/cli"
|
|
1398
1508
|
];
|
|
1399
|
-
|
|
1509
|
+
var ReactPackages = [
|
|
1510
|
+
"react",
|
|
1511
|
+
"next"
|
|
1512
|
+
];
|
|
1513
|
+
async function lincy(options = {}, ...userConfigs) {
|
|
1400
1514
|
const {
|
|
1401
1515
|
componentExts = [],
|
|
1402
1516
|
gitignore: enableGitignore = true,
|
|
1403
1517
|
isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI),
|
|
1404
1518
|
overrides = {},
|
|
1519
|
+
react: enableReact = ReactPackages.some((i) => isPackageExists(i)),
|
|
1405
1520
|
typescript: enableTypeScript = isPackageExists("typescript"),
|
|
1406
1521
|
vue: enableVue = VuePackages.some((i) => isPackageExists(i))
|
|
1407
1522
|
} = options;
|
|
1408
1523
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1409
|
-
if (stylisticOptions
|
|
1410
|
-
|
|
1524
|
+
if (stylisticOptions) {
|
|
1525
|
+
if (!("jsx" in stylisticOptions))
|
|
1526
|
+
stylisticOptions.jsx = options.jsx ?? true;
|
|
1527
|
+
if (enableReact)
|
|
1528
|
+
stylisticOptions.jsx = false;
|
|
1529
|
+
}
|
|
1411
1530
|
const configs = [];
|
|
1412
1531
|
if (enableGitignore) {
|
|
1413
1532
|
if (typeof enableGitignore !== "boolean") {
|
|
1414
|
-
configs.push(
|
|
1533
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1415
1534
|
} else {
|
|
1416
1535
|
if (fs.existsSync(".gitignore"))
|
|
1417
|
-
configs.push(
|
|
1536
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1418
1537
|
}
|
|
1419
1538
|
}
|
|
1420
1539
|
configs.push(
|
|
@@ -1465,6 +1584,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1465
1584
|
typescript: !!enableTypeScript
|
|
1466
1585
|
}));
|
|
1467
1586
|
}
|
|
1587
|
+
if (enableReact) {
|
|
1588
|
+
configs.push(react({
|
|
1589
|
+
overrides: overrides.react,
|
|
1590
|
+
...typeof enableReact !== "boolean" ? enableReact : {}
|
|
1591
|
+
}));
|
|
1592
|
+
}
|
|
1468
1593
|
if (options.jsonc ?? true) {
|
|
1469
1594
|
configs.push(
|
|
1470
1595
|
jsonc({
|
|
@@ -1530,33 +1655,15 @@ export {
|
|
|
1530
1655
|
src_default as default,
|
|
1531
1656
|
ignores,
|
|
1532
1657
|
imports,
|
|
1658
|
+
interopDefault,
|
|
1533
1659
|
javascript,
|
|
1534
1660
|
jsdoc,
|
|
1535
1661
|
jsonc,
|
|
1536
1662
|
lincy,
|
|
1537
1663
|
markdown,
|
|
1538
1664
|
node,
|
|
1539
|
-
default17 as parserJsonc,
|
|
1540
|
-
parserTs,
|
|
1541
|
-
default15 as parserVue,
|
|
1542
|
-
default16 as parserYaml,
|
|
1543
1665
|
perfectionist,
|
|
1544
|
-
|
|
1545
|
-
default3 as pluginComments,
|
|
1546
|
-
pluginImport,
|
|
1547
|
-
default4 as pluginJsdoc,
|
|
1548
|
-
pluginJsonc,
|
|
1549
|
-
default5 as pluginMarkdown,
|
|
1550
|
-
default12 as pluginNoOnlyTests,
|
|
1551
|
-
default6 as pluginNode,
|
|
1552
|
-
default14 as pluginPerfectionist,
|
|
1553
|
-
default7 as pluginStylistic,
|
|
1554
|
-
default8 as pluginTs,
|
|
1555
|
-
default9 as pluginUnicorn,
|
|
1556
|
-
default10 as pluginUnusedImports,
|
|
1557
|
-
default13 as pluginVitest,
|
|
1558
|
-
default11 as pluginVue,
|
|
1559
|
-
pluginYaml,
|
|
1666
|
+
react,
|
|
1560
1667
|
renameRules,
|
|
1561
1668
|
sortPackageJson,
|
|
1562
1669
|
sortTsconfig,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.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/)",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
43
|
-
"@stylistic/eslint-plugin": "1.
|
|
43
|
+
"@stylistic/eslint-plugin": "1.4.0",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
45
45
|
"@typescript-eslint/parser": "^6.11.0",
|
|
46
46
|
"eslint-config-flat-gitignore": "^0.1.1",
|
|
47
|
-
"eslint-plugin-antfu": "^1.0.
|
|
47
|
+
"eslint-plugin-antfu": "^1.0.10",
|
|
48
48
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
49
49
|
"eslint-plugin-i": "^2.29.0",
|
|
50
50
|
"eslint-plugin-jsdoc": "^46.9.0",
|
|
@@ -52,10 +52,12 @@
|
|
|
52
52
|
"eslint-plugin-markdown": "^3.0.1",
|
|
53
53
|
"eslint-plugin-n": "^16.3.1",
|
|
54
54
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
55
|
-
"eslint-plugin-perfectionist": "^2.
|
|
55
|
+
"eslint-plugin-perfectionist": "^2.4.0",
|
|
56
|
+
"eslint-plugin-react": "^7.33.2",
|
|
57
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
56
58
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
57
59
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
58
|
-
"eslint-plugin-vitest": "^0.3.
|
|
60
|
+
"eslint-plugin-vitest": "^0.3.10",
|
|
59
61
|
"eslint-plugin-vue": "^9.18.1",
|
|
60
62
|
"eslint-plugin-yml": "^1.10.0",
|
|
61
63
|
"globals": "^13.23.0",
|
|
@@ -66,23 +68,23 @@
|
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@antfu/ni": "^0.21.9",
|
|
69
|
-
"@eslint-types/jsdoc": "46.
|
|
70
|
-
"@eslint-types/typescript-eslint": "^6.
|
|
71
|
+
"@eslint-types/jsdoc": "46.9.0",
|
|
72
|
+
"@eslint-types/typescript-eslint": "^6.11.0",
|
|
71
73
|
"@eslint-types/unicorn": "^49.0.0",
|
|
72
74
|
"@lincy/eslint-config": "workspace:*",
|
|
73
|
-
"@stylistic/eslint-plugin-migrate": "^1.
|
|
75
|
+
"@stylistic/eslint-plugin-migrate": "^1.4.0",
|
|
74
76
|
"@types/eslint": "^8.44.7",
|
|
75
|
-
"@types/node": "^20.9.
|
|
77
|
+
"@types/node": "^20.9.2",
|
|
76
78
|
"bumpp": "^9.2.0",
|
|
77
|
-
"eslint": "^8.
|
|
78
|
-
"eslint-flat-config-viewer": "^0.1.
|
|
79
|
+
"eslint": "^8.54.0",
|
|
80
|
+
"eslint-flat-config-viewer": "^0.1.3",
|
|
79
81
|
"esno": "^4.0.0",
|
|
80
82
|
"lint-staged": "^15.1.0",
|
|
81
83
|
"rimraf": "^5.0.5",
|
|
82
84
|
"simple-git-hooks": "^2.9.0",
|
|
83
85
|
"simple-open-url": "^3.0.1",
|
|
84
86
|
"sucrase": "^3.34.0",
|
|
85
|
-
"tsup": "^
|
|
87
|
+
"tsup": "^8.0.0",
|
|
86
88
|
"typescript": "^5.2.2",
|
|
87
89
|
"unbuild": "^2.0.0",
|
|
88
90
|
"vitest": "^0.34.6"
|