@lincy/eslint-config 5.3.1 → 5.4.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/dist/index.js CHANGED
@@ -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 }));
@@ -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",
@@ -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)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "5.3.1",
5
- "packageManager": "pnpm@9.14.4",
4
+ "version": "5.4.0",
5
+ "packageManager": "pnpm@9.15.3",
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,73 +67,74 @@
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.14",
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.19.1",
76
+ "@typescript-eslint/parser": "^8.19.1",
77
+ "@vitest/eslint-plugin": "^1.1.25",
78
+ "eslint-config-flat-gitignore": "^1.0.0",
79
+ "eslint-flat-config-utils": "^1.0.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.0",
83
+ "eslint-plugin-import-x": "^4.6.1",
84
+ "eslint-plugin-jsdoc": "^50.6.1",
85
85
  "eslint-plugin-jsonc": "^2.18.2",
86
- "eslint-plugin-n": "^17.14.0",
86
+ "eslint-plugin-n": "^17.15.1",
87
87
  "eslint-plugin-no-only-tests": "^3.3.0",
88
- "eslint-plugin-perfectionist": "^4.1.2",
88
+ "eslint-plugin-perfectionist": "^4.6.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.17.3",
105
+ "@antfu/ni": "^23.2.0",
106
+ "@eslint-react/eslint-plugin": "^1.23.2",
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.5.6",
110
+ "@eslint/config-inspector": "^0.7.1",
111
111
  "@lincy/eslint-config": "workspace:*",
112
112
  "@prettier/plugin-xml": "^3.4.1",
113
- "@stylistic/eslint-plugin-migrate": "^2.11.0",
113
+ "@stylistic/eslint-plugin-migrate": "^2.13.0",
114
114
  "@types/fs-extra": "^11.0.4",
115
- "@types/node": "^22.10.1",
115
+ "@types/node": "^22.10.5",
116
116
  "@types/prompts": "^2.4.9",
117
- "@unocss/eslint-plugin": "^0.65.0",
118
- "bumpp": "^9.8.1",
119
- "eslint": "^9.16.0",
120
- "eslint-plugin-format": "^0.1.3",
121
- "eslint-plugin-react-hooks": "^5.0.0",
122
- "eslint-plugin-react-refresh": "^0.4.16",
117
+ "@types/react": "^19.0.6",
118
+ "@unocss/eslint-plugin": "^65.4.0",
119
+ "bumpp": "^9.10.0",
120
+ "eslint": "^9.18.0",
121
+ "eslint-plugin-format": "^1.0.1",
122
+ "eslint-plugin-react-hooks": "^5.1.0",
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
127
  "fs-extra": "^11.2.0",
127
- "lint-staged": "^15.2.10",
128
- "prettier": "^3.4.1",
129
- "react": "^18.3.1",
128
+ "lint-staged": "^15.3.0",
129
+ "prettier": "^3.4.2",
130
+ "react": "^19.0.0",
130
131
  "rimraf": "^6.0.1",
131
132
  "simple-git-hooks": "^2.11.1",
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": "^2.0.0",
136
+ "typescript": "^5.7.3",
137
+ "unbuild": "^3.3.0",
137
138
  "vitest": "^2.1.8",
138
139
  "vue": "^3.5.13"
139
140
  },
@@ -146,15 +147,15 @@
146
147
  },
147
148
  "resolutions": {
148
149
  "@eslint-community/eslint-utils": "^4.4.1",
149
- "@typescript-eslint/utils": "^8.17.0",
150
- "eslint": "^9.16.0",
150
+ "@typescript-eslint/utils": "^8.19.1",
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/"