@lincy/eslint-config 5.3.2 → 5.4.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/dist/index.js CHANGED
@@ -153,7 +153,7 @@ async function disables() {
153
153
  },
154
154
  {
155
155
  files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
156
- name: "antfu/disables/config-files",
156
+ name: "eslint/disables/config-files",
157
157
  rules: {
158
158
  "antfu/no-top-level-await": "off",
159
159
  "no-console": "off",
@@ -243,7 +243,7 @@ async function ensurePackages(packages) {
243
243
  const p = await import("@clack/prompts");
244
244
  const result = await p.confirm({
245
245
  // message: `${nonExistingPackages.length === 1 ? 'Package is' : 'Packages are'} required for this config: ${nonExistingPackages.join(', ')}. Do you want to install them?`,
246
- message: `\u6B64\u914D\u7F6E\u9700\u8981\u8F6F\u4EF6\u5305: ${nonExistingPackages.join(", ")}. \u4F60\u60F3\u5B89\u88C5\u5B83\u4EEC\u5417?`
246
+ message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?`
247
247
  });
248
248
  if (result)
249
249
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
@@ -732,7 +732,7 @@ async function javascript(options = {}) {
732
732
  allowTaggedTemplates: true,
733
733
  allowTernary: true
734
734
  }],
735
- "no-unused-vars": ["error", {
735
+ "no-unused-vars": ["warn", {
736
736
  args: "none",
737
737
  caughtErrors: "none",
738
738
  ignoreRestSiblings: true,
@@ -765,7 +765,7 @@ async function javascript(options = {}) {
765
765
  }
766
766
  ],
767
767
  "prefer-const": [
768
- "error",
768
+ isInEditor ? "warn" : "error",
769
769
  {
770
770
  destructuring: "all",
771
771
  ignoreReadBeforeAssign: true
@@ -779,7 +779,7 @@ async function javascript(options = {}) {
779
779
  "prefer-template": "error",
780
780
  "symbol-description": "error",
781
781
  "unicode-bom": ["error", "never"],
782
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
782
+ "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
783
783
  "unused-imports/no-unused-vars": [
784
784
  "error",
785
785
  {
@@ -1093,6 +1093,21 @@ import { isPackageExists as isPackageExists2 } from "local-pkg";
1093
1093
  var ReactRefreshAllowConstantExportPackages = [
1094
1094
  "vite"
1095
1095
  ];
1096
+ var RemixPackages = [
1097
+ "@remix-run/node",
1098
+ "@remix-run/react",
1099
+ "@remix-run/serve",
1100
+ "@remix-run/dev"
1101
+ ];
1102
+ var ReactRouterPackages = [
1103
+ "@react-router/node",
1104
+ "@react-router/react",
1105
+ "@react-router/serve",
1106
+ "@react-router/dev"
1107
+ ];
1108
+ var NextJsPackages = [
1109
+ "next"
1110
+ ];
1096
1111
  async function react(options = {}) {
1097
1112
  const {
1098
1113
  files = [GLOB_SRC],
@@ -1103,15 +1118,15 @@ async function react(options = {}) {
1103
1118
  overrides = {},
1104
1119
  tsconfigPath
1105
1120
  } = options;
1106
- const isTypeAware = !!tsconfigPath;
1107
- const typeAwareRules = {
1108
- "react/no-leaked-conditional-rendering": "warn"
1109
- };
1110
1121
  await ensurePackages([
1111
1122
  "@eslint-react/eslint-plugin",
1112
1123
  "eslint-plugin-react-hooks",
1113
1124
  "eslint-plugin-react-refresh"
1114
1125
  ]);
1126
+ const isTypeAware = !!tsconfigPath;
1127
+ const typeAwareRules = {
1128
+ "react/no-leaked-conditional-rendering": "warn"
1129
+ };
1115
1130
  const [
1116
1131
  pluginReact,
1117
1132
  pluginReactHooks,
@@ -1122,9 +1137,12 @@ async function react(options = {}) {
1122
1137
  interopDefault(import("eslint-plugin-react-hooks")),
1123
1138
  interopDefault(import("eslint-plugin-react-refresh"))
1124
1139
  ]);
1125
- const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1140
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1126
1141
  (i) => isPackageExists2(i)
1127
1142
  );
1143
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists2(i));
1144
+ const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists2(i));
1145
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
1128
1146
  const plugins = pluginReact.configs.all.plugins;
1129
1147
  return [
1130
1148
  {
@@ -1135,7 +1153,8 @@ async function react(options = {}) {
1135
1153
  "react-hooks": pluginReactHooks,
1136
1154
  "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1137
1155
  "react-naming-convention": plugins["@eslint-react/naming-convention"],
1138
- "react-refresh": pluginReactRefresh
1156
+ "react-refresh": pluginReactRefresh,
1157
+ "react-web-api": plugins["@eslint-react/web-api"]
1139
1158
  }
1140
1159
  },
1141
1160
  {
@@ -1166,10 +1185,41 @@ async function react(options = {}) {
1166
1185
  "react-hooks/exhaustive-deps": "warn",
1167
1186
  "react-hooks/rules-of-hooks": "error",
1168
1187
  // react refresh
1169
- // 'react-refresh/only-export-components': [
1170
- // 'warn',
1171
- // { allowConstantExport: isAllowConstantExport },
1172
- // ],
1188
+ "react-refresh/only-export-components": [
1189
+ "warn",
1190
+ {
1191
+ allowConstantExport: isAllowConstantExport,
1192
+ allowExportNames: [
1193
+ ...isUsingNext ? [
1194
+ "dynamic",
1195
+ "dynamicParams",
1196
+ "revalidate",
1197
+ "fetchCache",
1198
+ "runtime",
1199
+ "preferredRegion",
1200
+ "maxDuration",
1201
+ "config",
1202
+ "generateStaticParams",
1203
+ "metadata",
1204
+ "generateMetadata",
1205
+ "viewport",
1206
+ "generateViewport"
1207
+ ] : [],
1208
+ ...isUsingRemix || isUsingReactRouter ? [
1209
+ "meta",
1210
+ "links",
1211
+ "headers",
1212
+ "loader",
1213
+ "action"
1214
+ ] : []
1215
+ ]
1216
+ }
1217
+ ],
1218
+ // recommended rules from @eslint-react/web-api
1219
+ "react-web-api/no-leaked-event-listener": "warn",
1220
+ "react-web-api/no-leaked-interval": "warn",
1221
+ "react-web-api/no-leaked-resize-observer": "warn",
1222
+ "react-web-api/no-leaked-timeout": "warn",
1173
1223
  // recommended rules from @eslint-react
1174
1224
  "react/ensure-forward-ref-using-ref": "warn",
1175
1225
  "react/no-access-state-in-setstate": "error",
@@ -1512,7 +1562,7 @@ async function test(options = {}) {
1512
1562
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1513
1563
  "test/no-identical-title": "error",
1514
1564
  "test/no-import-node-test": "error",
1515
- "test/no-only-tests": isInEditor ? "off" : "error",
1565
+ "test/no-only-tests": isInEditor ? "warn" : "error",
1516
1566
  "test/prefer-hooks-in-order": "error",
1517
1567
  "test/prefer-lowercase-title": "error",
1518
1568
  // Disables
@@ -1717,7 +1767,7 @@ async function typescript(options = {}) {
1717
1767
  allowTernary: true
1718
1768
  }],
1719
1769
  "ts/no-unused-vars": [
1720
- "error",
1770
+ "warn",
1721
1771
  {
1722
1772
  args: "all",
1723
1773
  argsIgnorePattern: "^_",
@@ -1970,7 +2020,7 @@ async function vue(options = {}) {
1970
2020
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
1971
2021
  "vue/no-setup-props-reactivity-loss": "off",
1972
2022
  "vue/no-sparse-arrays": "error",
1973
- "vue/no-unused-refs": "error",
2023
+ "vue/no-unused-refs": "warn",
1974
2024
  "vue/no-useless-v-bind": "error",
1975
2025
  "vue/no-v-html": "off",
1976
2026
  "vue/no-v-text-v-html-on-component": "off",
@@ -2285,7 +2335,7 @@ function lincy(options = {}, ...userConfigs) {
2285
2335
  disables()
2286
2336
  );
2287
2337
  if ("files" in options) {
2288
- throw new Error("[@lincy/eslint-config] \u7B2C\u4E00\u4E2A\u53C2\u6570\u4E0D\u5E94\u5305\u542B\u201Cfiles\u201D\u5C5E\u6027\uFF0C\u56E0\u4E3A\u9009\u9879\u5E94\u8BE5\u662F\u5168\u5C40\u7684\u3002\u8BF7\u5C06\u5176\u653E\u5728\u7B2C\u4E8C\u4E2A\u6216\u66F4\u540E\u9762\u7684\u914D\u7F6E\u4E2D\u3002");
2338
+ throw new Error("[@lincy/eslint-config] 第一个参数不应包含“files”属性,因为选项应该是全局的。请将其放在第二个或更后面的配置中。");
2289
2339
  }
2290
2340
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2291
2341
  if (key in options)
@@ -2302,6 +2352,15 @@ function lincy(options = {}, ...userConfigs) {
2302
2352
  if (autoRenamePlugins) {
2303
2353
  composer = composer.renamePlugins(defaultPluginRenaming);
2304
2354
  }
2355
+ if (isInEditor) {
2356
+ composer = composer.disableRulesFix([
2357
+ "unused-imports/no-unused-imports",
2358
+ "test/no-only-tests",
2359
+ "prefer-const"
2360
+ ], {
2361
+ builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules)
2362
+ });
2363
+ }
2305
2364
  return composer;
2306
2365
  }
2307
2366
  function resolveSubOptions(options, key) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "5.3.2",
5
- "packageManager": "pnpm@9.15.0",
4
+ "version": "5.4.1",
5
+ "packageManager": "pnpm@9.15.4",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
8
8
  "license": "MIT",
@@ -30,9 +30,9 @@
30
30
  "prepublishOnly": "nr build",
31
31
  "release": "bumpp && npm publish -r --access public",
32
32
  "test": "vitest",
33
- "typegen": "esno scripts/typegen.ts",
34
- "lint": "pnpm run stub && eslint . --flag unstable_ts_config",
35
- "lint:fix": "eslint . --flag unstable_ts_config --fix",
33
+ "typegen": "tsx scripts/typegen.ts",
34
+ "lint": "pnpm run stub && eslint .",
35
+ "lint:fix": "eslint . --fix",
36
36
  "lint:ts": "tsc --noEmit",
37
37
  "prepare": "npx simple-git-hooks"
38
38
  },
@@ -67,64 +67,65 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@antfu/eslint-define-config": "1.23.0-2",
70
- "@antfu/install-pkg": "^0.5.0",
71
- "@clack/prompts": "^0.8.2",
70
+ "@antfu/install-pkg": "^1.0.0",
71
+ "@clack/prompts": "^0.9.1",
72
72
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
73
73
  "@eslint/markdown": "^6.2.1",
74
- "@stylistic/eslint-plugin": "2.11.0",
75
- "@typescript-eslint/eslint-plugin": "8.17.0",
76
- "@typescript-eslint/parser": "8.17.0",
77
- "@vitest/eslint-plugin": "^1.1.16",
78
- "eslint-config-flat-gitignore": "^0.3.0",
79
- "eslint-flat-config-utils": "^0.4.0",
80
- "eslint-merge-processors": "^0.1.0",
81
- "eslint-parser-plain": "^0.1.0",
74
+ "@stylistic/eslint-plugin": "^2.13.0",
75
+ "@typescript-eslint/eslint-plugin": "^8.21.0",
76
+ "@typescript-eslint/parser": "^8.21.0",
77
+ "@vitest/eslint-plugin": "^1.1.25",
78
+ "eslint-config-flat-gitignore": "^1.0.0",
79
+ "eslint-flat-config-utils": "^1.1.0",
80
+ "eslint-merge-processors": "^1.0.0",
81
+ "eslint-parser-plain": "^0.1.1",
82
82
  "eslint-plugin-antfu": "^2.7.0",
83
- "eslint-plugin-import-x": "^4.5.0",
84
- "eslint-plugin-jsdoc": "^50.6.1",
83
+ "eslint-plugin-import-x": "^4.6.1",
84
+ "eslint-plugin-jsdoc": "^50.6.2",
85
85
  "eslint-plugin-jsonc": "^2.18.2",
86
- "eslint-plugin-n": "^17.15.0",
86
+ "eslint-plugin-n": "^17.15.1",
87
87
  "eslint-plugin-no-only-tests": "^3.3.0",
88
- "eslint-plugin-perfectionist": "^4.3.0",
88
+ "eslint-plugin-perfectionist": "^4.7.0",
89
89
  "eslint-plugin-regexp": "^2.7.0",
90
90
  "eslint-plugin-toml": "^0.12.0",
91
91
  "eslint-plugin-unicorn": "^56.0.1",
92
92
  "eslint-plugin-unused-imports": "^4.1.4",
93
93
  "eslint-plugin-vue": "^9.32.0",
94
94
  "eslint-plugin-yml": "^1.16.0",
95
- "eslint-processor-vue-blocks": "^0.1.2",
96
- "globals": "^15.13.0",
95
+ "eslint-processor-vue-blocks": "^1.0.0",
96
+ "globals": "^15.14.0",
97
97
  "jsonc-eslint-parser": "^2.4.0",
98
- "local-pkg": "^0.5.1",
98
+ "local-pkg": "^1.0.0",
99
99
  "prompts": "^2.4.2",
100
100
  "toml-eslint-parser": "^0.10.0",
101
101
  "vue-eslint-parser": "^9.4.3",
102
102
  "yaml-eslint-parser": "^1.2.3"
103
103
  },
104
104
  "devDependencies": {
105
- "@antfu/ni": "^0.23.1",
106
- "@eslint-react/eslint-plugin": "^1.19.0",
105
+ "@antfu/ni": "^23.2.0",
106
+ "@eslint-react/eslint-plugin": "^1.24.1",
107
107
  "@eslint-types/jsdoc": "48.2.2",
108
108
  "@eslint-types/typescript-eslint": "^7.5.0",
109
109
  "@eslint-types/unicorn": "^52.0.0",
110
- "@eslint/config-inspector": "^0.6.0",
110
+ "@eslint/config-inspector": "^1.0.0",
111
111
  "@lincy/eslint-config": "workspace:*",
112
112
  "@prettier/plugin-xml": "^3.4.1",
113
- "@stylistic/eslint-plugin-migrate": "^2.12.1",
113
+ "@stylistic/eslint-plugin-migrate": "^2.13.0",
114
114
  "@types/fs-extra": "^11.0.4",
115
- "@types/node": "^22.10.2",
115
+ "@types/node": "^22.10.8",
116
116
  "@types/prompts": "^2.4.9",
117
- "@unocss/eslint-plugin": "^0.65.1",
118
- "bumpp": "^9.9.1",
119
- "eslint": "^9.17.0",
120
- "eslint-plugin-format": "^0.1.3",
117
+ "@types/react": "^19.0.7",
118
+ "@unocss/eslint-plugin": "^65.4.3",
119
+ "bumpp": "^9.10.2",
120
+ "eslint": "^9.18.0",
121
+ "eslint-plugin-format": "^1.0.1",
121
122
  "eslint-plugin-react-hooks": "^5.1.0",
122
- "eslint-plugin-react-refresh": "^0.4.16",
123
+ "eslint-plugin-react-refresh": "^0.4.18",
123
124
  "eslint-ts-patch": "9.8.0-1",
124
- "eslint-typegen": "^0.3.2",
125
+ "eslint-typegen": "^1.0.0",
125
126
  "esno": "^4.8.0",
126
- "fs-extra": "^11.2.0",
127
- "lint-staged": "^15.2.11",
127
+ "fs-extra": "^11.3.0",
128
+ "lint-staged": "^15.4.1",
128
129
  "prettier": "^3.4.2",
129
130
  "react": "^19.0.0",
130
131
  "rimraf": "^6.0.1",
@@ -132,9 +133,9 @@
132
133
  "simple-open-url": "^3.0.1",
133
134
  "sucrase": "^3.35.0",
134
135
  "tsup": "^8.3.5",
135
- "typescript": "^5.7.2",
136
- "unbuild": "^3.0.1",
137
- "vitest": "^2.1.8",
136
+ "typescript": "^5.7.3",
137
+ "unbuild": "^3.3.1",
138
+ "vitest": "^3.0.3",
138
139
  "vue": "^3.5.13"
139
140
  },
140
141
  "pnpm": {
@@ -146,15 +147,15 @@
146
147
  },
147
148
  "resolutions": {
148
149
  "@eslint-community/eslint-utils": "^4.4.1",
149
- "@typescript-eslint/utils": "^8.18.0",
150
- "eslint": "^9.17.0",
150
+ "@typescript-eslint/utils": "^8.21.0",
151
+ "eslint": "^9.18.0",
151
152
  "tsx": "^4.19.2"
152
153
  },
153
154
  "simple-git-hooks": {
154
155
  "pre-commit": "npx lint-staged"
155
156
  },
156
157
  "lint-staged": {
157
- "*.{[jt]s?(x),vue,md}": "eslint --fix --flag unstable_ts_config"
158
+ "*.{[jt]s?(x),vue,md}": "eslint --fix"
158
159
  },
159
160
  "publishConfig": {
160
161
  "registry": "https://registry.npmjs.org/"