@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/README.md +4 -2
- package/dist/index.cjs +128 -25
- package/dist/index.d.cts +1398 -440
- package/dist/index.d.ts +1398 -440
- package/dist/index.js +126 -24
- package/package.json +65 -83
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
- 也适用于 json、yaml、markdown
|
|
11
11
|
- import导入排序, 对象字⾯量项尾逗号
|
|
12
12
|
- 合理的默认值,最佳实践,只需一行配置
|
|
13
|
+
- .gitignore默认支持
|
|
14
|
+
- 需要 ESLint v9.5.0+
|
|
13
15
|
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
|
|
14
16
|
- 使用 [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
15
17
|
- **风格原则**: 读取最小,差异稳定
|
|
@@ -25,7 +27,7 @@ pnpm add -D eslint @lincy/eslint-config
|
|
|
25
27
|
### Create config file
|
|
26
28
|
|
|
27
29
|
```js
|
|
28
|
-
// eslint.config.
|
|
30
|
+
// eslint.config.mjs
|
|
29
31
|
import lincy from '@lincy/eslint-config'
|
|
30
32
|
|
|
31
33
|
export default lincy()
|
|
@@ -110,7 +112,7 @@ export default lincy()
|
|
|
110
112
|
如果 package.json 中开启了`"type": "module",`
|
|
111
113
|
|
|
112
114
|
```js
|
|
113
|
-
// eslint.config.
|
|
115
|
+
// eslint.config.mjs
|
|
114
116
|
import lincy from '@lincy/eslint-config'
|
|
115
117
|
|
|
116
118
|
// or
|
package/dist/index.cjs
CHANGED
|
@@ -82,6 +82,7 @@ __export(index_exports, {
|
|
|
82
82
|
node: () => node,
|
|
83
83
|
parserPlain: () => parserPlain,
|
|
84
84
|
perfectionist: () => perfectionist,
|
|
85
|
+
pnpm: () => pnpm,
|
|
85
86
|
react: () => react,
|
|
86
87
|
regexp: () => regexp,
|
|
87
88
|
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
@@ -101,7 +102,7 @@ __export(index_exports, {
|
|
|
101
102
|
});
|
|
102
103
|
module.exports = __toCommonJS(index_exports);
|
|
103
104
|
|
|
104
|
-
// node_modules/.pnpm/tsup@8.
|
|
105
|
+
// node_modules/.pnpm/tsup@8.4.0_jiti@2.4.2_postcss@8.4.49_tsx@4.19.3_typescript@5.8.2_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
105
106
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
106
107
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
107
108
|
|
|
@@ -414,7 +415,9 @@ async function stylistic(options = {}) {
|
|
|
414
415
|
},
|
|
415
416
|
// 覆盖`stylistic`默认规则
|
|
416
417
|
"style/brace-style": ["error", "stroustrup"],
|
|
418
|
+
"style/generator-star-spacing": ["error", { after: true, before: false }],
|
|
417
419
|
"style/multiline-ternary": ["error", "never"],
|
|
420
|
+
"style/yield-star-spacing": ["error", { after: true, before: false }],
|
|
418
421
|
...overrides
|
|
419
422
|
}
|
|
420
423
|
}
|
|
@@ -1195,6 +1198,53 @@ async function perfectionist(options = {}) {
|
|
|
1195
1198
|
];
|
|
1196
1199
|
}
|
|
1197
1200
|
|
|
1201
|
+
// src/configs/pnpm.ts
|
|
1202
|
+
async function pnpm() {
|
|
1203
|
+
const [
|
|
1204
|
+
pluginPnpm,
|
|
1205
|
+
yamlParser,
|
|
1206
|
+
jsoncParser
|
|
1207
|
+
] = await Promise.all([
|
|
1208
|
+
interopDefault(import("eslint-plugin-pnpm")),
|
|
1209
|
+
interopDefault(import("yaml-eslint-parser")),
|
|
1210
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
1211
|
+
]);
|
|
1212
|
+
return [
|
|
1213
|
+
{
|
|
1214
|
+
files: [
|
|
1215
|
+
"package.json",
|
|
1216
|
+
"**/package.json"
|
|
1217
|
+
],
|
|
1218
|
+
languageOptions: {
|
|
1219
|
+
parser: jsoncParser
|
|
1220
|
+
},
|
|
1221
|
+
name: "eslint/pnpm/package-json",
|
|
1222
|
+
plugins: {
|
|
1223
|
+
pnpm: pluginPnpm
|
|
1224
|
+
},
|
|
1225
|
+
rules: {
|
|
1226
|
+
"pnpm/json-enforce-catalog": "error",
|
|
1227
|
+
"pnpm/json-prefer-workspace-settings": "error",
|
|
1228
|
+
"pnpm/json-valid-catalog": "error"
|
|
1229
|
+
}
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
files: ["pnpm-workspace.yaml"],
|
|
1233
|
+
languageOptions: {
|
|
1234
|
+
parser: yamlParser
|
|
1235
|
+
},
|
|
1236
|
+
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
1237
|
+
plugins: {
|
|
1238
|
+
pnpm: pluginPnpm
|
|
1239
|
+
},
|
|
1240
|
+
rules: {
|
|
1241
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1242
|
+
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
];
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1198
1248
|
// src/configs/react.ts
|
|
1199
1249
|
var import_local_pkg2 = require("local-pkg");
|
|
1200
1250
|
var ReactRefreshAllowConstantExportPackages = [
|
|
@@ -1240,7 +1290,6 @@ async function react(options = {}) {
|
|
|
1240
1290
|
pluginReactRefresh
|
|
1241
1291
|
] = await Promise.all([
|
|
1242
1292
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1243
|
-
// @ts-expect-error missing types
|
|
1244
1293
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1245
1294
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1246
1295
|
]);
|
|
@@ -1276,22 +1325,29 @@ async function react(options = {}) {
|
|
|
1276
1325
|
},
|
|
1277
1326
|
name: "eslint/react/rules",
|
|
1278
1327
|
rules: {
|
|
1279
|
-
// recommended rules from
|
|
1280
|
-
"react-dom/no-
|
|
1281
|
-
"react-dom/no-dangerously-set-innerhtml": "off",
|
|
1328
|
+
// recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
|
|
1329
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1282
1330
|
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1283
1331
|
"react-dom/no-find-dom-node": "error",
|
|
1332
|
+
"react-dom/no-flush-sync": "error",
|
|
1333
|
+
"react-dom/no-hydrate": "error",
|
|
1284
1334
|
"react-dom/no-missing-button-type": "warn",
|
|
1285
1335
|
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
1286
1336
|
"react-dom/no-namespace": "error",
|
|
1337
|
+
"react-dom/no-render": "error",
|
|
1287
1338
|
"react-dom/no-render-return-value": "error",
|
|
1288
1339
|
"react-dom/no-script-url": "warn",
|
|
1289
1340
|
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1290
1341
|
"react-dom/no-unsafe-target-blank": "warn",
|
|
1291
|
-
|
|
1342
|
+
"react-dom/no-use-form-state": "error",
|
|
1343
|
+
"react-dom/no-void-elements-with-children": "error",
|
|
1344
|
+
// recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
|
|
1345
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1346
|
+
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
|
|
1347
|
+
// recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
|
|
1292
1348
|
"react-hooks/exhaustive-deps": "warn",
|
|
1293
1349
|
"react-hooks/rules-of-hooks": "error",
|
|
1294
|
-
// react refresh
|
|
1350
|
+
// preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
|
|
1295
1351
|
"react-refresh/only-export-components": [
|
|
1296
1352
|
"warn",
|
|
1297
1353
|
{
|
|
@@ -1322,31 +1378,35 @@ async function react(options = {}) {
|
|
|
1322
1378
|
]
|
|
1323
1379
|
}
|
|
1324
1380
|
],
|
|
1325
|
-
// recommended rules from
|
|
1381
|
+
// recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
|
|
1326
1382
|
"react-web-api/no-leaked-event-listener": "warn",
|
|
1327
1383
|
"react-web-api/no-leaked-interval": "warn",
|
|
1328
1384
|
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1329
1385
|
"react-web-api/no-leaked-timeout": "warn",
|
|
1330
|
-
// recommended rules from
|
|
1331
|
-
"react/ensure-forward-ref-using-ref": "warn",
|
|
1386
|
+
// recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
|
|
1332
1387
|
"react/no-access-state-in-setstate": "error",
|
|
1333
1388
|
"react/no-array-index-key": "warn",
|
|
1334
1389
|
"react/no-children-count": "warn",
|
|
1335
1390
|
"react/no-children-for-each": "warn",
|
|
1336
1391
|
"react/no-children-map": "warn",
|
|
1337
1392
|
"react/no-children-only": "warn",
|
|
1338
|
-
"react/no-children-prop": "warn",
|
|
1339
1393
|
"react/no-children-to-array": "warn",
|
|
1340
1394
|
"react/no-clone-element": "warn",
|
|
1341
1395
|
"react/no-comment-textnodes": "warn",
|
|
1342
1396
|
"react/no-component-will-mount": "error",
|
|
1343
1397
|
"react/no-component-will-receive-props": "error",
|
|
1344
1398
|
"react/no-component-will-update": "error",
|
|
1399
|
+
"react/no-context-provider": "warn",
|
|
1345
1400
|
"react/no-create-ref": "error",
|
|
1401
|
+
"react/no-default-props": "error",
|
|
1346
1402
|
"react/no-direct-mutation-state": "error",
|
|
1347
|
-
"react/no-duplicate-
|
|
1403
|
+
"react/no-duplicate-jsx-props": "warn",
|
|
1404
|
+
"react/no-duplicate-key": "warn",
|
|
1405
|
+
"react/no-forward-ref": "warn",
|
|
1406
|
+
"react/no-implicit-key": "warn",
|
|
1348
1407
|
"react/no-missing-key": "error",
|
|
1349
|
-
"react/no-nested-
|
|
1408
|
+
"react/no-nested-component-definitions": "error",
|
|
1409
|
+
"react/no-prop-types": "error",
|
|
1350
1410
|
"react/no-redundant-should-component-update": "error",
|
|
1351
1411
|
"react/no-set-state-in-component-did-mount": "warn",
|
|
1352
1412
|
"react/no-set-state-in-component-did-update": "warn",
|
|
@@ -1355,14 +1415,13 @@ async function react(options = {}) {
|
|
|
1355
1415
|
"react/no-unsafe-component-will-mount": "warn",
|
|
1356
1416
|
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1357
1417
|
"react/no-unsafe-component-will-update": "warn",
|
|
1358
|
-
"react/no-unstable-context-value": "
|
|
1359
|
-
"react/no-unstable-default-props": "
|
|
1418
|
+
"react/no-unstable-context-value": "warn",
|
|
1419
|
+
"react/no-unstable-default-props": "warn",
|
|
1360
1420
|
"react/no-unused-class-component-members": "warn",
|
|
1361
1421
|
"react/no-unused-state": "warn",
|
|
1362
|
-
"react/no-
|
|
1363
|
-
"react/
|
|
1364
|
-
"react/
|
|
1365
|
-
"react/prefer-shorthand-fragment": "warn",
|
|
1422
|
+
"react/no-use-context": "warn",
|
|
1423
|
+
"react/no-useless-forward-ref": "warn",
|
|
1424
|
+
"react/use-jsx-vars": "warn",
|
|
1366
1425
|
// overrides
|
|
1367
1426
|
...overrides
|
|
1368
1427
|
}
|
|
@@ -1548,6 +1607,7 @@ function sortTsconfig() {
|
|
|
1548
1607
|
"useDefineForClassFields",
|
|
1549
1608
|
"emitDecoratorMetadata",
|
|
1550
1609
|
"experimentalDecorators",
|
|
1610
|
+
"libReplacement",
|
|
1551
1611
|
/* Modules */
|
|
1552
1612
|
"baseUrl",
|
|
1553
1613
|
"rootDir",
|
|
@@ -1621,6 +1681,7 @@ function sortTsconfig() {
|
|
|
1621
1681
|
"isolatedModules",
|
|
1622
1682
|
"preserveSymlinks",
|
|
1623
1683
|
"verbatimModuleSyntax",
|
|
1684
|
+
"erasableSyntaxOnly",
|
|
1624
1685
|
/* Completeness */
|
|
1625
1686
|
"skipDefaultLibCheck",
|
|
1626
1687
|
"skipLibCheck"
|
|
@@ -2061,13 +2122,13 @@ async function vue(options = {}) {
|
|
|
2061
2122
|
rules: {
|
|
2062
2123
|
...pluginVue.configs.base.rules,
|
|
2063
2124
|
...vueVersion === "2" ? {
|
|
2064
|
-
...pluginVue.configs
|
|
2065
|
-
...pluginVue.configs["strongly-recommended"].rules,
|
|
2066
|
-
...pluginVue.configs
|
|
2125
|
+
...pluginVue.configs["vue2-essential"].rules,
|
|
2126
|
+
...pluginVue.configs["vue2-strongly-recommended"].rules,
|
|
2127
|
+
...pluginVue.configs["vue2-recommended"].rules
|
|
2067
2128
|
} : {
|
|
2068
|
-
...pluginVue.configs["
|
|
2069
|
-
...pluginVue.configs["
|
|
2070
|
-
...pluginVue.configs["
|
|
2129
|
+
...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
|
|
2130
|
+
...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
|
|
2131
|
+
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {})
|
|
2071
2132
|
},
|
|
2072
2133
|
"antfu/no-top-level-await": "off",
|
|
2073
2134
|
"node/prefer-global/process": "off",
|
|
@@ -2234,6 +2295,41 @@ async function yaml(options = {}) {
|
|
|
2234
2295
|
} : {},
|
|
2235
2296
|
...overrides
|
|
2236
2297
|
}
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
files: ["pnpm-workspace.yaml"],
|
|
2301
|
+
name: "eslint/yaml/pnpm-workspace",
|
|
2302
|
+
rules: {
|
|
2303
|
+
"yaml/sort-keys": [
|
|
2304
|
+
"error",
|
|
2305
|
+
{
|
|
2306
|
+
order: [
|
|
2307
|
+
"packages",
|
|
2308
|
+
"overrides",
|
|
2309
|
+
"patchedDependencies",
|
|
2310
|
+
"hoistPattern",
|
|
2311
|
+
"catalog",
|
|
2312
|
+
"catalogs",
|
|
2313
|
+
"allowedDeprecatedVersions",
|
|
2314
|
+
"allowNonAppliedPatches",
|
|
2315
|
+
"configDependencies",
|
|
2316
|
+
"ignoredBuiltDependencies",
|
|
2317
|
+
"ignoredOptionalDependencies",
|
|
2318
|
+
"neverBuiltDependencies",
|
|
2319
|
+
"onlyBuiltDependencies",
|
|
2320
|
+
"onlyBuiltDependenciesFile",
|
|
2321
|
+
"packageExtensions",
|
|
2322
|
+
"peerDependencyRules",
|
|
2323
|
+
"supportedArchitectures"
|
|
2324
|
+
],
|
|
2325
|
+
pathPattern: "^$"
|
|
2326
|
+
},
|
|
2327
|
+
{
|
|
2328
|
+
order: { type: "asc" },
|
|
2329
|
+
pathPattern: ".*"
|
|
2330
|
+
}
|
|
2331
|
+
]
|
|
2332
|
+
}
|
|
2237
2333
|
}
|
|
2238
2334
|
];
|
|
2239
2335
|
}
|
|
@@ -2274,6 +2370,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2274
2370
|
ignores: ignoresList = [],
|
|
2275
2371
|
jsx: enableJsx = true,
|
|
2276
2372
|
overrides = {},
|
|
2373
|
+
pnpm: enableCatalogs = false,
|
|
2277
2374
|
react: enableReact = false,
|
|
2278
2375
|
regexp: enableRegexp = true,
|
|
2279
2376
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
@@ -2409,6 +2506,11 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2409
2506
|
sortTsconfig()
|
|
2410
2507
|
);
|
|
2411
2508
|
}
|
|
2509
|
+
if (enableCatalogs) {
|
|
2510
|
+
configs2.push(
|
|
2511
|
+
pnpm()
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2412
2514
|
if (options.yaml ?? true) {
|
|
2413
2515
|
configs2.push(yaml({
|
|
2414
2516
|
...resolveSubOptions(options, "yaml"),
|
|
@@ -2537,6 +2639,7 @@ var index_default = lincy;
|
|
|
2537
2639
|
node,
|
|
2538
2640
|
parserPlain,
|
|
2539
2641
|
perfectionist,
|
|
2642
|
+
pnpm,
|
|
2540
2643
|
react,
|
|
2541
2644
|
regexp,
|
|
2542
2645
|
renamePluginInConfigs,
|