@lincy/eslint-config 5.8.1 → 6.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.
@@ -0,0 +1,39 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+
28
+ Object.defineProperty(exports, '__commonJS', {
29
+ enumerable: true,
30
+ get: function () {
31
+ return __commonJS;
32
+ }
33
+ });
34
+ Object.defineProperty(exports, '__toESM', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return __toESM;
38
+ }
39
+ });
package/dist/index.cjs CHANGED
@@ -1,42 +1,35 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- //#region rolldown:runtime
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
-
24
- //#endregion
25
- const eslint_flat_config_utils = __toESM(require("eslint-flat-config-utils"));
26
- const local_pkg = __toESM(require("local-pkg"));
27
- const __eslint_community_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"));
28
- const eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"));
29
- const eslint_plugin_import_lite = __toESM(require("eslint-plugin-import-lite"));
30
- const eslint_plugin_n = __toESM(require("eslint-plugin-n"));
31
- const eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"));
32
- const eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"));
33
- const eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"));
34
- const node_process = __toESM(require("node:process"));
35
- const node_url = __toESM(require("node:url"));
36
- const globals = __toESM(require("globals"));
37
- const eslint_merge_processors = __toESM(require("eslint-merge-processors"));
38
- const eslint_parser_plain = __toESM(require("eslint-parser-plain"));
39
- const eslint_plugin_regexp = __toESM(require("eslint-plugin-regexp"));
2
+ const require_chunk = require('./chunk-DWy1uDak.cjs');
3
+ let eslint_flat_config_utils = require("eslint-flat-config-utils");
4
+ eslint_flat_config_utils = require_chunk.__toESM(eslint_flat_config_utils);
5
+ let local_pkg = require("local-pkg");
6
+ local_pkg = require_chunk.__toESM(local_pkg);
7
+ let __eslint_community_eslint_plugin_eslint_comments = require("@eslint-community/eslint-plugin-eslint-comments");
8
+ __eslint_community_eslint_plugin_eslint_comments = require_chunk.__toESM(__eslint_community_eslint_plugin_eslint_comments);
9
+ let eslint_plugin_antfu = require("eslint-plugin-antfu");
10
+ eslint_plugin_antfu = require_chunk.__toESM(eslint_plugin_antfu);
11
+ let eslint_plugin_import_lite = require("eslint-plugin-import-lite");
12
+ eslint_plugin_import_lite = require_chunk.__toESM(eslint_plugin_import_lite);
13
+ let eslint_plugin_n = require("eslint-plugin-n");
14
+ eslint_plugin_n = require_chunk.__toESM(eslint_plugin_n);
15
+ let eslint_plugin_perfectionist = require("eslint-plugin-perfectionist");
16
+ eslint_plugin_perfectionist = require_chunk.__toESM(eslint_plugin_perfectionist);
17
+ let eslint_plugin_unicorn = require("eslint-plugin-unicorn");
18
+ eslint_plugin_unicorn = require_chunk.__toESM(eslint_plugin_unicorn);
19
+ let eslint_plugin_unused_imports = require("eslint-plugin-unused-imports");
20
+ eslint_plugin_unused_imports = require_chunk.__toESM(eslint_plugin_unused_imports);
21
+ let node_process = require("node:process");
22
+ node_process = require_chunk.__toESM(node_process);
23
+ let node_url = require("node:url");
24
+ node_url = require_chunk.__toESM(node_url);
25
+ let globals = require("globals");
26
+ globals = require_chunk.__toESM(globals);
27
+ let eslint_merge_processors = require("eslint-merge-processors");
28
+ eslint_merge_processors = require_chunk.__toESM(eslint_merge_processors);
29
+ let eslint_parser_plain = require("eslint-parser-plain");
30
+ eslint_parser_plain = require_chunk.__toESM(eslint_parser_plain);
31
+ let eslint_plugin_regexp = require("eslint-plugin-regexp");
32
+ eslint_plugin_regexp = require_chunk.__toESM(eslint_plugin_regexp);
40
33
 
41
34
  //#region src/configs/comments.ts
42
35
  async function comments(options = {}) {
@@ -211,8 +204,7 @@ const parserPlain = {
211
204
  * Combine array and non-array configs into a single array.
212
205
  */
213
206
  async function combine(...configs$1) {
214
- const resolved = await Promise.all(configs$1);
215
- return resolved.flat();
207
+ return (await Promise.all(configs$1)).flat();
216
208
  }
217
209
  function renameRules(rules, map) {
218
210
  return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
@@ -245,9 +237,7 @@ async function ensurePackages(packages) {
245
237
  if (node_process.default.env.CI || node_process.default.stdout.isTTY === false || isCwdInScope === false) return;
246
238
  const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
247
239
  if (nonExistingPackages.length === 0) return;
248
- const p = await import("@clack/prompts");
249
- const result = await p.confirm({ message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?` });
250
- if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
240
+ if (await (await import("@clack/prompts")).confirm({ message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?` })) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
251
241
  }
252
242
  function isInEditorEnv() {
253
243
  if (node_process.default.env.CI) return false;
@@ -366,10 +356,9 @@ async function formatters(options = {}, stylistic$1 = {}) {
366
356
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
367
357
  useTabs: indent === "tab"
368
358
  }, options.dprintOptions || {});
369
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
370
359
  const configs$1 = [{
371
360
  name: "eslint/formatter/setup",
372
- plugins: { format: pluginFormat }
361
+ plugins: { format: await interopDefault(import("eslint-plugin-format")) }
373
362
  }];
374
363
  if (options.css) configs$1.push({
375
364
  files: [GLOB_CSS, GLOB_POSTCSS],
@@ -483,7 +472,7 @@ async function javascript(options = {}) {
483
472
  const { isInEditor = false, overrides = {} } = options;
484
473
  return [{
485
474
  languageOptions: {
486
- ecmaVersion: 2022,
475
+ ecmaVersion: "latest",
487
476
  globals: {
488
477
  ...globals.default.browser,
489
478
  ...globals.default.es2021,
@@ -494,7 +483,7 @@ async function javascript(options = {}) {
494
483
  },
495
484
  parserOptions: {
496
485
  ecmaFeatures: { jsx: true },
497
- ecmaVersion: 2022,
486
+ ecmaVersion: "latest",
498
487
  sourceType: "module"
499
488
  },
500
489
  sourceType: "module"
@@ -1089,43 +1078,7 @@ async function react(options = {}) {
1089
1078
  "react-dom/no-unsafe-target-blank": "warn",
1090
1079
  "react-dom/no-use-form-state": "error",
1091
1080
  "react-dom/no-void-elements-with-children": "error",
1092
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1093
- "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1094
- "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
1095
- "react-hooks/exhaustive-deps": "warn",
1096
- "react-hooks/rules-of-hooks": "error",
1097
- "react-refresh/only-export-components": ["warn", {
1098
- allowConstantExport: isAllowConstantExport,
1099
- allowExportNames: [...isUsingNext ? [
1100
- "dynamic",
1101
- "dynamicParams",
1102
- "revalidate",
1103
- "fetchCache",
1104
- "runtime",
1105
- "preferredRegion",
1106
- "maxDuration",
1107
- "config",
1108
- "generateStaticParams",
1109
- "metadata",
1110
- "generateMetadata",
1111
- "viewport",
1112
- "generateViewport"
1113
- ] : [], ...isUsingRemix || isUsingReactRouter ? [
1114
- "meta",
1115
- "links",
1116
- "headers",
1117
- "loader",
1118
- "action",
1119
- "clientLoader",
1120
- "clientAction",
1121
- "handle",
1122
- "shouldRevalidate"
1123
- ] : []]
1124
- }],
1125
- "react-web-api/no-leaked-event-listener": "warn",
1126
- "react-web-api/no-leaked-interval": "warn",
1127
- "react-web-api/no-leaked-resize-observer": "warn",
1128
- "react-web-api/no-leaked-timeout": "warn",
1081
+ "react/jsx-no-comment-textnodes": "warn",
1129
1082
  "react/jsx-no-duplicate-props": "warn",
1130
1083
  "react/jsx-uses-vars": "warn",
1131
1084
  "react/no-access-state-in-setstate": "error",
@@ -1136,7 +1089,6 @@ async function react(options = {}) {
1136
1089
  "react/no-children-only": "warn",
1137
1090
  "react/no-children-to-array": "warn",
1138
1091
  "react/no-clone-element": "warn",
1139
- "react/no-comment-textnodes": "warn",
1140
1092
  "react/no-component-will-mount": "error",
1141
1093
  "react/no-component-will-receive-props": "error",
1142
1094
  "react/no-component-will-update": "error",
@@ -1144,7 +1096,6 @@ async function react(options = {}) {
1144
1096
  "react/no-create-ref": "error",
1145
1097
  "react/no-default-props": "error",
1146
1098
  "react/no-direct-mutation-state": "error",
1147
- "react/no-duplicate-jsx-props": "warn",
1148
1099
  "react/no-duplicate-key": "warn",
1149
1100
  "react/no-forward-ref": "warn",
1150
1101
  "react/no-implicit-key": "warn",
@@ -1156,6 +1107,7 @@ async function react(options = {}) {
1156
1107
  "react/no-set-state-in-component-did-update": "warn",
1157
1108
  "react/no-set-state-in-component-will-update": "warn",
1158
1109
  "react/no-string-refs": "error",
1110
+ "react/no-unnecessary-use-prefix": "warn",
1159
1111
  "react/no-unsafe-component-will-mount": "warn",
1160
1112
  "react/no-unsafe-component-will-receive-props": "warn",
1161
1113
  "react/no-unsafe-component-will-update": "warn",
@@ -1165,7 +1117,41 @@ async function react(options = {}) {
1165
1117
  "react/no-unused-state": "warn",
1166
1118
  "react/no-use-context": "warn",
1167
1119
  "react/no-useless-forward-ref": "warn",
1168
- "react/use-jsx-vars": "warn",
1120
+ "react/prefer-use-state-lazy-initialization": "warn",
1121
+ ...pluginReactHooks.configs.recommended.rules,
1122
+ "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1123
+ "react-refresh/only-export-components": ["warn", {
1124
+ allowConstantExport: isAllowConstantExport,
1125
+ allowExportNames: [...isUsingNext ? [
1126
+ "dynamic",
1127
+ "dynamicParams",
1128
+ "revalidate",
1129
+ "fetchCache",
1130
+ "runtime",
1131
+ "preferredRegion",
1132
+ "maxDuration",
1133
+ "config",
1134
+ "generateStaticParams",
1135
+ "metadata",
1136
+ "generateMetadata",
1137
+ "viewport",
1138
+ "generateViewport"
1139
+ ] : [], ...isUsingRemix || isUsingReactRouter ? [
1140
+ "meta",
1141
+ "links",
1142
+ "headers",
1143
+ "loader",
1144
+ "action",
1145
+ "clientLoader",
1146
+ "clientAction",
1147
+ "handle",
1148
+ "shouldRevalidate"
1149
+ ] : []]
1150
+ }],
1151
+ "react-web-api/no-leaked-event-listener": "warn",
1152
+ "react-web-api/no-leaked-interval": "warn",
1153
+ "react-web-api/no-leaked-resize-observer": "warn",
1154
+ "react-web-api/no-leaked-timeout": "warn",
1169
1155
  ...overrides
1170
1156
  }
1171
1157
  },
@@ -1272,6 +1258,14 @@ async function sortPackageJson() {
1272
1258
  order: { type: "asc" },
1273
1259
  pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1274
1260
  },
1261
+ {
1262
+ order: { type: "asc" },
1263
+ pathPattern: "^workspaces\\.catalog$"
1264
+ },
1265
+ {
1266
+ order: { type: "asc" },
1267
+ pathPattern: "^workspaces\\.catalogs\\.[^.]+$"
1268
+ },
1275
1269
  {
1276
1270
  order: [
1277
1271
  "types",
@@ -1501,7 +1495,7 @@ async function toml(options = {}) {
1501
1495
  //#endregion
1502
1496
  //#region src/configs/typescript.ts
1503
1497
  async function typescript(options = {}) {
1504
- const { componentExts = [], overrides = {}, parserOptions = {}, type = "app" } = options;
1498
+ const { componentExts = [], erasableOnly = false, overrides = {}, parserOptions = {}, type = "app" } = options;
1505
1499
  const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
1506
1500
  const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
1507
1501
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
@@ -1634,6 +1628,16 @@ async function typescript(options = {}) {
1634
1628
  ...typeAwareRules,
1635
1629
  ...overrides
1636
1630
  }
1631
+ }] : [],
1632
+ ...erasableOnly ? [{
1633
+ name: "eslint/typescript/erasable-syntax-only",
1634
+ plugins: { "erasable-syntax-only": await interopDefault(Promise.resolve().then(() => require("./lib-B2tdYoXA.cjs"))) },
1635
+ rules: {
1636
+ "erasable-syntax-only/enums": "error",
1637
+ "erasable-syntax-only/import-aliases": "error",
1638
+ "erasable-syntax-only/namespaces": "error",
1639
+ "erasable-syntax-only/parameter-properties": "error"
1640
+ }
1637
1641
  }] : []
1638
1642
  ];
1639
1643
  }