@lincy/eslint-config 6.4.0 → 6.5.1

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 CHANGED
@@ -107,7 +107,7 @@ export default lincy()
107
107
 
108
108
  通常你只需要导入 `lincy` 预设:
109
109
 
110
- #### esm
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
- #### cjs
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 __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);
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": __eslint_community_eslint_plugin_eslint_comments.default },
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: pluginJsonc }
798
+ plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
799
799
  }, {
800
800
  files,
801
- languageOptions: { parser: parserJsonc },
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
- languageOptions: { parser: eslint_parser_plain },
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",
@@ -1050,45 +1074,48 @@ async function detectCatalogUsage() {
1050
1074
  const yaml$1 = await node_fs_promises.default.readFile(workspaceFile, "utf-8");
1051
1075
  return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
1052
1076
  }
1053
- async function pnpm(options = {}) {
1054
- const { catalogs = await detectCatalogUsage(), isInEditor = false } = options;
1055
- const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
1077
+ async function pnpm(options) {
1078
+ const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
1056
1079
  interopDefault(import("eslint-plugin-pnpm")),
1057
- interopDefault(import("yaml-eslint-parser")),
1058
- interopDefault(import("jsonc-eslint-parser"))
1080
+ interopDefault(import("eslint-plugin-yml")),
1081
+ interopDefault(import("yaml-eslint-parser"))
1059
1082
  ]);
1060
- return [
1061
- {
1062
- files: ["package.json", "**/package.json"],
1063
- languageOptions: { parser: jsoncParser },
1064
- name: "eslint/pnpm/package-json",
1065
- plugins: { pnpm: pluginPnpm },
1066
- rules: {
1067
- ...catalogs ? { "pnpm/json-enforce-catalog": ["error", {
1068
- autofix: !isInEditor,
1069
- ignores: ["@types/vscode"]
1070
- }] } : {},
1071
- "pnpm/json-prefer-workspace-settings": ["error", { autofix: isInEditor }],
1072
- "pnpm/json-valid-catalog": ["error", { autofix: isInEditor }]
1073
- }
1074
- },
1075
- {
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({
1076
1101
  files: ["pnpm-workspace.yaml"],
1077
1102
  languageOptions: { parser: yamlParser },
1078
1103
  name: "eslint/pnpm/pnpm-workspace-yaml",
1079
1104
  plugins: { pnpm: pluginPnpm },
1080
1105
  rules: {
1081
1106
  "pnpm/yaml-enforce-settings": ["error", { settings: {
1082
- catalogMode: "prefer",
1083
- shellEmulator: true
1107
+ shellEmulator: true,
1108
+ trustPolicy: "no-downgrade"
1084
1109
  } }],
1085
1110
  "pnpm/yaml-no-duplicate-catalog-item": "error",
1086
1111
  "pnpm/yaml-no-unused-catalog-item": "error"
1087
1112
  }
1088
- },
1089
- {
1113
+ });
1114
+ if (sort) configs$1.push({
1090
1115
  files: ["pnpm-workspace.yaml"],
1091
- name: "eslint/yaml/pnpm-workspace",
1116
+ languageOptions: { parser: yamlParser },
1117
+ name: "eslint/pnpm/pnpm-workspace-yaml-sort",
1118
+ plugins: { yaml: pluginYaml },
1092
1119
  rules: { "yaml/sort-keys": [
1093
1120
  "error",
1094
1121
  {
@@ -1161,8 +1188,9 @@ async function pnpm(options = {}) {
1161
1188
  pathPattern: ".*"
1162
1189
  }
1163
1190
  ] }
1164
- }
1165
- ];
1191
+ });
1192
+ }
1193
+ return configs$1;
1166
1194
  }
1167
1195
 
1168
1196
  //#endregion
@@ -1190,7 +1218,10 @@ async function react(options = {}) {
1190
1218
  "eslint-plugin-react-refresh"
1191
1219
  ]);
1192
1220
  const isTypeAware = !!tsconfigPath;
1193
- const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
1221
+ const typeAwareRules = {
1222
+ "react/no-implicit-key": "error",
1223
+ "react/no-leaked-conditional-rendering": "warn"
1224
+ };
1194
1225
  const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1195
1226
  interopDefault(import("@eslint-react/eslint-plugin")),
1196
1227
  interopDefault(import("eslint-plugin-react-hooks")),
@@ -1211,6 +1242,7 @@ async function react(options = {}) {
1211
1242
  "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1212
1243
  "react-naming-convention": plugins["@eslint-react/naming-convention"],
1213
1244
  "react-refresh": pluginReactRefresh,
1245
+ "react-rsc": plugins["@eslint-react/rsc"],
1214
1246
  "react-web-api": plugins["@eslint-react/web-api"]
1215
1247
  }
1216
1248
  },
@@ -1234,8 +1266,17 @@ async function react(options = {}) {
1234
1266
  "react-dom/no-unsafe-iframe-sandbox": "warn",
1235
1267
  "react-dom/no-use-form-state": "error",
1236
1268
  "react-dom/no-void-elements-with-children": "error",
1269
+ "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1237
1270
  "react-hooks/exhaustive-deps": "warn",
1238
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",
1239
1280
  "react/jsx-key-before-spread": "warn",
1240
1281
  "react/jsx-no-comment-textnodes": "warn",
1241
1282
  "react/jsx-no-duplicate-props": "warn",
@@ -1256,9 +1297,7 @@ async function react(options = {}) {
1256
1297
  "react/no-create-ref": "error",
1257
1298
  "react/no-default-props": "error",
1258
1299
  "react/no-direct-mutation-state": "error",
1259
- "react/no-duplicate-key": "error",
1260
1300
  "react/no-forward-ref": "warn",
1261
- "react/no-implicit-key": "warn",
1262
1301
  "react/no-missing-key": "error",
1263
1302
  "react/no-nested-component-definitions": "error",
1264
1303
  "react/no-nested-lazy-component-declarations": "error",
@@ -1272,6 +1311,7 @@ async function react(options = {}) {
1272
1311
  "react/no-unsafe-component-will-mount": "warn",
1273
1312
  "react/no-unsafe-component-will-receive-props": "warn",
1274
1313
  "react/no-unsafe-component-will-update": "warn",
1314
+ "react/no-unused-class-component-members": "warn",
1275
1315
  "react/no-use-context": "warn",
1276
1316
  "react/no-useless-forward-ref": "warn",
1277
1317
  "react/prefer-namespace-import": "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-hooks-extra/no-direct-set-state-in-use-effect": "warn",
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" ? 4 : indent],
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",