@lincy/eslint-config 5.4.2 → 5.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/dist/index.js CHANGED
@@ -307,7 +307,9 @@ async function stylistic(options = {}) {
307
307
  },
308
308
  // 覆盖`stylistic`默认规则
309
309
  "style/brace-style": ["error", "stroustrup"],
310
+ "style/generator-star-spacing": ["error", { after: true, before: false }],
310
311
  "style/multiline-ternary": ["error", "never"],
312
+ "style/yield-star-spacing": ["error", { after: true, before: false }],
311
313
  ...overrides
312
314
  }
313
315
  }
@@ -1088,6 +1090,53 @@ async function perfectionist(options = {}) {
1088
1090
  ];
1089
1091
  }
1090
1092
 
1093
+ // src/configs/pnpm.ts
1094
+ async function pnpm() {
1095
+ const [
1096
+ pluginPnpm,
1097
+ yamlParser,
1098
+ jsoncParser
1099
+ ] = await Promise.all([
1100
+ interopDefault(import("eslint-plugin-pnpm")),
1101
+ interopDefault(import("yaml-eslint-parser")),
1102
+ interopDefault(import("jsonc-eslint-parser"))
1103
+ ]);
1104
+ return [
1105
+ {
1106
+ files: [
1107
+ "package.json",
1108
+ "**/package.json"
1109
+ ],
1110
+ languageOptions: {
1111
+ parser: jsoncParser
1112
+ },
1113
+ name: "eslint/pnpm/package-json",
1114
+ plugins: {
1115
+ pnpm: pluginPnpm
1116
+ },
1117
+ rules: {
1118
+ "pnpm/json-enforce-catalog": "error",
1119
+ "pnpm/json-prefer-workspace-settings": "error",
1120
+ "pnpm/json-valid-catalog": "error"
1121
+ }
1122
+ },
1123
+ {
1124
+ files: ["pnpm-workspace.yaml"],
1125
+ languageOptions: {
1126
+ parser: yamlParser
1127
+ },
1128
+ name: "eslint/pnpm/pnpm-workspace-yaml",
1129
+ plugins: {
1130
+ pnpm: pluginPnpm
1131
+ },
1132
+ rules: {
1133
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
1134
+ "pnpm/yaml-no-unused-catalog-item": "error"
1135
+ }
1136
+ }
1137
+ ];
1138
+ }
1139
+
1091
1140
  // src/configs/react.ts
1092
1141
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1093
1142
  var ReactRefreshAllowConstantExportPackages = [
@@ -1133,7 +1182,6 @@ async function react(options = {}) {
1133
1182
  pluginReactRefresh
1134
1183
  ] = await Promise.all([
1135
1184
  interopDefault(import("@eslint-react/eslint-plugin")),
1136
- // @ts-expect-error missing types
1137
1185
  interopDefault(import("eslint-plugin-react-hooks")),
1138
1186
  interopDefault(import("eslint-plugin-react-refresh"))
1139
1187
  ]);
@@ -1169,22 +1217,29 @@ async function react(options = {}) {
1169
1217
  },
1170
1218
  name: "eslint/react/rules",
1171
1219
  rules: {
1172
- // recommended rules from @eslint-react/dom
1173
- "react-dom/no-children-in-void-dom-elements": "warn",
1174
- "react-dom/no-dangerously-set-innerhtml": "off",
1220
+ // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
1221
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1175
1222
  "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1176
1223
  "react-dom/no-find-dom-node": "error",
1224
+ "react-dom/no-flush-sync": "error",
1225
+ "react-dom/no-hydrate": "error",
1177
1226
  "react-dom/no-missing-button-type": "warn",
1178
1227
  "react-dom/no-missing-iframe-sandbox": "warn",
1179
1228
  "react-dom/no-namespace": "error",
1229
+ "react-dom/no-render": "error",
1180
1230
  "react-dom/no-render-return-value": "error",
1181
1231
  "react-dom/no-script-url": "warn",
1182
1232
  "react-dom/no-unsafe-iframe-sandbox": "warn",
1183
1233
  "react-dom/no-unsafe-target-blank": "warn",
1184
- // recommended rules react-hooks
1234
+ "react-dom/no-use-form-state": "error",
1235
+ "react-dom/no-void-elements-with-children": "error",
1236
+ // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
1237
+ "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1238
+ "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1239
+ // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
1185
1240
  "react-hooks/exhaustive-deps": "warn",
1186
1241
  "react-hooks/rules-of-hooks": "error",
1187
- // react refresh
1242
+ // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
1188
1243
  "react-refresh/only-export-components": [
1189
1244
  "warn",
1190
1245
  {
@@ -1215,31 +1270,35 @@ async function react(options = {}) {
1215
1270
  ]
1216
1271
  }
1217
1272
  ],
1218
- // recommended rules from @eslint-react/web-api
1273
+ // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
1219
1274
  "react-web-api/no-leaked-event-listener": "warn",
1220
1275
  "react-web-api/no-leaked-interval": "warn",
1221
1276
  "react-web-api/no-leaked-resize-observer": "warn",
1222
1277
  "react-web-api/no-leaked-timeout": "warn",
1223
- // recommended rules from @eslint-react
1224
- "react/ensure-forward-ref-using-ref": "warn",
1278
+ // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
1225
1279
  "react/no-access-state-in-setstate": "error",
1226
1280
  "react/no-array-index-key": "warn",
1227
1281
  "react/no-children-count": "warn",
1228
1282
  "react/no-children-for-each": "warn",
1229
1283
  "react/no-children-map": "warn",
1230
1284
  "react/no-children-only": "warn",
1231
- "react/no-children-prop": "warn",
1232
1285
  "react/no-children-to-array": "warn",
1233
1286
  "react/no-clone-element": "warn",
1234
1287
  "react/no-comment-textnodes": "warn",
1235
1288
  "react/no-component-will-mount": "error",
1236
1289
  "react/no-component-will-receive-props": "error",
1237
1290
  "react/no-component-will-update": "error",
1291
+ "react/no-context-provider": "warn",
1238
1292
  "react/no-create-ref": "error",
1293
+ "react/no-default-props": "error",
1239
1294
  "react/no-direct-mutation-state": "error",
1240
- "react/no-duplicate-key": "error",
1295
+ "react/no-duplicate-jsx-props": "warn",
1296
+ "react/no-duplicate-key": "warn",
1297
+ "react/no-forward-ref": "warn",
1298
+ "react/no-implicit-key": "warn",
1241
1299
  "react/no-missing-key": "error",
1242
- "react/no-nested-components": "warn",
1300
+ "react/no-nested-component-definitions": "error",
1301
+ "react/no-prop-types": "error",
1243
1302
  "react/no-redundant-should-component-update": "error",
1244
1303
  "react/no-set-state-in-component-did-mount": "warn",
1245
1304
  "react/no-set-state-in-component-did-update": "warn",
@@ -1248,14 +1307,13 @@ async function react(options = {}) {
1248
1307
  "react/no-unsafe-component-will-mount": "warn",
1249
1308
  "react/no-unsafe-component-will-receive-props": "warn",
1250
1309
  "react/no-unsafe-component-will-update": "warn",
1251
- "react/no-unstable-context-value": "error",
1252
- "react/no-unstable-default-props": "error",
1310
+ "react/no-unstable-context-value": "warn",
1311
+ "react/no-unstable-default-props": "warn",
1253
1312
  "react/no-unused-class-component-members": "warn",
1254
1313
  "react/no-unused-state": "warn",
1255
- "react/no-useless-fragment": "warn",
1256
- "react/prefer-destructuring-assignment": "warn",
1257
- "react/prefer-shorthand-boolean": "warn",
1258
- "react/prefer-shorthand-fragment": "warn",
1314
+ "react/no-use-context": "warn",
1315
+ "react/no-useless-forward-ref": "warn",
1316
+ "react/use-jsx-vars": "warn",
1259
1317
  // overrides
1260
1318
  ...overrides
1261
1319
  }
@@ -1441,6 +1499,7 @@ function sortTsconfig() {
1441
1499
  "useDefineForClassFields",
1442
1500
  "emitDecoratorMetadata",
1443
1501
  "experimentalDecorators",
1502
+ "libReplacement",
1444
1503
  /* Modules */
1445
1504
  "baseUrl",
1446
1505
  "rootDir",
@@ -1514,6 +1573,7 @@ function sortTsconfig() {
1514
1573
  "isolatedModules",
1515
1574
  "preserveSymlinks",
1516
1575
  "verbatimModuleSyntax",
1576
+ "erasableSyntaxOnly",
1517
1577
  /* Completeness */
1518
1578
  "skipDefaultLibCheck",
1519
1579
  "skipLibCheck"
@@ -1954,13 +2014,13 @@ async function vue(options = {}) {
1954
2014
  rules: {
1955
2015
  ...pluginVue.configs.base.rules,
1956
2016
  ...vueVersion === "2" ? {
1957
- ...pluginVue.configs.essential.rules,
1958
- ...pluginVue.configs["strongly-recommended"].rules,
1959
- ...pluginVue.configs.recommended.rules
2017
+ ...pluginVue.configs["vue2-essential"].rules,
2018
+ ...pluginVue.configs["vue2-strongly-recommended"].rules,
2019
+ ...pluginVue.configs["vue2-recommended"].rules
1960
2020
  } : {
1961
- ...pluginVue.configs["vue3-essential"].rules,
1962
- ...pluginVue.configs["vue3-strongly-recommended"].rules,
1963
- ...pluginVue.configs["vue3-recommended"].rules
2021
+ ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2022
+ ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2023
+ ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {})
1964
2024
  },
1965
2025
  "antfu/no-top-level-await": "off",
1966
2026
  "node/prefer-global/process": "off",
@@ -2127,6 +2187,41 @@ async function yaml(options = {}) {
2127
2187
  } : {},
2128
2188
  ...overrides
2129
2189
  }
2190
+ },
2191
+ {
2192
+ files: ["pnpm-workspace.yaml"],
2193
+ name: "eslint/yaml/pnpm-workspace",
2194
+ rules: {
2195
+ "yaml/sort-keys": [
2196
+ "error",
2197
+ {
2198
+ order: [
2199
+ "packages",
2200
+ "overrides",
2201
+ "patchedDependencies",
2202
+ "hoistPattern",
2203
+ "catalog",
2204
+ "catalogs",
2205
+ "allowedDeprecatedVersions",
2206
+ "allowNonAppliedPatches",
2207
+ "configDependencies",
2208
+ "ignoredBuiltDependencies",
2209
+ "ignoredOptionalDependencies",
2210
+ "neverBuiltDependencies",
2211
+ "onlyBuiltDependencies",
2212
+ "onlyBuiltDependenciesFile",
2213
+ "packageExtensions",
2214
+ "peerDependencyRules",
2215
+ "supportedArchitectures"
2216
+ ],
2217
+ pathPattern: "^$"
2218
+ },
2219
+ {
2220
+ order: { type: "asc" },
2221
+ pathPattern: ".*"
2222
+ }
2223
+ ]
2224
+ }
2130
2225
  }
2131
2226
  ];
2132
2227
  }
@@ -2167,6 +2262,7 @@ function lincy(options = {}, ...userConfigs) {
2167
2262
  ignores: ignoresList = [],
2168
2263
  jsx: enableJsx = true,
2169
2264
  overrides = {},
2265
+ pnpm: enableCatalogs = false,
2170
2266
  react: enableReact = false,
2171
2267
  regexp: enableRegexp = true,
2172
2268
  typescript: enableTypeScript = isPackageExists3("typescript"),
@@ -2302,6 +2398,11 @@ function lincy(options = {}, ...userConfigs) {
2302
2398
  sortTsconfig()
2303
2399
  );
2304
2400
  }
2401
+ if (enableCatalogs) {
2402
+ configs2.push(
2403
+ pnpm()
2404
+ );
2405
+ }
2305
2406
  if (options.yaml ?? true) {
2306
2407
  configs2.push(yaml({
2307
2408
  ...resolveSubOptions(options, "yaml"),
@@ -2430,6 +2531,7 @@ export {
2430
2531
  node,
2431
2532
  parserPlain,
2432
2533
  perfectionist,
2534
+ pnpm,
2433
2535
  react,
2434
2536
  regexp,
2435
2537
  renamePluginInConfigs,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "5.4.2",
5
- "packageManager": "pnpm@10.3.0",
4
+ "version": "5.5.1",
5
+ "packageManager": "pnpm@10.6.5",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
8
8
  "license": "MIT",
@@ -66,90 +66,72 @@
66
66
  }
67
67
  },
68
68
  "dependencies": {
69
- "@antfu/eslint-define-config": "1.23.0-2",
70
- "@antfu/install-pkg": "^1.0.0",
71
- "@clack/prompts": "^0.10.0",
72
- "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
73
- "@eslint/markdown": "^6.2.2",
74
- "@stylistic/eslint-plugin": "4.0.0-beta.1",
75
- "@typescript-eslint/eslint-plugin": "^8.24.0",
76
- "@typescript-eslint/parser": "^8.24.0",
77
- "@vitest/eslint-plugin": "^1.1.31",
78
- "eslint-config-flat-gitignore": "^2.0.0",
79
- "eslint-flat-config-utils": "^2.0.1",
80
- "eslint-merge-processors": "^2.0.0",
81
- "eslint-parser-plain": "^0.1.1",
82
- "eslint-plugin-antfu": "^3.0.0",
83
- "eslint-plugin-import-x": "^4.6.1",
84
- "eslint-plugin-jsdoc": "^50.6.3",
85
- "eslint-plugin-jsonc": "^2.19.1",
86
- "eslint-plugin-n": "^17.15.1",
87
- "eslint-plugin-no-only-tests": "^3.3.0",
88
- "eslint-plugin-perfectionist": "^4.8.0",
89
- "eslint-plugin-regexp": "^2.7.0",
90
- "eslint-plugin-toml": "^0.12.0",
91
- "eslint-plugin-unicorn": "^56.0.1",
92
- "eslint-plugin-unused-imports": "^4.1.4",
93
- "eslint-plugin-vue": "^9.32.0",
94
- "eslint-plugin-yml": "^1.16.0",
95
- "eslint-processor-vue-blocks": "^2.0.0",
96
- "globals": "^15.15.0",
97
- "jsonc-eslint-parser": "^2.4.0",
98
- "local-pkg": "^1.0.0",
99
- "prompts": "^2.4.2",
100
- "toml-eslint-parser": "^0.10.0",
101
- "vue-eslint-parser": "^9.4.3",
102
- "yaml-eslint-parser": "^1.2.3"
69
+ "@antfu/install-pkg": "catalog:prod",
70
+ "@clack/prompts": "catalog:prod",
71
+ "@eslint-community/eslint-plugin-eslint-comments": "catalog:prod",
72
+ "@eslint/markdown": "catalog:prod",
73
+ "@stylistic/eslint-plugin": "catalog:prod",
74
+ "@typescript-eslint/eslint-plugin": "catalog:prod",
75
+ "@typescript-eslint/parser": "catalog:prod",
76
+ "@vitest/eslint-plugin": "catalog:prod",
77
+ "eslint-config-flat-gitignore": "catalog:prod",
78
+ "eslint-flat-config-utils": "catalog:prod",
79
+ "eslint-merge-processors": "catalog:prod",
80
+ "eslint-parser-plain": "catalog:prod",
81
+ "eslint-plugin-antfu": "catalog:prod",
82
+ "eslint-plugin-import-x": "catalog:prod",
83
+ "eslint-plugin-jsdoc": "catalog:prod",
84
+ "eslint-plugin-jsonc": "catalog:prod",
85
+ "eslint-plugin-n": "catalog:prod",
86
+ "eslint-plugin-no-only-tests": "catalog:prod",
87
+ "eslint-plugin-perfectionist": "catalog:prod",
88
+ "eslint-plugin-pnpm": "catalog:prod",
89
+ "eslint-plugin-regexp": "catalog:prod",
90
+ "eslint-plugin-toml": "catalog:prod",
91
+ "eslint-plugin-unicorn": "catalog:prod",
92
+ "eslint-plugin-unused-imports": "catalog:prod",
93
+ "eslint-plugin-vue": "catalog:prod",
94
+ "eslint-plugin-yml": "catalog:prod",
95
+ "eslint-processor-vue-blocks": "catalog:prod",
96
+ "globals": "catalog:prod",
97
+ "jsonc-eslint-parser": "catalog:prod",
98
+ "local-pkg": "catalog:prod",
99
+ "prompts": "catalog:prod",
100
+ "toml-eslint-parser": "catalog:prod",
101
+ "vue-eslint-parser": "catalog:prod",
102
+ "yaml-eslint-parser": "catalog:prod"
103
103
  },
104
104
  "devDependencies": {
105
- "@antfu/ni": "^23.3.1",
106
- "@eslint-react/eslint-plugin": "^1.26.2",
107
- "@eslint-types/jsdoc": "48.2.2",
108
- "@eslint-types/typescript-eslint": "^7.5.0",
109
- "@eslint-types/unicorn": "^52.0.0",
110
- "@eslint/config-inspector": "^1.0.0",
105
+ "@antfu/ni": "catalog:dev",
106
+ "@eslint-react/eslint-plugin": "catalog:dev",
107
+ "@eslint-types/jsdoc": "catalog:dev",
108
+ "@eslint-types/typescript-eslint": "catalog:dev",
109
+ "@eslint-types/unicorn": "catalog:dev",
110
+ "@eslint/config-inspector": "catalog:dev",
111
111
  "@lincy/eslint-config": "workspace:*",
112
- "@prettier/plugin-xml": "^3.4.1",
113
- "@stylistic/eslint-plugin-migrate": "^4.0.0-beta.1",
114
- "@types/fs-extra": "^11.0.4",
115
- "@types/node": "^22.13.1",
116
- "@types/prompts": "^2.4.9",
117
- "@types/react": "^19.0.8",
118
- "@unocss/eslint-plugin": "^65.4.3",
119
- "bumpp": "^10.0.3",
120
- "eslint": "^9.20.1",
121
- "eslint-plugin-format": "^1.0.1",
122
- "eslint-plugin-react-hooks": "^5.1.0",
123
- "eslint-plugin-react-refresh": "^0.4.19",
124
- "eslint-ts-patch": "9.8.0-1",
125
- "eslint-typegen": "^1.0.0",
126
- "esno": "^4.8.0",
127
- "fs-extra": "^11.3.0",
128
- "lint-staged": "^15.4.3",
129
- "prettier": "^3.5.0",
130
- "react": "^19.0.0",
131
- "rimraf": "^6.0.1",
132
- "simple-git-hooks": "^2.11.1",
133
- "simple-open-url": "^3.0.1",
134
- "sucrase": "^3.35.0",
135
- "tsup": "^8.3.6",
136
- "typescript": "^5.7.3",
137
- "unbuild": "^3.3.1",
138
- "vitest": "^3.0.5",
139
- "vue": "^3.5.13"
140
- },
141
- "pnpm": {
142
- "peerDependencyRules": {
143
- "ignoreMissing": [
144
- "prettier"
145
- ]
146
- }
147
- },
148
- "resolutions": {
149
- "@eslint-community/eslint-utils": "^4.4.1",
150
- "@typescript-eslint/utils": "^8.24.0",
151
- "eslint": "^9.20.1",
152
- "tsx": "^4.19.2"
112
+ "@prettier/plugin-xml": "catalog:dev",
113
+ "@stylistic/eslint-plugin-migrate": "catalog:dev",
114
+ "@types/node": "catalog:dev",
115
+ "@types/react": "catalog:dev",
116
+ "@unocss/eslint-plugin": "catalog:dev",
117
+ "bumpp": "catalog:dev",
118
+ "eslint": "catalog:dev",
119
+ "eslint-plugin-format": "catalog:dev",
120
+ "eslint-plugin-react-hooks": "catalog:dev",
121
+ "eslint-plugin-react-refresh": "catalog:dev",
122
+ "eslint-typegen": "catalog:dev",
123
+ "esno": "catalog:dev",
124
+ "lint-staged": "catalog:dev",
125
+ "prettier": "catalog:dev",
126
+ "react": "catalog:dev",
127
+ "simple-git-hooks": "catalog:dev",
128
+ "simple-open-url": "catalog:dev",
129
+ "sucrase": "catalog:dev",
130
+ "tinyglobby": "catalog:dev",
131
+ "tsup": "catalog:dev",
132
+ "typescript": "catalog:dev",
133
+ "vitest": "catalog:test",
134
+ "vue": "catalog:dev"
153
135
  },
154
136
  "simple-git-hooks": {
155
137
  "pre-commit": "npx lint-staged"