@lincy/eslint-config 5.2.7 → 5.3.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 +77 -10
- package/dist/index.cjs +123 -97
- package/dist/index.d.cts +718 -600
- package/dist/index.d.ts +718 -600
- package/dist/index.js +121 -97
- package/package.json +25 -23
package/dist/index.js
CHANGED
|
@@ -242,7 +242,8 @@ async function ensurePackages(packages) {
|
|
|
242
242
|
return;
|
|
243
243
|
const p = await import("@clack/prompts");
|
|
244
244
|
const result = await p.confirm({
|
|
245
|
-
message: `${nonExistingPackages.length === 1 ?
|
|
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
247
|
});
|
|
247
248
|
if (result)
|
|
248
249
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
@@ -307,7 +308,6 @@ async function stylistic(options = {}) {
|
|
|
307
308
|
},
|
|
308
309
|
// 覆盖`stylistic`默认规则
|
|
309
310
|
"style/brace-style": ["error", "stroustrup"],
|
|
310
|
-
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
311
311
|
"style/multiline-ternary": ["error", "never"],
|
|
312
312
|
...overrides
|
|
313
313
|
}
|
|
@@ -330,13 +330,14 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
330
330
|
const defaultIndent = 4;
|
|
331
331
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
332
332
|
if (options === true) {
|
|
333
|
+
const isPrettierPluginXmlInScope2 = isPackageInScope("@prettier/plugin-xml");
|
|
333
334
|
options = {
|
|
334
335
|
css: false,
|
|
335
336
|
graphql: true,
|
|
336
337
|
html: true,
|
|
337
338
|
markdown: true,
|
|
338
|
-
svg:
|
|
339
|
-
xml:
|
|
339
|
+
svg: isPrettierPluginXmlInScope2,
|
|
340
|
+
xml: isPrettierPluginXmlInScope2
|
|
340
341
|
};
|
|
341
342
|
} else {
|
|
342
343
|
options = {
|
|
@@ -389,7 +390,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
389
390
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
390
391
|
const configs2 = [
|
|
391
392
|
{
|
|
392
|
-
name: "eslint/
|
|
393
|
+
name: "eslint/formatter/setup",
|
|
393
394
|
plugins: {
|
|
394
395
|
format: pluginFormat
|
|
395
396
|
}
|
|
@@ -402,12 +403,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
402
403
|
languageOptions: {
|
|
403
404
|
parser: parserPlain
|
|
404
405
|
},
|
|
405
|
-
name: "eslint/
|
|
406
|
+
name: "eslint/formatter/css",
|
|
406
407
|
rules: {
|
|
407
408
|
"format/prettier": [
|
|
408
409
|
"error",
|
|
409
410
|
mergePrettierOptions(prettierOptions, {
|
|
410
|
-
...prettierOptions,
|
|
411
411
|
parser: "css"
|
|
412
412
|
})
|
|
413
413
|
]
|
|
@@ -418,12 +418,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
418
418
|
languageOptions: {
|
|
419
419
|
parser: parserPlain
|
|
420
420
|
},
|
|
421
|
-
name: "eslint/
|
|
421
|
+
name: "eslint/formatter/scss",
|
|
422
422
|
rules: {
|
|
423
423
|
"format/prettier": [
|
|
424
424
|
"error",
|
|
425
425
|
mergePrettierOptions(prettierOptions, {
|
|
426
|
-
...prettierOptions,
|
|
427
426
|
parser: "scss"
|
|
428
427
|
})
|
|
429
428
|
]
|
|
@@ -434,12 +433,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
434
433
|
languageOptions: {
|
|
435
434
|
parser: parserPlain
|
|
436
435
|
},
|
|
437
|
-
name: "eslint/
|
|
436
|
+
name: "eslint/formatter/less",
|
|
438
437
|
rules: {
|
|
439
438
|
"format/prettier": [
|
|
440
439
|
"error",
|
|
441
440
|
mergePrettierOptions(prettierOptions, {
|
|
442
|
-
...prettierOptions,
|
|
443
441
|
parser: "less"
|
|
444
442
|
})
|
|
445
443
|
]
|
|
@@ -453,12 +451,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
453
451
|
languageOptions: {
|
|
454
452
|
parser: parserPlain
|
|
455
453
|
},
|
|
456
|
-
name: "eslint/
|
|
454
|
+
name: "eslint/formatter/html",
|
|
457
455
|
rules: {
|
|
458
456
|
"format/prettier": [
|
|
459
457
|
"error",
|
|
460
458
|
mergePrettierOptions(prettierOptions, {
|
|
461
|
-
...prettierOptions,
|
|
462
459
|
parser: "html"
|
|
463
460
|
})
|
|
464
461
|
]
|
|
@@ -491,7 +488,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
491
488
|
languageOptions: {
|
|
492
489
|
parser: parserPlain
|
|
493
490
|
},
|
|
494
|
-
name: "eslint/
|
|
491
|
+
name: "eslint/formatter/svg",
|
|
495
492
|
rules: {
|
|
496
493
|
"format/prettier": [
|
|
497
494
|
"error",
|
|
@@ -509,10 +506,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
509
506
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
510
507
|
configs2.push({
|
|
511
508
|
files: [GLOB_MARKDOWN],
|
|
509
|
+
ignores: [],
|
|
512
510
|
languageOptions: {
|
|
513
511
|
parser: parserPlain
|
|
514
512
|
},
|
|
515
|
-
name: "eslint/
|
|
513
|
+
name: "eslint/formatter/markdown",
|
|
516
514
|
rules: {
|
|
517
515
|
[`format/${formater}`]: [
|
|
518
516
|
"error",
|
|
@@ -533,7 +531,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
533
531
|
languageOptions: {
|
|
534
532
|
parser: parserPlain
|
|
535
533
|
},
|
|
536
|
-
name: "eslint/
|
|
534
|
+
name: "eslint/formatter/graphql",
|
|
537
535
|
rules: {
|
|
538
536
|
"format/prettier": [
|
|
539
537
|
"error",
|
|
@@ -1077,7 +1075,7 @@ async function perfectionist(options = {}) {
|
|
|
1077
1075
|
"object",
|
|
1078
1076
|
"unknown"
|
|
1079
1077
|
],
|
|
1080
|
-
internalPattern: ["
|
|
1078
|
+
internalPattern: ["^~/.*", "^@/.*"],
|
|
1081
1079
|
newlinesBetween: "ignore",
|
|
1082
1080
|
order: "asc",
|
|
1083
1081
|
type: "natural"
|
|
@@ -1097,13 +1095,18 @@ var ReactRefreshAllowConstantExportPackages = [
|
|
|
1097
1095
|
];
|
|
1098
1096
|
async function react(options = {}) {
|
|
1099
1097
|
const {
|
|
1100
|
-
files = [
|
|
1101
|
-
|
|
1098
|
+
files = [GLOB_SRC],
|
|
1099
|
+
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
1100
|
+
ignoresTypeAware = [
|
|
1101
|
+
`${GLOB_MARKDOWN}/**`
|
|
1102
|
+
],
|
|
1102
1103
|
overrides = {},
|
|
1103
|
-
|
|
1104
|
+
tsconfigPath
|
|
1104
1105
|
} = options;
|
|
1105
|
-
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1106
1106
|
const isTypeAware = !!tsconfigPath;
|
|
1107
|
+
const typeAwareRules = {
|
|
1108
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1109
|
+
};
|
|
1107
1110
|
await ensurePackages([
|
|
1108
1111
|
"@eslint-react/eslint-plugin",
|
|
1109
1112
|
"eslint-plugin-react-hooks",
|
|
@@ -1112,15 +1115,13 @@ async function react(options = {}) {
|
|
|
1112
1115
|
const [
|
|
1113
1116
|
pluginReact,
|
|
1114
1117
|
pluginReactHooks,
|
|
1115
|
-
pluginReactRefresh
|
|
1116
|
-
parserTs
|
|
1118
|
+
pluginReactRefresh
|
|
1117
1119
|
] = await Promise.all([
|
|
1118
1120
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1119
1121
|
// @ts-expect-error missing types
|
|
1120
1122
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1121
1123
|
// @ts-expect-error missing types
|
|
1122
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1123
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
1124
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1124
1125
|
]);
|
|
1125
1126
|
const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1126
1127
|
(i) => isPackageExists2(i)
|
|
@@ -1141,13 +1142,12 @@ async function react(options = {}) {
|
|
|
1141
1142
|
{
|
|
1142
1143
|
files,
|
|
1143
1144
|
languageOptions: {
|
|
1144
|
-
parser: parserTs,
|
|
1145
1145
|
parserOptions: {
|
|
1146
1146
|
ecmaFeatures: {
|
|
1147
|
-
jsx:
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1147
|
+
jsx: true
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
sourceType: "module"
|
|
1151
1151
|
},
|
|
1152
1152
|
name: "eslint/react/rules",
|
|
1153
1153
|
rules: {
|
|
@@ -1207,18 +1207,18 @@ async function react(options = {}) {
|
|
|
1207
1207
|
"react/prefer-destructuring-assignment": "warn",
|
|
1208
1208
|
"react/prefer-shorthand-boolean": "warn",
|
|
1209
1209
|
"react/prefer-shorthand-fragment": "warn",
|
|
1210
|
-
...isTypeAware ? {
|
|
1211
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1212
|
-
} : {},
|
|
1213
1210
|
// overrides
|
|
1214
1211
|
...overrides
|
|
1215
|
-
},
|
|
1216
|
-
settings: {
|
|
1217
|
-
react: {
|
|
1218
|
-
version
|
|
1219
|
-
}
|
|
1220
1212
|
}
|
|
1221
|
-
}
|
|
1213
|
+
},
|
|
1214
|
+
...isTypeAware ? [{
|
|
1215
|
+
files: filesTypeAware,
|
|
1216
|
+
ignores: ignoresTypeAware,
|
|
1217
|
+
name: "eslint/react/type-aware-rules",
|
|
1218
|
+
rules: {
|
|
1219
|
+
...typeAwareRules
|
|
1220
|
+
}
|
|
1221
|
+
}] : []
|
|
1222
1222
|
];
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
@@ -1852,6 +1852,8 @@ async function vue(options = {}) {
|
|
|
1852
1852
|
]);
|
|
1853
1853
|
return [
|
|
1854
1854
|
{
|
|
1855
|
+
// This allows Vue plugin to work with auto imports
|
|
1856
|
+
// https://github.com/vuejs/eslint-plugin-vue/pull/2422
|
|
1855
1857
|
languageOptions: {
|
|
1856
1858
|
globals: {
|
|
1857
1859
|
computed: "readonly",
|
|
@@ -1894,21 +1896,21 @@ async function vue(options = {}) {
|
|
|
1894
1896
|
processorVueBlocks({
|
|
1895
1897
|
...sfcBlocks,
|
|
1896
1898
|
blocks: {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
+
styles: true,
|
|
1900
|
+
...sfcBlocks.blocks
|
|
1899
1901
|
}
|
|
1900
1902
|
})
|
|
1901
1903
|
]),
|
|
1902
1904
|
rules: {
|
|
1903
1905
|
...pluginVue.configs.base.rules,
|
|
1904
|
-
...vueVersion === "
|
|
1905
|
-
...pluginVue.configs["vue3-essential"].rules,
|
|
1906
|
-
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1907
|
-
...pluginVue.configs["vue3-recommended"].rules
|
|
1908
|
-
} : {
|
|
1906
|
+
...vueVersion === "2" ? {
|
|
1909
1907
|
...pluginVue.configs.essential.rules,
|
|
1910
1908
|
...pluginVue.configs["strongly-recommended"].rules,
|
|
1911
1909
|
...pluginVue.configs.recommended.rules
|
|
1910
|
+
} : {
|
|
1911
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1912
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1913
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
1912
1914
|
},
|
|
1913
1915
|
"antfu/no-top-level-await": "off",
|
|
1914
1916
|
"node/prefer-global/process": "off",
|
|
@@ -1973,12 +1975,17 @@ async function vue(options = {}) {
|
|
|
1973
1975
|
"vue/no-useless-v-bind": "error",
|
|
1974
1976
|
"vue/no-v-html": "off",
|
|
1975
1977
|
"vue/no-v-text-v-html-on-component": "off",
|
|
1976
|
-
"vue/object-shorthand": [
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1978
|
+
"vue/object-shorthand": [
|
|
1979
|
+
"error",
|
|
1980
|
+
"always",
|
|
1981
|
+
{
|
|
1982
|
+
avoidQuotes: true,
|
|
1983
|
+
ignoreConstructors: false
|
|
1984
|
+
}
|
|
1985
|
+
],
|
|
1980
1986
|
"vue/prefer-separate-static-class": "error",
|
|
1981
1987
|
"vue/prefer-template": "error",
|
|
1988
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1982
1989
|
"vue/require-default-prop": "off",
|
|
1983
1990
|
"vue/require-prop-types": "off",
|
|
1984
1991
|
"vue/singleline-html-element-content-newline": "off",
|
|
@@ -1988,12 +1995,17 @@ async function vue(options = {}) {
|
|
|
1988
1995
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1989
1996
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1990
1997
|
"vue/block-spacing": ["error", "always"],
|
|
1991
|
-
"vue/block-tag-newline": ["error", {
|
|
1998
|
+
"vue/block-tag-newline": ["error", {
|
|
1999
|
+
multiline: "always",
|
|
2000
|
+
singleline: "always"
|
|
2001
|
+
}],
|
|
1992
2002
|
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: false }],
|
|
1993
2003
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1994
2004
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1995
2005
|
"vue/comma-style": ["error", "last"],
|
|
1996
|
-
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2006
|
+
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2007
|
+
exceptions: ["-"]
|
|
2008
|
+
}],
|
|
1997
2009
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1998
2010
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1999
2011
|
"vue/object-curly-newline": "off",
|
|
@@ -2018,6 +2030,9 @@ async function yaml(options = {}) {
|
|
|
2018
2030
|
overrides = {},
|
|
2019
2031
|
stylistic: stylistic2 = true
|
|
2020
2032
|
} = options;
|
|
2033
|
+
const {
|
|
2034
|
+
quotes = "single"
|
|
2035
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
2021
2036
|
const [
|
|
2022
2037
|
pluginYaml,
|
|
2023
2038
|
parserYaml
|
|
@@ -2057,7 +2072,7 @@ async function yaml(options = {}) {
|
|
|
2057
2072
|
"yaml/indent": ["error", 2],
|
|
2058
2073
|
"yaml/key-spacing": "error",
|
|
2059
2074
|
"yaml/no-tab-indent": "error",
|
|
2060
|
-
"yaml/quotes": ["error", { avoidEscape:
|
|
2075
|
+
"yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
|
|
2061
2076
|
"yaml/spaced-comment": "error"
|
|
2062
2077
|
} : {},
|
|
2063
2078
|
...overrides
|
|
@@ -2094,10 +2109,6 @@ var defaultPluginRenaming = {
|
|
|
2094
2109
|
"vitest": "test",
|
|
2095
2110
|
"yml": "yaml"
|
|
2096
2111
|
};
|
|
2097
|
-
var ReactPackages = [
|
|
2098
|
-
"react",
|
|
2099
|
-
"next"
|
|
2100
|
-
];
|
|
2101
2112
|
function lincy(options = {}, ...userConfigs) {
|
|
2102
2113
|
const {
|
|
2103
2114
|
autoRenamePlugins = true,
|
|
@@ -2106,7 +2117,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2106
2117
|
ignores: ignoresList = [],
|
|
2107
2118
|
jsx: enableJsx = true,
|
|
2108
2119
|
overrides = {},
|
|
2109
|
-
react: enableReact =
|
|
2120
|
+
react: enableReact = false,
|
|
2110
2121
|
regexp: enableRegexp = true,
|
|
2111
2122
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
2112
2123
|
unicorn: enableUnicorn = true,
|
|
@@ -2120,12 +2131,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2120
2131
|
console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2121
2132
|
}
|
|
2122
2133
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
if (!("jsx" in stylisticOptions)) {
|
|
2126
|
-
stylisticOptions.jsx = enableJsx;
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2134
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2135
|
+
stylisticOptions.jsx = enableJsx;
|
|
2129
2136
|
const configs2 = [];
|
|
2130
2137
|
if (enableGitignore) {
|
|
2131
2138
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -2140,6 +2147,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2140
2147
|
})]));
|
|
2141
2148
|
}
|
|
2142
2149
|
}
|
|
2150
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2151
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2143
2152
|
configs2.push(
|
|
2144
2153
|
ignores({
|
|
2145
2154
|
ignores: [
|
|
@@ -2149,7 +2158,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2149
2158
|
}),
|
|
2150
2159
|
javascript({
|
|
2151
2160
|
isInEditor,
|
|
2152
|
-
overrides:
|
|
2161
|
+
overrides: getOverrides(options, "javascript")
|
|
2153
2162
|
}),
|
|
2154
2163
|
comments({
|
|
2155
2164
|
overrides: overrides.comments
|
|
@@ -2179,63 +2188,64 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2179
2188
|
if (enableVue) {
|
|
2180
2189
|
componentExts.push("vue");
|
|
2181
2190
|
}
|
|
2191
|
+
if (enableJsx) {
|
|
2192
|
+
configs2.push(jsx());
|
|
2193
|
+
}
|
|
2182
2194
|
if (enableTypeScript) {
|
|
2183
2195
|
configs2.push(typescript({
|
|
2184
|
-
...
|
|
2196
|
+
...typescriptOptions,
|
|
2185
2197
|
componentExts,
|
|
2186
|
-
overrides:
|
|
2198
|
+
overrides: getOverrides(options, "typescript"),
|
|
2187
2199
|
tsconfigPath,
|
|
2188
2200
|
type: options.type
|
|
2189
2201
|
}));
|
|
2190
2202
|
}
|
|
2191
|
-
if (enableJsx) {
|
|
2192
|
-
configs2.push(jsx());
|
|
2193
|
-
}
|
|
2194
2203
|
if (stylisticOptions) {
|
|
2195
2204
|
configs2.push(stylistic({
|
|
2196
|
-
overrides:
|
|
2205
|
+
overrides: getOverrides(options, "stylistic"),
|
|
2197
2206
|
stylistic: stylisticOptions
|
|
2198
2207
|
}));
|
|
2199
2208
|
}
|
|
2200
2209
|
if (enableRegexp) {
|
|
2201
2210
|
configs2.push(regexp({
|
|
2202
|
-
...
|
|
2203
|
-
|
|
2211
|
+
...resolveSubOptions(options, "regexp"),
|
|
2212
|
+
...getOverrides(options, "regexp")
|
|
2204
2213
|
}));
|
|
2205
2214
|
}
|
|
2206
2215
|
if (options.test ?? true) {
|
|
2207
2216
|
configs2.push(test({
|
|
2208
|
-
...
|
|
2217
|
+
...resolveSubOptions(options, "test"),
|
|
2209
2218
|
isInEditor,
|
|
2210
|
-
overrides:
|
|
2219
|
+
overrides: getOverrides(options, "test")
|
|
2211
2220
|
}));
|
|
2212
2221
|
}
|
|
2213
2222
|
if (enableVue) {
|
|
2214
2223
|
configs2.push(vue({
|
|
2215
|
-
...
|
|
2216
|
-
overrides:
|
|
2224
|
+
...resolveSubOptions(options, "vue"),
|
|
2225
|
+
overrides: getOverrides(options, "vue"),
|
|
2217
2226
|
stylistic: stylisticOptions,
|
|
2218
2227
|
typescript: !!enableTypeScript
|
|
2219
2228
|
}));
|
|
2220
2229
|
}
|
|
2221
2230
|
if (enableReact) {
|
|
2222
2231
|
configs2.push(react({
|
|
2223
|
-
|
|
2224
|
-
...
|
|
2225
|
-
overrides:
|
|
2232
|
+
...typescriptOptions,
|
|
2233
|
+
...resolveSubOptions(options, "react"),
|
|
2234
|
+
overrides: getOverrides(options, "react"),
|
|
2235
|
+
tsconfigPath
|
|
2226
2236
|
}));
|
|
2227
2237
|
}
|
|
2228
2238
|
if (enableUnoCSS) {
|
|
2229
2239
|
configs2.push(unocss({
|
|
2230
|
-
...
|
|
2231
|
-
overrides:
|
|
2240
|
+
...resolveSubOptions(options, "unocss"),
|
|
2241
|
+
overrides: getOverrides(options, "unocss")
|
|
2232
2242
|
}));
|
|
2233
2243
|
}
|
|
2234
2244
|
if (options.jsonc ?? true) {
|
|
2235
2245
|
configs2.push(
|
|
2236
2246
|
jsonc({
|
|
2237
|
-
...
|
|
2238
|
-
overrides:
|
|
2247
|
+
...resolveSubOptions(options, "jsonc"),
|
|
2248
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2239
2249
|
stylistic: stylisticOptions
|
|
2240
2250
|
}),
|
|
2241
2251
|
sortPackageJson(),
|
|
@@ -2244,23 +2254,27 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2244
2254
|
}
|
|
2245
2255
|
if (options.yaml ?? true) {
|
|
2246
2256
|
configs2.push(yaml({
|
|
2247
|
-
...
|
|
2248
|
-
overrides:
|
|
2257
|
+
...resolveSubOptions(options, "yaml"),
|
|
2258
|
+
overrides: getOverrides(options, "yaml"),
|
|
2249
2259
|
stylistic: stylisticOptions
|
|
2250
2260
|
}));
|
|
2251
2261
|
}
|
|
2252
|
-
if (options.toml) {
|
|
2262
|
+
if (options.toml ?? true) {
|
|
2253
2263
|
configs2.push(toml({
|
|
2254
|
-
overrides:
|
|
2264
|
+
overrides: getOverrides(options, "toml"),
|
|
2255
2265
|
stylistic: stylisticOptions
|
|
2256
2266
|
}));
|
|
2257
2267
|
}
|
|
2258
2268
|
if (options.markdown ?? true) {
|
|
2259
|
-
configs2.push(
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2269
|
+
configs2.push(
|
|
2270
|
+
markdown(
|
|
2271
|
+
{
|
|
2272
|
+
...resolveSubOptions(options, "markdown"),
|
|
2273
|
+
componentExts,
|
|
2274
|
+
overrides: getOverrides(options, "markdown")
|
|
2275
|
+
}
|
|
2276
|
+
)
|
|
2277
|
+
);
|
|
2264
2278
|
}
|
|
2265
2279
|
if (options.formatters) {
|
|
2266
2280
|
configs2.push(formatters(
|
|
@@ -2275,14 +2289,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2275
2289
|
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");
|
|
2276
2290
|
}
|
|
2277
2291
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2278
|
-
if (key in options)
|
|
2292
|
+
if (key in options)
|
|
2279
2293
|
acc[key] = options[key];
|
|
2280
|
-
}
|
|
2281
2294
|
return acc;
|
|
2282
2295
|
}, {});
|
|
2283
|
-
if (Object.keys(fusedConfig).length)
|
|
2296
|
+
if (Object.keys(fusedConfig).length)
|
|
2284
2297
|
configs2.push([fusedConfig]);
|
|
2285
|
-
}
|
|
2286
2298
|
let composer = new FlatConfigComposer();
|
|
2287
2299
|
composer = composer.append(
|
|
2288
2300
|
...configs2,
|
|
@@ -2293,6 +2305,16 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2293
2305
|
}
|
|
2294
2306
|
return composer;
|
|
2295
2307
|
}
|
|
2308
|
+
function resolveSubOptions(options, key) {
|
|
2309
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
2310
|
+
}
|
|
2311
|
+
function getOverrides(options, key) {
|
|
2312
|
+
const sub = resolveSubOptions(options, key);
|
|
2313
|
+
return {
|
|
2314
|
+
...options.overrides?.[key],
|
|
2315
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2296
2318
|
|
|
2297
2319
|
// src/index.ts
|
|
2298
2320
|
var src_default = lincy;
|
|
@@ -2333,6 +2355,7 @@ export {
|
|
|
2333
2355
|
disables,
|
|
2334
2356
|
ensurePackages,
|
|
2335
2357
|
formatters,
|
|
2358
|
+
getOverrides,
|
|
2336
2359
|
ignores,
|
|
2337
2360
|
imports,
|
|
2338
2361
|
interopDefault,
|
|
@@ -2352,6 +2375,7 @@ export {
|
|
|
2352
2375
|
regexp,
|
|
2353
2376
|
renamePluginInConfigs,
|
|
2354
2377
|
renameRules,
|
|
2378
|
+
resolveSubOptions,
|
|
2355
2379
|
sortPackageJson,
|
|
2356
2380
|
sortTsconfig,
|
|
2357
2381
|
stylistic,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincy/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
5
|
-
"packageManager": "pnpm@9.
|
|
4
|
+
"version": "5.3.0",
|
|
5
|
+
"packageManager": "pnpm@9.14.2",
|
|
6
6
|
"description": "LinCenYing's ESLint config",
|
|
7
7
|
"author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
|
|
8
8
|
"license": "MIT",
|
|
@@ -68,60 +68,62 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
70
70
|
"@antfu/install-pkg": "^0.4.1",
|
|
71
|
-
"@clack/prompts": "^0.
|
|
71
|
+
"@clack/prompts": "^0.8.2",
|
|
72
72
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
73
73
|
"@eslint/markdown": "^6.2.1",
|
|
74
74
|
"@stylistic/eslint-plugin": "2.10.1",
|
|
75
75
|
"@typescript-eslint/eslint-plugin": "8.13.0",
|
|
76
76
|
"@typescript-eslint/parser": "8.13.0",
|
|
77
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
77
|
+
"@vitest/eslint-plugin": "^1.1.10",
|
|
78
78
|
"eslint-config-flat-gitignore": "^0.3.0",
|
|
79
79
|
"eslint-flat-config-utils": "^0.4.0",
|
|
80
80
|
"eslint-merge-processors": "^0.1.0",
|
|
81
81
|
"eslint-parser-plain": "^0.1.0",
|
|
82
82
|
"eslint-plugin-antfu": "^2.7.0",
|
|
83
|
-
"eslint-plugin-import-x": "^4.4.
|
|
84
|
-
"eslint-plugin-jsdoc": "^50.
|
|
85
|
-
"eslint-plugin-jsonc": "^2.
|
|
86
|
-
"eslint-plugin-n": "^17.
|
|
83
|
+
"eslint-plugin-import-x": "^4.4.3",
|
|
84
|
+
"eslint-plugin-jsdoc": "^50.5.0",
|
|
85
|
+
"eslint-plugin-jsonc": "^2.18.2",
|
|
86
|
+
"eslint-plugin-n": "^17.14.0",
|
|
87
87
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
88
|
-
"eslint-plugin-perfectionist": "^
|
|
89
|
-
"eslint-plugin-regexp": "^2.
|
|
88
|
+
"eslint-plugin-perfectionist": "^4.0.3",
|
|
89
|
+
"eslint-plugin-regexp": "^2.7.0",
|
|
90
90
|
"eslint-plugin-toml": "^0.11.1",
|
|
91
|
-
"eslint-plugin-unicorn": "^56.0.
|
|
91
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
92
92
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
93
|
-
"eslint-plugin-vue": "^9.
|
|
93
|
+
"eslint-plugin-vue": "^9.31.0",
|
|
94
94
|
"eslint-plugin-yml": "^1.15.0",
|
|
95
95
|
"eslint-processor-vue-blocks": "^0.1.2",
|
|
96
96
|
"globals": "^15.12.0",
|
|
97
97
|
"jsonc-eslint-parser": "^2.4.0",
|
|
98
|
-
"local-pkg": "^0.5.
|
|
98
|
+
"local-pkg": "^0.5.1",
|
|
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.
|
|
106
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
105
|
+
"@antfu/ni": "^0.23.1",
|
|
106
|
+
"@eslint-react/eslint-plugin": "^1.17.1",
|
|
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
110
|
"@eslint/config-inspector": "^0.5.6",
|
|
111
111
|
"@lincy/eslint-config": "workspace:*",
|
|
112
112
|
"@prettier/plugin-xml": "^3.4.1",
|
|
113
|
-
"@stylistic/eslint-plugin-migrate": "^2.
|
|
114
|
-
"@types/
|
|
113
|
+
"@stylistic/eslint-plugin-migrate": "^2.11.0",
|
|
114
|
+
"@types/fs-extra": "^11.0.4",
|
|
115
|
+
"@types/node": "^22.9.3",
|
|
115
116
|
"@types/prompts": "^2.4.9",
|
|
116
|
-
"@unocss/eslint-plugin": "^0.64.
|
|
117
|
+
"@unocss/eslint-plugin": "^0.64.1",
|
|
117
118
|
"bumpp": "^9.8.1",
|
|
118
|
-
"eslint": "^9.
|
|
119
|
+
"eslint": "^9.15.0",
|
|
119
120
|
"eslint-plugin-format": "^0.1.2",
|
|
120
121
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
121
122
|
"eslint-plugin-react-refresh": "^0.4.14",
|
|
122
123
|
"eslint-ts-patch": "9.8.0-1",
|
|
123
124
|
"eslint-typegen": "^0.3.2",
|
|
124
125
|
"esno": "^4.8.0",
|
|
126
|
+
"fs-extra": "^11.2.0",
|
|
125
127
|
"lint-staged": "^15.2.10",
|
|
126
128
|
"prettier": "^3.3.3",
|
|
127
129
|
"react": "^18.3.1",
|
|
@@ -132,8 +134,8 @@
|
|
|
132
134
|
"tsup": "^8.3.5",
|
|
133
135
|
"typescript": "^5.6.3",
|
|
134
136
|
"unbuild": "^2.0.0",
|
|
135
|
-
"vitest": "^2.1.
|
|
136
|
-
"vue": "^3.5.
|
|
137
|
+
"vitest": "^2.1.5",
|
|
138
|
+
"vue": "^3.5.13"
|
|
137
139
|
},
|
|
138
140
|
"pnpm": {
|
|
139
141
|
"peerDependencyRules": {
|
|
@@ -144,8 +146,8 @@
|
|
|
144
146
|
},
|
|
145
147
|
"resolutions": {
|
|
146
148
|
"@eslint-community/eslint-utils": "^4.4.1",
|
|
147
|
-
"@typescript-eslint/utils": "^8.
|
|
148
|
-
"eslint": "^9.
|
|
149
|
+
"@typescript-eslint/utils": "^8.15.0",
|
|
150
|
+
"eslint": "^9.15.0",
|
|
149
151
|
"tsx": "^4.19.2"
|
|
150
152
|
},
|
|
151
153
|
"simple-git-hooks": {
|