@lincy/eslint-config 4.3.1 → 4.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/README.md +1 -1
- package/dist/index.cjs +39 -21
- package/dist/index.d.cts +268 -197
- package/dist/index.d.ts +268 -197
- package/dist/index.js +39 -21
- package/package.json +22 -22
package/dist/index.js
CHANGED
|
@@ -349,7 +349,7 @@ async function javascript(options = {}) {
|
|
|
349
349
|
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
350
350
|
"unused-imports/no-unused-vars": [
|
|
351
351
|
"error",
|
|
352
|
-
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
|
|
352
|
+
{ args: "after-used", argsIgnorePattern: "^_", ignoreRestSiblings: true, vars: "all", varsIgnorePattern: "^_" }
|
|
353
353
|
],
|
|
354
354
|
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
355
355
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
@@ -379,8 +379,9 @@ function renameRules(rules, map) {
|
|
|
379
379
|
return Object.fromEntries(
|
|
380
380
|
Object.entries(rules).map(([key, value]) => {
|
|
381
381
|
for (const [from, to] of Object.entries(map)) {
|
|
382
|
-
if (key.startsWith(`${from}/`))
|
|
382
|
+
if (key.startsWith(`${from}/`)) {
|
|
383
383
|
return [to + key.slice(from.length), value];
|
|
384
|
+
}
|
|
384
385
|
}
|
|
385
386
|
return [key, value];
|
|
386
387
|
})
|
|
@@ -389,13 +390,15 @@ function renameRules(rules, map) {
|
|
|
389
390
|
function renamePluginInConfigs(configs, map) {
|
|
390
391
|
return configs.map((i) => {
|
|
391
392
|
const clone = { ...i };
|
|
392
|
-
if (clone.rules)
|
|
393
|
+
if (clone.rules) {
|
|
393
394
|
clone.rules = renameRules(clone.rules, map);
|
|
395
|
+
}
|
|
394
396
|
if (clone.plugins) {
|
|
395
397
|
clone.plugins = Object.fromEntries(
|
|
396
398
|
Object.entries(clone.plugins).map(([key, value]) => {
|
|
397
|
-
if (key in map)
|
|
399
|
+
if (key in map) {
|
|
398
400
|
return [map[key], value];
|
|
401
|
+
}
|
|
399
402
|
return [key, value];
|
|
400
403
|
})
|
|
401
404
|
);
|
|
@@ -411,11 +414,13 @@ async function interopDefault(m) {
|
|
|
411
414
|
return resolved.default || resolved;
|
|
412
415
|
}
|
|
413
416
|
async function ensurePackages(packages) {
|
|
414
|
-
if (process.stdout.isTTY === false)
|
|
417
|
+
if (process.stdout.isTTY === false) {
|
|
415
418
|
return;
|
|
419
|
+
}
|
|
416
420
|
const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
|
|
417
|
-
if (nonExistingPackages.length === 0)
|
|
421
|
+
if (nonExistingPackages.length === 0) {
|
|
418
422
|
return;
|
|
423
|
+
}
|
|
419
424
|
const { default: prompts } = await import("prompts");
|
|
420
425
|
const { result } = await prompts([
|
|
421
426
|
{
|
|
@@ -424,8 +429,9 @@ async function ensurePackages(packages) {
|
|
|
424
429
|
type: "confirm"
|
|
425
430
|
}
|
|
426
431
|
]);
|
|
427
|
-
if (result)
|
|
432
|
+
if (result) {
|
|
428
433
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
434
|
+
}
|
|
429
435
|
}
|
|
430
436
|
|
|
431
437
|
// src/configs/jsdoc.ts
|
|
@@ -650,6 +656,7 @@ import * as parserPlain2 from "eslint-parser-plain";
|
|
|
650
656
|
var StylisticConfigDefaults = {
|
|
651
657
|
indent: 4,
|
|
652
658
|
jsx: true,
|
|
659
|
+
lessOpinionated: true,
|
|
653
660
|
quotes: "single",
|
|
654
661
|
semi: false
|
|
655
662
|
};
|
|
@@ -661,6 +668,7 @@ async function stylistic(options = {}) {
|
|
|
661
668
|
const {
|
|
662
669
|
indent,
|
|
663
670
|
jsx,
|
|
671
|
+
lessOpinionated,
|
|
664
672
|
quotes,
|
|
665
673
|
semi
|
|
666
674
|
} = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
|
|
@@ -683,9 +691,13 @@ async function stylistic(options = {}) {
|
|
|
683
691
|
rules: {
|
|
684
692
|
...config.rules,
|
|
685
693
|
"antfu/consistent-list-newline": "off",
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
694
|
+
...lessOpinionated ? {
|
|
695
|
+
curly: ["error", "all"]
|
|
696
|
+
} : {
|
|
697
|
+
"antfu/if-newline": "error",
|
|
698
|
+
"antfu/top-level-function": "error",
|
|
699
|
+
"curly": ["error", "multi-or-nest", "consistent"]
|
|
700
|
+
},
|
|
689
701
|
// 覆盖`stylistic`默认规则
|
|
690
702
|
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
691
703
|
"style/multiline-ternary": ["error", "never"],
|
|
@@ -798,7 +810,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
798
810
|
}
|
|
799
811
|
if (options.html) {
|
|
800
812
|
configs.push({
|
|
801
|
-
files: [
|
|
813
|
+
files: [GLOB_HTML],
|
|
802
814
|
languageOptions: {
|
|
803
815
|
parser: parserPlain2
|
|
804
816
|
},
|
|
@@ -1894,16 +1906,18 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1894
1906
|
} = options;
|
|
1895
1907
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1896
1908
|
if (stylisticOptions) {
|
|
1897
|
-
if (!("jsx" in stylisticOptions))
|
|
1909
|
+
if (!("jsx" in stylisticOptions)) {
|
|
1898
1910
|
stylisticOptions.jsx = options.jsx ?? true;
|
|
1911
|
+
}
|
|
1899
1912
|
}
|
|
1900
1913
|
const configs = [];
|
|
1901
1914
|
if (enableGitignore) {
|
|
1902
1915
|
if (typeof enableGitignore !== "boolean") {
|
|
1903
1916
|
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1904
1917
|
} else {
|
|
1905
|
-
if (fs.existsSync(".gitignore"))
|
|
1918
|
+
if (fs.existsSync(".gitignore")) {
|
|
1906
1919
|
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1920
|
+
}
|
|
1907
1921
|
}
|
|
1908
1922
|
}
|
|
1909
1923
|
configs.push(
|
|
@@ -1926,8 +1940,9 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
1926
1940
|
// Optional plugins (installed but not enabled by default)
|
|
1927
1941
|
perfectionist()
|
|
1928
1942
|
);
|
|
1929
|
-
if (enableVue)
|
|
1943
|
+
if (enableVue) {
|
|
1930
1944
|
componentExts.push("vue");
|
|
1945
|
+
}
|
|
1931
1946
|
if (enableTypeScript) {
|
|
1932
1947
|
configs.push(typescript({
|
|
1933
1948
|
...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
|
|
@@ -2007,20 +2022,23 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2007
2022
|
));
|
|
2008
2023
|
}
|
|
2009
2024
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2010
|
-
if (key in options)
|
|
2025
|
+
if (key in options) {
|
|
2011
2026
|
acc[key] = options[key];
|
|
2027
|
+
}
|
|
2012
2028
|
return acc;
|
|
2013
2029
|
}, {});
|
|
2014
|
-
if (Object.keys(fusedConfig).length)
|
|
2030
|
+
if (Object.keys(fusedConfig).length) {
|
|
2015
2031
|
configs.push([fusedConfig]);
|
|
2016
|
-
|
|
2017
|
-
|
|
2032
|
+
}
|
|
2033
|
+
let composer = new FlatConfigComposer();
|
|
2034
|
+
composer = composer.append(
|
|
2018
2035
|
...configs,
|
|
2019
2036
|
...userConfigs
|
|
2020
2037
|
);
|
|
2021
|
-
if (autoRenamePlugins)
|
|
2022
|
-
|
|
2023
|
-
|
|
2038
|
+
if (autoRenamePlugins) {
|
|
2039
|
+
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2040
|
+
}
|
|
2041
|
+
return composer;
|
|
2024
2042
|
}
|
|
2025
2043
|
|
|
2026
2044
|
// src/index.ts
|
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.4.0",
|
|
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/)",
|
|
@@ -65,26 +65,26 @@
|
|
|
65
65
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
66
66
|
"@antfu/install-pkg": "^0.3.2",
|
|
67
67
|
"@stylistic/eslint-plugin": "1.7.0",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
69
|
-
"@typescript-eslint/parser": "^7.
|
|
70
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
71
|
-
"eslint-flat-config-utils": "^0.2.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
69
|
+
"@typescript-eslint/parser": "^7.6.0",
|
|
70
|
+
"eslint-config-flat-gitignore": "^0.1.5",
|
|
71
|
+
"eslint-flat-config-utils": "^0.2.3",
|
|
72
72
|
"eslint-merge-processors": "^0.1.0",
|
|
73
73
|
"eslint-parser-plain": "^0.1.0",
|
|
74
74
|
"eslint-plugin-antfu": "^2.1.2",
|
|
75
75
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
76
76
|
"eslint-plugin-import-x": "^0.5.0",
|
|
77
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
78
|
-
"eslint-plugin-jsonc": "^2.15.
|
|
77
|
+
"eslint-plugin-jsdoc": "^48.2.3",
|
|
78
|
+
"eslint-plugin-jsonc": "^2.15.1",
|
|
79
79
|
"eslint-plugin-markdown": "^4.0.1",
|
|
80
|
-
"eslint-plugin-n": "^
|
|
80
|
+
"eslint-plugin-n": "^17.2.1",
|
|
81
81
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
82
|
-
"eslint-plugin-perfectionist": "^2.
|
|
82
|
+
"eslint-plugin-perfectionist": "^2.9.0",
|
|
83
83
|
"eslint-plugin-toml": "^0.11.0",
|
|
84
|
-
"eslint-plugin-unicorn": "^
|
|
84
|
+
"eslint-plugin-unicorn": "^52.0.0",
|
|
85
85
|
"eslint-plugin-unused-imports": "^3.1.0",
|
|
86
|
-
"eslint-plugin-vitest": "^0.
|
|
87
|
-
"eslint-plugin-vue": "^9.
|
|
86
|
+
"eslint-plugin-vitest": "^0.5.3",
|
|
87
|
+
"eslint-plugin-vue": "^9.25.0",
|
|
88
88
|
"eslint-plugin-yml": "^1.14.0",
|
|
89
89
|
"eslint-processor-vue-blocks": "^0.1.1",
|
|
90
90
|
"globals": "^15.0.0",
|
|
@@ -97,23 +97,23 @@
|
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@antfu/ni": "^0.21.12",
|
|
100
|
-
"@eslint-types/jsdoc": "48.2.
|
|
101
|
-
"@eslint-types/typescript-eslint": "^7.
|
|
102
|
-
"@eslint-types/unicorn": "^
|
|
103
|
-
"@eslint/config-inspector": "^0.
|
|
100
|
+
"@eslint-types/jsdoc": "48.2.2",
|
|
101
|
+
"@eslint-types/typescript-eslint": "^7.5.0",
|
|
102
|
+
"@eslint-types/unicorn": "^52.0.0",
|
|
103
|
+
"@eslint/config-inspector": "^0.4.6",
|
|
104
104
|
"@lincy/eslint-config": "workspace:*",
|
|
105
105
|
"@stylistic/eslint-plugin-migrate": "^1.7.0",
|
|
106
|
-
"@types/eslint": "^8.56.
|
|
107
|
-
"@types/node": "^20.12.
|
|
106
|
+
"@types/eslint": "^8.56.9",
|
|
107
|
+
"@types/node": "^20.12.7",
|
|
108
108
|
"@types/prompts": "^2.4.9",
|
|
109
|
-
"@unocss/eslint-plugin": "^0.
|
|
109
|
+
"@unocss/eslint-plugin": "^0.59.2",
|
|
110
110
|
"bumpp": "^9.4.0",
|
|
111
111
|
"eslint": "^8.57.0",
|
|
112
112
|
"eslint-plugin-format": "^0.1.0",
|
|
113
113
|
"eslint-plugin-react": "^7.34.1",
|
|
114
114
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
115
115
|
"eslint-plugin-react-refresh": "^0.4.6",
|
|
116
|
-
"eslint-typegen": "^0.2.
|
|
116
|
+
"eslint-typegen": "^0.2.2",
|
|
117
117
|
"esno": "^4.7.0",
|
|
118
118
|
"lint-staged": "^15.2.2",
|
|
119
119
|
"prettier": "^3.2.5",
|
|
@@ -122,9 +122,9 @@
|
|
|
122
122
|
"simple-open-url": "^3.0.1",
|
|
123
123
|
"sucrase": "^3.35.0",
|
|
124
124
|
"tsup": "^8.0.2",
|
|
125
|
-
"typescript": "^5.4.
|
|
125
|
+
"typescript": "^5.4.5",
|
|
126
126
|
"unbuild": "^2.0.0",
|
|
127
|
-
"vitest": "^1.
|
|
127
|
+
"vitest": "^1.5.0",
|
|
128
128
|
"vue": "^3.4.21"
|
|
129
129
|
},
|
|
130
130
|
"pnpm": {
|