@lincy/eslint-config 4.2.6 → 4.3.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 -6
- package/dist/index.cjs +63 -12
- package/dist/index.d.cts +14310 -57
- package/dist/index.d.ts +14310 -57
- package/dist/index.js +65 -16
- package/package.json +31 -29
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
|
-
import process3 from "process";
|
|
3
|
-
import fs from "fs";
|
|
2
|
+
import process3 from "node:process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
5
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
5
6
|
|
|
6
7
|
// src/plugins.ts
|
|
7
8
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
8
9
|
import { default as default3 } from "eslint-plugin-eslint-comments";
|
|
9
|
-
import * as pluginImport from "eslint-plugin-
|
|
10
|
+
import * as pluginImport from "eslint-plugin-import-x";
|
|
10
11
|
import { default as default4 } from "eslint-plugin-n";
|
|
11
12
|
import { default as default5 } from "eslint-plugin-unicorn";
|
|
12
13
|
import { default as default6 } from "eslint-plugin-unused-imports";
|
|
@@ -90,6 +91,7 @@ var GLOB_EXCLUDE = [
|
|
|
90
91
|
"**/.idea",
|
|
91
92
|
"**/.output",
|
|
92
93
|
"**/.vite-inspect",
|
|
94
|
+
"**/.yarn",
|
|
93
95
|
"**/CHANGELOG*.md",
|
|
94
96
|
"**/*.min.*",
|
|
95
97
|
"**/LICENSE*",
|
|
@@ -367,21 +369,40 @@ async function javascript(options = {}) {
|
|
|
367
369
|
}
|
|
368
370
|
|
|
369
371
|
// src/utils.ts
|
|
370
|
-
import process from "process";
|
|
372
|
+
import process from "node:process";
|
|
371
373
|
import { isPackageExists } from "local-pkg";
|
|
372
374
|
async function combine(...configs) {
|
|
373
375
|
const resolved = await Promise.all(configs);
|
|
374
376
|
return resolved.flat();
|
|
375
377
|
}
|
|
376
|
-
function renameRules(rules,
|
|
378
|
+
function renameRules(rules, map) {
|
|
377
379
|
return Object.fromEntries(
|
|
378
380
|
Object.entries(rules).map(([key, value]) => {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
+
for (const [from, to] of Object.entries(map)) {
|
|
382
|
+
if (key.startsWith(`${from}/`))
|
|
383
|
+
return [to + key.slice(from.length), value];
|
|
384
|
+
}
|
|
381
385
|
return [key, value];
|
|
382
386
|
})
|
|
383
387
|
);
|
|
384
388
|
}
|
|
389
|
+
function renamePluginInConfigs(configs, map) {
|
|
390
|
+
return configs.map((i) => {
|
|
391
|
+
const clone = { ...i };
|
|
392
|
+
if (clone.rules)
|
|
393
|
+
clone.rules = renameRules(clone.rules, map);
|
|
394
|
+
if (clone.plugins) {
|
|
395
|
+
clone.plugins = Object.fromEntries(
|
|
396
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
397
|
+
if (key in map)
|
|
398
|
+
return [map[key], value];
|
|
399
|
+
return [key, value];
|
|
400
|
+
})
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
return clone;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
385
406
|
function toArray(value) {
|
|
386
407
|
return Array.isArray(value) ? value : [value];
|
|
387
408
|
}
|
|
@@ -958,7 +979,6 @@ async function react(options = {}) {
|
|
|
958
979
|
"react/jsx-no-target-blank": "error",
|
|
959
980
|
"react/jsx-no-undef": "error",
|
|
960
981
|
"react/jsx-no-useless-fragment": "error",
|
|
961
|
-
"react/jsx-pascal-case": "error",
|
|
962
982
|
"react/jsx-props-no-spreading": "off",
|
|
963
983
|
// 强制任何 JSX 属性都不会传播
|
|
964
984
|
"react/jsx-uses-react": "error",
|
|
@@ -1015,6 +1035,7 @@ async function react(options = {}) {
|
|
|
1015
1035
|
"react/static-property-placement": "error",
|
|
1016
1036
|
"react/style-prop-object": "error",
|
|
1017
1037
|
"react/void-dom-elements-no-children": "error",
|
|
1038
|
+
"style/jsx-pascal-case": "error",
|
|
1018
1039
|
...typescript2 ? {
|
|
1019
1040
|
"react/jsx-no-undef": "off",
|
|
1020
1041
|
"react/prop-type": "off"
|
|
@@ -1110,6 +1131,22 @@ async function sortPackageJson() {
|
|
|
1110
1131
|
"default"
|
|
1111
1132
|
],
|
|
1112
1133
|
pathPattern: "^exports.*$"
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
order: [
|
|
1137
|
+
// client hooks only
|
|
1138
|
+
"pre-commit",
|
|
1139
|
+
"prepare-commit-msg",
|
|
1140
|
+
"commit-msg",
|
|
1141
|
+
"post-commit",
|
|
1142
|
+
"pre-rebase",
|
|
1143
|
+
"post-rewrite",
|
|
1144
|
+
"post-checkout",
|
|
1145
|
+
"post-merge",
|
|
1146
|
+
"pre-push",
|
|
1147
|
+
"pre-auto-gc"
|
|
1148
|
+
],
|
|
1149
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
1113
1150
|
}
|
|
1114
1151
|
]
|
|
1115
1152
|
}
|
|
@@ -1289,7 +1326,7 @@ async function test(options = {}) {
|
|
|
1289
1326
|
}
|
|
1290
1327
|
|
|
1291
1328
|
// src/configs/typescript.ts
|
|
1292
|
-
import process2 from "process";
|
|
1329
|
+
import process2 from "node:process";
|
|
1293
1330
|
async function typescript(options = {}) {
|
|
1294
1331
|
const {
|
|
1295
1332
|
componentExts = [],
|
|
@@ -1372,13 +1409,11 @@ async function typescript(options = {}) {
|
|
|
1372
1409
|
rules: {
|
|
1373
1410
|
...renameRules(
|
|
1374
1411
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1375
|
-
"@typescript-eslint
|
|
1376
|
-
"ts/"
|
|
1412
|
+
{ "@typescript-eslint": "ts" }
|
|
1377
1413
|
),
|
|
1378
1414
|
...renameRules(
|
|
1379
1415
|
pluginTs.configs.strict.rules,
|
|
1380
|
-
"@typescript-eslint
|
|
1381
|
-
"ts/"
|
|
1416
|
+
{ "@typescript-eslint": "ts" }
|
|
1382
1417
|
),
|
|
1383
1418
|
"no-dupe-class-members": "off",
|
|
1384
1419
|
"no-loss-of-precision": "off",
|
|
@@ -1833,12 +1868,21 @@ var VuePackages = [
|
|
|
1833
1868
|
"vitepress",
|
|
1834
1869
|
"@slidev/cli"
|
|
1835
1870
|
];
|
|
1871
|
+
var defaultPluginRenaming = {
|
|
1872
|
+
"@stylistic": "style",
|
|
1873
|
+
"@typescript-eslint": "ts",
|
|
1874
|
+
"import-x": "import",
|
|
1875
|
+
"n": "node",
|
|
1876
|
+
"vitest": "test",
|
|
1877
|
+
"yml": "yaml"
|
|
1878
|
+
};
|
|
1836
1879
|
var ReactPackages = [
|
|
1837
1880
|
"react",
|
|
1838
1881
|
"next"
|
|
1839
1882
|
];
|
|
1840
|
-
|
|
1883
|
+
function lincy(options = {}, ...userConfigs) {
|
|
1841
1884
|
const {
|
|
1885
|
+
autoRenamePlugins = true,
|
|
1842
1886
|
componentExts = [],
|
|
1843
1887
|
gitignore: enableGitignore = true,
|
|
1844
1888
|
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
@@ -1969,11 +2013,14 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1969
2013
|
}, {});
|
|
1970
2014
|
if (Object.keys(fusedConfig).length)
|
|
1971
2015
|
configs.push([fusedConfig]);
|
|
1972
|
-
|
|
2016
|
+
let pipeline = new FlatConfigComposer();
|
|
2017
|
+
pipeline = pipeline.append(
|
|
1973
2018
|
...configs,
|
|
1974
2019
|
...userConfigs
|
|
1975
2020
|
);
|
|
1976
|
-
|
|
2021
|
+
if (autoRenamePlugins)
|
|
2022
|
+
pipeline = pipeline.renamePlugins(defaultPluginRenaming);
|
|
2023
|
+
return pipeline;
|
|
1977
2024
|
}
|
|
1978
2025
|
|
|
1979
2026
|
// src/index.ts
|
|
@@ -2008,6 +2055,7 @@ export {
|
|
|
2008
2055
|
combine,
|
|
2009
2056
|
comments,
|
|
2010
2057
|
src_default as default,
|
|
2058
|
+
defaultPluginRenaming,
|
|
2011
2059
|
ensurePackages,
|
|
2012
2060
|
formatters,
|
|
2013
2061
|
ignores,
|
|
@@ -2021,6 +2069,7 @@ export {
|
|
|
2021
2069
|
node,
|
|
2022
2070
|
perfectionist,
|
|
2023
2071
|
react,
|
|
2072
|
+
renamePluginInConfigs,
|
|
2024
2073
|
renameRules,
|
|
2025
2074
|
sortPackageJson,
|
|
2026
2075
|
sortTsconfig,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.1",
|
|
5
5
|
"packageManager": "pnpm@8.7.6",
|
|
6
6
|
"description": "LinCenYing's ESLint config",
|
|
7
7
|
"author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
15
|
"import": "./dist/index.js",
|
|
17
16
|
"require": "./dist/index.cjs"
|
|
18
17
|
}
|
|
@@ -24,17 +23,18 @@
|
|
|
24
23
|
"dist"
|
|
25
24
|
],
|
|
26
25
|
"scripts": {
|
|
27
|
-
"build": "tsup
|
|
26
|
+
"build": "nr typegen && tsup --format esm,cjs --clean --dts",
|
|
28
27
|
"stub": "tsup src/index.ts --format esm",
|
|
29
28
|
"watch": "tsup --format esm,cjs --watch",
|
|
30
29
|
"postpublish": "simple-open-url https://npmmirror.com/package/@lincy/eslint-config",
|
|
31
30
|
"prepublishOnly": "nr build",
|
|
32
31
|
"release": "bumpp && npm publish -r --access public",
|
|
33
32
|
"test": "vitest",
|
|
33
|
+
"typegen": "esno scripts/typegen.ts",
|
|
34
34
|
"lint": "pnpm run stub && eslint .",
|
|
35
35
|
"lint:fix": "eslint . --fix",
|
|
36
36
|
"lint:ts": "tsc --noEmit",
|
|
37
|
-
"prepare": "
|
|
37
|
+
"prepare": "npx simple-git-hooks"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
@@ -63,30 +63,31 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
66
|
-
"@antfu/install-pkg": "^0.3.
|
|
67
|
-
"@stylistic/eslint-plugin": "1.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
69
|
-
"@typescript-eslint/parser": "^7.
|
|
66
|
+
"@antfu/install-pkg": "^0.3.2",
|
|
67
|
+
"@stylistic/eslint-plugin": "1.7.0",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
69
|
+
"@typescript-eslint/parser": "^7.5.0",
|
|
70
70
|
"eslint-config-flat-gitignore": "^0.1.3",
|
|
71
|
+
"eslint-flat-config-utils": "^0.2.0",
|
|
71
72
|
"eslint-merge-processors": "^0.1.0",
|
|
72
73
|
"eslint-parser-plain": "^0.1.0",
|
|
73
74
|
"eslint-plugin-antfu": "^2.1.2",
|
|
74
75
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
75
|
-
"eslint-plugin-
|
|
76
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
77
|
-
"eslint-plugin-jsonc": "^2.
|
|
76
|
+
"eslint-plugin-import-x": "^0.5.0",
|
|
77
|
+
"eslint-plugin-jsdoc": "^48.2.2",
|
|
78
|
+
"eslint-plugin-jsonc": "^2.15.0",
|
|
78
79
|
"eslint-plugin-markdown": "^4.0.1",
|
|
79
80
|
"eslint-plugin-n": "^16.6.2",
|
|
80
81
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
81
|
-
"eslint-plugin-perfectionist": "^2.
|
|
82
|
-
"eslint-plugin-toml": "^0.
|
|
82
|
+
"eslint-plugin-perfectionist": "^2.7.0",
|
|
83
|
+
"eslint-plugin-toml": "^0.11.0",
|
|
83
84
|
"eslint-plugin-unicorn": "^51.0.1",
|
|
84
85
|
"eslint-plugin-unused-imports": "^3.1.0",
|
|
85
|
-
"eslint-plugin-vitest": "^0.
|
|
86
|
-
"eslint-plugin-vue": "^9.
|
|
87
|
-
"eslint-plugin-yml": "^1.
|
|
86
|
+
"eslint-plugin-vitest": "^0.4.1",
|
|
87
|
+
"eslint-plugin-vue": "^9.24.0",
|
|
88
|
+
"eslint-plugin-yml": "^1.14.0",
|
|
88
89
|
"eslint-processor-vue-blocks": "^0.1.1",
|
|
89
|
-
"globals": "^
|
|
90
|
+
"globals": "^15.0.0",
|
|
90
91
|
"jsonc-eslint-parser": "^2.4.0",
|
|
91
92
|
"local-pkg": "^0.5.0",
|
|
92
93
|
"prompts": "^2.4.2",
|
|
@@ -96,33 +97,34 @@
|
|
|
96
97
|
},
|
|
97
98
|
"devDependencies": {
|
|
98
99
|
"@antfu/ni": "^0.21.12",
|
|
99
|
-
"@eslint-types/jsdoc": "48.2.
|
|
100
|
-
"@eslint-types/typescript-eslint": "^7.0
|
|
100
|
+
"@eslint-types/jsdoc": "48.2.1",
|
|
101
|
+
"@eslint-types/typescript-eslint": "^7.2.0",
|
|
101
102
|
"@eslint-types/unicorn": "^51.0.1",
|
|
103
|
+
"@eslint/config-inspector": "^0.2.1",
|
|
102
104
|
"@lincy/eslint-config": "workspace:*",
|
|
103
|
-
"@stylistic/eslint-plugin-migrate": "^1.
|
|
104
|
-
"@types/eslint": "^8.56.
|
|
105
|
-
"@types/node": "^20.
|
|
105
|
+
"@stylistic/eslint-plugin-migrate": "^1.7.0",
|
|
106
|
+
"@types/eslint": "^8.56.7",
|
|
107
|
+
"@types/node": "^20.12.2",
|
|
106
108
|
"@types/prompts": "^2.4.9",
|
|
107
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
109
|
+
"@unocss/eslint-plugin": "^0.58.8",
|
|
108
110
|
"bumpp": "^9.4.0",
|
|
109
111
|
"eslint": "^8.57.0",
|
|
110
|
-
"eslint-flat-config-viewer": "^0.1.11",
|
|
111
112
|
"eslint-plugin-format": "^0.1.0",
|
|
112
|
-
"eslint-plugin-react": "^7.34.
|
|
113
|
+
"eslint-plugin-react": "^7.34.1",
|
|
113
114
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
114
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
115
|
+
"eslint-plugin-react-refresh": "^0.4.6",
|
|
116
|
+
"eslint-typegen": "^0.2.0",
|
|
115
117
|
"esno": "^4.7.0",
|
|
116
118
|
"lint-staged": "^15.2.2",
|
|
117
119
|
"prettier": "^3.2.5",
|
|
118
120
|
"rimraf": "^5.0.5",
|
|
119
|
-
"simple-git-hooks": "^2.
|
|
121
|
+
"simple-git-hooks": "^2.11.1",
|
|
120
122
|
"simple-open-url": "^3.0.1",
|
|
121
123
|
"sucrase": "^3.35.0",
|
|
122
124
|
"tsup": "^8.0.2",
|
|
123
|
-
"typescript": "^5.4.
|
|
125
|
+
"typescript": "^5.4.3",
|
|
124
126
|
"unbuild": "^2.0.0",
|
|
125
|
-
"vitest": "^1.
|
|
127
|
+
"vitest": "^1.4.0",
|
|
126
128
|
"vue": "^3.4.21"
|
|
127
129
|
},
|
|
128
130
|
"pnpm": {
|