@lincy/eslint-config 6.3.3 → 6.5.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 +2 -2
- package/dist/index.cjs +115 -67
- package/dist/index.d.cts +1615 -691
- package/dist/index.d.mts +1615 -691
- package/dist/index.mjs +112 -63
- package/package.json +44 -44
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ export default lincy()
|
|
|
107
107
|
|
|
108
108
|
通常你只需要导入 `lincy` 预设:
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
### esm
|
|
111
111
|
|
|
112
112
|
如果 package.json 中开启了`"type": "module",`
|
|
113
113
|
|
|
@@ -121,7 +121,7 @@ import lincy from '@lincy/eslint-config'
|
|
|
121
121
|
export default lincy()
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
### cjs
|
|
125
125
|
|
|
126
126
|
如果 package.json 中没有开启`"type": "module",`
|
|
127
127
|
|
package/dist/index.cjs
CHANGED
|
@@ -37,8 +37,8 @@ node_fs = __toESM(node_fs);
|
|
|
37
37
|
let node_path = require("node:path");
|
|
38
38
|
node_path = __toESM(node_path);
|
|
39
39
|
let local_pkg = require("local-pkg");
|
|
40
|
-
let
|
|
41
|
-
|
|
40
|
+
let _eslint_community_eslint_plugin_eslint_comments = require("@eslint-community/eslint-plugin-eslint-comments");
|
|
41
|
+
_eslint_community_eslint_plugin_eslint_comments = __toESM(_eslint_community_eslint_plugin_eslint_comments);
|
|
42
42
|
let eslint_plugin_antfu = require("eslint-plugin-antfu");
|
|
43
43
|
eslint_plugin_antfu = __toESM(eslint_plugin_antfu);
|
|
44
44
|
let eslint_plugin_import_lite = require("eslint-plugin-import-lite");
|
|
@@ -54,8 +54,6 @@ eslint_plugin_unused_imports = __toESM(eslint_plugin_unused_imports);
|
|
|
54
54
|
let globals = require("globals");
|
|
55
55
|
globals = __toESM(globals);
|
|
56
56
|
let eslint_merge_processors = require("eslint-merge-processors");
|
|
57
|
-
let eslint_parser_plain = require("eslint-parser-plain");
|
|
58
|
-
eslint_parser_plain = __toESM(eslint_parser_plain);
|
|
59
57
|
let eslint_plugin_regexp = require("eslint-plugin-regexp");
|
|
60
58
|
|
|
61
59
|
//#region node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
@@ -97,7 +95,7 @@ async function comments(options = {}) {
|
|
|
97
95
|
const { overrides = {} } = options;
|
|
98
96
|
return [{
|
|
99
97
|
name: "eslint/comments/rules",
|
|
100
|
-
plugins: { "eslint-comments":
|
|
98
|
+
plugins: { "eslint-comments": _eslint_community_eslint_plugin_eslint_comments.default },
|
|
101
99
|
rules: {
|
|
102
100
|
"eslint-comments/no-aggregating-enable": "error",
|
|
103
101
|
"eslint-comments/no-duplicate-disable": "error",
|
|
@@ -364,7 +362,7 @@ async function stylistic(options = {}) {
|
|
|
364
362
|
|
|
365
363
|
//#endregion
|
|
366
364
|
//#region src/configs/formatters.ts
|
|
367
|
-
function mergePrettierOptions(options, overrides
|
|
365
|
+
function mergePrettierOptions(options, overrides) {
|
|
368
366
|
return {
|
|
369
367
|
...options,
|
|
370
368
|
...overrides,
|
|
@@ -757,8 +755,11 @@ async function javascript(options = {}) {
|
|
|
757
755
|
async function jsdoc(options = {}) {
|
|
758
756
|
const { overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
759
757
|
return [{
|
|
758
|
+
name: "eslint/jsdoc/setup",
|
|
759
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
|
|
760
|
+
}, {
|
|
761
|
+
files: [GLOB_SRC],
|
|
760
762
|
name: "eslint/jsdoc/rules",
|
|
761
|
-
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
762
763
|
rules: {
|
|
763
764
|
"jsdoc/check-access": "warn",
|
|
764
765
|
"jsdoc/check-param-names": "warn",
|
|
@@ -792,13 +793,12 @@ async function jsonc(options = {}) {
|
|
|
792
793
|
GLOB_JSON5,
|
|
793
794
|
GLOB_JSONC
|
|
794
795
|
], overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
795
|
-
const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
796
796
|
return [{
|
|
797
797
|
name: "eslint/jsonc/setup",
|
|
798
|
-
plugins: { jsonc:
|
|
798
|
+
plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
|
|
799
799
|
}, {
|
|
800
800
|
files,
|
|
801
|
-
|
|
801
|
+
language: "jsonc/x",
|
|
802
802
|
name: "eslint/jsonc/rules",
|
|
803
803
|
rules: {
|
|
804
804
|
"jsonc/no-bigint-literals": "error",
|
|
@@ -863,7 +863,7 @@ async function jsx() {
|
|
|
863
863
|
//#endregion
|
|
864
864
|
//#region src/configs/markdown.ts
|
|
865
865
|
async function markdown(options = {}) {
|
|
866
|
-
const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
|
|
866
|
+
const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
|
|
867
867
|
const markdown$1 = await interopDefault(import("@eslint/markdown"));
|
|
868
868
|
return [
|
|
869
869
|
{
|
|
@@ -878,13 +878,37 @@ async function markdown(options = {}) {
|
|
|
878
878
|
},
|
|
879
879
|
{
|
|
880
880
|
files,
|
|
881
|
-
|
|
881
|
+
language: gfm ? "markdown/gfm" : "markdown/commonmark",
|
|
882
882
|
name: "eslint/markdown/parser"
|
|
883
883
|
},
|
|
884
|
+
{
|
|
885
|
+
files,
|
|
886
|
+
name: "eslint/markdown/rules",
|
|
887
|
+
rules: {
|
|
888
|
+
...markdown$1.configs.recommended.at(0)?.rules,
|
|
889
|
+
"markdown/no-missing-label-refs": "off",
|
|
890
|
+
...overridesMarkdown
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
files,
|
|
895
|
+
name: "eslint/markdown/disables/markdown",
|
|
896
|
+
rules: {
|
|
897
|
+
"command/command": "off",
|
|
898
|
+
"no-irregular-whitespace": "off",
|
|
899
|
+
"perfectionist/sort-exports": "off",
|
|
900
|
+
"perfectionist/sort-imports": "off",
|
|
901
|
+
"regexp/no-legacy-features": "off",
|
|
902
|
+
"regexp/no-missing-g-flag": "off",
|
|
903
|
+
"regexp/no-useless-dollar-replacements": "off",
|
|
904
|
+
"regexp/no-useless-flag": "off",
|
|
905
|
+
"style/indent": "off"
|
|
906
|
+
}
|
|
907
|
+
},
|
|
884
908
|
{
|
|
885
909
|
files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
|
|
886
910
|
languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
|
|
887
|
-
name: "eslint/markdown/disables",
|
|
911
|
+
name: "eslint/markdown/disables/code",
|
|
888
912
|
rules: {
|
|
889
913
|
"antfu/no-top-level-await": "off",
|
|
890
914
|
"import/newline-after-import": "off",
|
|
@@ -1005,28 +1029,27 @@ async function perfectionist(options = {}) {
|
|
|
1005
1029
|
}],
|
|
1006
1030
|
"perfectionist/sort-imports": ["error", {
|
|
1007
1031
|
groups: [
|
|
1008
|
-
"type",
|
|
1009
|
-
"builtin-type",
|
|
1032
|
+
"type-import",
|
|
1010
1033
|
[
|
|
1011
|
-
"
|
|
1012
|
-
"
|
|
1013
|
-
"
|
|
1014
|
-
"internal
|
|
1034
|
+
"type-parent",
|
|
1035
|
+
"type-sibling",
|
|
1036
|
+
"type-index",
|
|
1037
|
+
"type-internal"
|
|
1015
1038
|
],
|
|
1016
|
-
"builtin",
|
|
1017
|
-
"external",
|
|
1018
|
-
"internal",
|
|
1039
|
+
"value-builtin",
|
|
1040
|
+
"value-external",
|
|
1041
|
+
"value-internal",
|
|
1019
1042
|
[
|
|
1020
|
-
"
|
|
1021
|
-
"
|
|
1022
|
-
"
|
|
1043
|
+
"value-parent",
|
|
1044
|
+
"value-sibling",
|
|
1045
|
+
"value-index"
|
|
1023
1046
|
],
|
|
1024
1047
|
"side-effect",
|
|
1025
|
-
"
|
|
1048
|
+
"ts-equals-import",
|
|
1026
1049
|
"unknown"
|
|
1027
1050
|
],
|
|
1028
|
-
internalPattern: ["^~/.*", "^@/.*"],
|
|
1029
1051
|
newlinesBetween: "ignore",
|
|
1052
|
+
newlinesInside: "ignore",
|
|
1030
1053
|
order: "asc",
|
|
1031
1054
|
type: "natural"
|
|
1032
1055
|
}],
|
|
@@ -1051,45 +1074,48 @@ async function detectCatalogUsage() {
|
|
|
1051
1074
|
const yaml$1 = await node_fs_promises.default.readFile(workspaceFile, "utf-8");
|
|
1052
1075
|
return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
|
|
1053
1076
|
}
|
|
1054
|
-
async function pnpm(options
|
|
1055
|
-
const
|
|
1056
|
-
const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
|
|
1077
|
+
async function pnpm(options) {
|
|
1078
|
+
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
1057
1079
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1058
|
-
interopDefault(import("
|
|
1059
|
-
interopDefault(import("
|
|
1080
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1081
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1060
1082
|
]);
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1083
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml: yaml$1 = true } = options;
|
|
1084
|
+
const configs$1 = [];
|
|
1085
|
+
if (json) configs$1.push({
|
|
1086
|
+
files: ["package.json", "**/package.json"],
|
|
1087
|
+
language: "jsonc/x",
|
|
1088
|
+
name: "eslint/pnpm/package-json",
|
|
1089
|
+
plugins: { pnpm: pluginPnpm },
|
|
1090
|
+
rules: {
|
|
1091
|
+
...catalogs ? { "pnpm/json-enforce-catalog": ["error", {
|
|
1092
|
+
autofix: !isInEditor,
|
|
1093
|
+
ignores: ["@types/vscode"]
|
|
1094
|
+
}] } : {},
|
|
1095
|
+
"pnpm/json-prefer-workspace-settings": ["error", { autofix: !isInEditor }],
|
|
1096
|
+
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
if (yaml$1) {
|
|
1100
|
+
configs$1.push({
|
|
1077
1101
|
files: ["pnpm-workspace.yaml"],
|
|
1078
1102
|
languageOptions: { parser: yamlParser },
|
|
1079
1103
|
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
1080
1104
|
plugins: { pnpm: pluginPnpm },
|
|
1081
1105
|
rules: {
|
|
1082
1106
|
"pnpm/yaml-enforce-settings": ["error", { settings: {
|
|
1083
|
-
|
|
1084
|
-
|
|
1107
|
+
shellEmulator: true,
|
|
1108
|
+
trustPolicy: "no-downgrade"
|
|
1085
1109
|
} }],
|
|
1086
1110
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1087
1111
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1088
1112
|
}
|
|
1089
|
-
}
|
|
1090
|
-
{
|
|
1113
|
+
});
|
|
1114
|
+
if (sort) configs$1.push({
|
|
1091
1115
|
files: ["pnpm-workspace.yaml"],
|
|
1092
|
-
|
|
1116
|
+
languageOptions: { parser: yamlParser },
|
|
1117
|
+
name: "eslint/pnpm/pnpm-workspace-yaml-sort",
|
|
1118
|
+
plugins: { yaml: pluginYaml },
|
|
1093
1119
|
rules: { "yaml/sort-keys": [
|
|
1094
1120
|
"error",
|
|
1095
1121
|
{
|
|
@@ -1162,8 +1188,9 @@ async function pnpm(options = {}) {
|
|
|
1162
1188
|
pathPattern: ".*"
|
|
1163
1189
|
}
|
|
1164
1190
|
] }
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
return configs$1;
|
|
1167
1194
|
}
|
|
1168
1195
|
|
|
1169
1196
|
//#endregion
|
|
@@ -1191,7 +1218,10 @@ async function react(options = {}) {
|
|
|
1191
1218
|
"eslint-plugin-react-refresh"
|
|
1192
1219
|
]);
|
|
1193
1220
|
const isTypeAware = !!tsconfigPath;
|
|
1194
|
-
const typeAwareRules = {
|
|
1221
|
+
const typeAwareRules = {
|
|
1222
|
+
"react/no-implicit-key": "error",
|
|
1223
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1224
|
+
};
|
|
1195
1225
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1196
1226
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1197
1227
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
@@ -1212,6 +1242,7 @@ async function react(options = {}) {
|
|
|
1212
1242
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1213
1243
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1214
1244
|
"react-refresh": pluginReactRefresh,
|
|
1245
|
+
"react-rsc": plugins["@eslint-react/rsc"],
|
|
1215
1246
|
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1216
1247
|
}
|
|
1217
1248
|
},
|
|
@@ -1235,8 +1266,17 @@ async function react(options = {}) {
|
|
|
1235
1266
|
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1236
1267
|
"react-dom/no-use-form-state": "error",
|
|
1237
1268
|
"react-dom/no-void-elements-with-children": "error",
|
|
1269
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1238
1270
|
"react-hooks/exhaustive-deps": "warn",
|
|
1239
1271
|
"react-hooks/rules-of-hooks": "error",
|
|
1272
|
+
"react-naming-convention/context-name": "warn",
|
|
1273
|
+
"react-naming-convention/ref-name": "warn",
|
|
1274
|
+
"react-naming-convention/use-state": "warn",
|
|
1275
|
+
"react-rsc/function-definition": "error",
|
|
1276
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
1277
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
1278
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1279
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
1240
1280
|
"react/jsx-key-before-spread": "warn",
|
|
1241
1281
|
"react/jsx-no-comment-textnodes": "warn",
|
|
1242
1282
|
"react/jsx-no-duplicate-props": "warn",
|
|
@@ -1257,9 +1297,7 @@ async function react(options = {}) {
|
|
|
1257
1297
|
"react/no-create-ref": "error",
|
|
1258
1298
|
"react/no-default-props": "error",
|
|
1259
1299
|
"react/no-direct-mutation-state": "error",
|
|
1260
|
-
"react/no-duplicate-key": "error",
|
|
1261
1300
|
"react/no-forward-ref": "warn",
|
|
1262
|
-
"react/no-implicit-key": "warn",
|
|
1263
1301
|
"react/no-missing-key": "error",
|
|
1264
1302
|
"react/no-nested-component-definitions": "error",
|
|
1265
1303
|
"react/no-nested-lazy-component-declarations": "error",
|
|
@@ -1273,8 +1311,10 @@ async function react(options = {}) {
|
|
|
1273
1311
|
"react/no-unsafe-component-will-mount": "warn",
|
|
1274
1312
|
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1275
1313
|
"react/no-unsafe-component-will-update": "warn",
|
|
1314
|
+
"react/no-unused-class-component-members": "warn",
|
|
1276
1315
|
"react/no-use-context": "warn",
|
|
1277
1316
|
"react/no-useless-forward-ref": "warn",
|
|
1317
|
+
"react/prefer-namespace-import": "error",
|
|
1278
1318
|
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1279
1319
|
...reactCompiler ? {
|
|
1280
1320
|
"react-hooks/component-hook-factories": "error",
|
|
@@ -1293,8 +1333,7 @@ async function react(options = {}) {
|
|
|
1293
1333
|
"react-hooks/unsupported-syntax": "warn",
|
|
1294
1334
|
"react-hooks/use-memo": "error"
|
|
1295
1335
|
} : {},
|
|
1296
|
-
"react-
|
|
1297
|
-
"react-refresh/only-export-components": ["warn", {
|
|
1336
|
+
"react-refresh/only-export-components": ["error", {
|
|
1298
1337
|
allowConstantExport: isAllowConstantExport,
|
|
1299
1338
|
allowExportNames: [...isUsingNext ? [
|
|
1300
1339
|
"dynamic",
|
|
@@ -1304,12 +1343,13 @@ async function react(options = {}) {
|
|
|
1304
1343
|
"runtime",
|
|
1305
1344
|
"preferredRegion",
|
|
1306
1345
|
"maxDuration",
|
|
1307
|
-
"config",
|
|
1308
1346
|
"generateStaticParams",
|
|
1309
1347
|
"metadata",
|
|
1310
1348
|
"generateMetadata",
|
|
1311
1349
|
"viewport",
|
|
1312
|
-
"generateViewport"
|
|
1350
|
+
"generateViewport",
|
|
1351
|
+
"generateImageMetadata",
|
|
1352
|
+
"generateSitemaps"
|
|
1313
1353
|
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1314
1354
|
"meta",
|
|
1315
1355
|
"links",
|
|
@@ -1322,13 +1362,21 @@ async function react(options = {}) {
|
|
|
1322
1362
|
"shouldRevalidate"
|
|
1323
1363
|
] : []]
|
|
1324
1364
|
}],
|
|
1325
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1326
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1327
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1328
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1329
1365
|
...overrides
|
|
1330
1366
|
}
|
|
1331
1367
|
},
|
|
1368
|
+
{
|
|
1369
|
+
files: filesTypeAware,
|
|
1370
|
+
name: "eslint/react/typescript",
|
|
1371
|
+
rules: {
|
|
1372
|
+
"react-dom/no-string-style-prop": "off",
|
|
1373
|
+
"react-dom/no-unknown-property": "off",
|
|
1374
|
+
"react/jsx-no-duplicate-props": "off",
|
|
1375
|
+
"react/jsx-no-undef": "off",
|
|
1376
|
+
"react/jsx-uses-react": "off",
|
|
1377
|
+
"react/jsx-uses-vars": "off"
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1332
1380
|
...isTypeAware ? [{
|
|
1333
1381
|
files: filesTypeAware,
|
|
1334
1382
|
ignores: ignoresTypeAware,
|
|
@@ -1652,7 +1700,7 @@ async function toml(options = {}) {
|
|
|
1652
1700
|
"toml/array-bracket-newline": "error",
|
|
1653
1701
|
"toml/array-bracket-spacing": "error",
|
|
1654
1702
|
"toml/array-element-newline": "error",
|
|
1655
|
-
"toml/indent": ["error", indent === "tab" ?
|
|
1703
|
+
"toml/indent": ["error", typeof indent === "number" ? indent : indent === "tab" ? "tab" : 4],
|
|
1656
1704
|
"toml/inline-table-curly-spacing": "error",
|
|
1657
1705
|
"toml/key-spacing": "error",
|
|
1658
1706
|
"toml/padding-line-between-pairs": "error",
|