@lincy/eslint-config 5.2.7 → 5.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 +97 -20
- package/dist/index.cjs +124 -99
- package/dist/index.d.cts +788 -605
- package/dist/index.d.ts +788 -605
- package/dist/index.js +121 -98
- package/package.json +37 -35
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,12 @@ 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
|
-
|
|
1122
|
-
interopDefault(import("eslint-plugin-react-refresh")),
|
|
1123
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
1123
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1124
1124
|
]);
|
|
1125
1125
|
const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1126
1126
|
(i) => isPackageExists2(i)
|
|
@@ -1141,13 +1141,12 @@ async function react(options = {}) {
|
|
|
1141
1141
|
{
|
|
1142
1142
|
files,
|
|
1143
1143
|
languageOptions: {
|
|
1144
|
-
parser: parserTs,
|
|
1145
1144
|
parserOptions: {
|
|
1146
1145
|
ecmaFeatures: {
|
|
1147
|
-
jsx:
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1146
|
+
jsx: true
|
|
1147
|
+
}
|
|
1148
|
+
},
|
|
1149
|
+
sourceType: "module"
|
|
1151
1150
|
},
|
|
1152
1151
|
name: "eslint/react/rules",
|
|
1153
1152
|
rules: {
|
|
@@ -1207,18 +1206,18 @@ async function react(options = {}) {
|
|
|
1207
1206
|
"react/prefer-destructuring-assignment": "warn",
|
|
1208
1207
|
"react/prefer-shorthand-boolean": "warn",
|
|
1209
1208
|
"react/prefer-shorthand-fragment": "warn",
|
|
1210
|
-
...isTypeAware ? {
|
|
1211
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1212
|
-
} : {},
|
|
1213
1209
|
// overrides
|
|
1214
1210
|
...overrides
|
|
1215
|
-
},
|
|
1216
|
-
settings: {
|
|
1217
|
-
react: {
|
|
1218
|
-
version
|
|
1219
|
-
}
|
|
1220
1211
|
}
|
|
1221
|
-
}
|
|
1212
|
+
},
|
|
1213
|
+
...isTypeAware ? [{
|
|
1214
|
+
files: filesTypeAware,
|
|
1215
|
+
ignores: ignoresTypeAware,
|
|
1216
|
+
name: "eslint/react/type-aware-rules",
|
|
1217
|
+
rules: {
|
|
1218
|
+
...typeAwareRules
|
|
1219
|
+
}
|
|
1220
|
+
}] : []
|
|
1222
1221
|
];
|
|
1223
1222
|
}
|
|
1224
1223
|
|
|
@@ -1852,6 +1851,8 @@ async function vue(options = {}) {
|
|
|
1852
1851
|
]);
|
|
1853
1852
|
return [
|
|
1854
1853
|
{
|
|
1854
|
+
// This allows Vue plugin to work with auto imports
|
|
1855
|
+
// https://github.com/vuejs/eslint-plugin-vue/pull/2422
|
|
1855
1856
|
languageOptions: {
|
|
1856
1857
|
globals: {
|
|
1857
1858
|
computed: "readonly",
|
|
@@ -1894,21 +1895,21 @@ async function vue(options = {}) {
|
|
|
1894
1895
|
processorVueBlocks({
|
|
1895
1896
|
...sfcBlocks,
|
|
1896
1897
|
blocks: {
|
|
1897
|
-
|
|
1898
|
-
|
|
1898
|
+
styles: true,
|
|
1899
|
+
...sfcBlocks.blocks
|
|
1899
1900
|
}
|
|
1900
1901
|
})
|
|
1901
1902
|
]),
|
|
1902
1903
|
rules: {
|
|
1903
1904
|
...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
|
-
} : {
|
|
1905
|
+
...vueVersion === "2" ? {
|
|
1909
1906
|
...pluginVue.configs.essential.rules,
|
|
1910
1907
|
...pluginVue.configs["strongly-recommended"].rules,
|
|
1911
1908
|
...pluginVue.configs.recommended.rules
|
|
1909
|
+
} : {
|
|
1910
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1911
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1912
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
1912
1913
|
},
|
|
1913
1914
|
"antfu/no-top-level-await": "off",
|
|
1914
1915
|
"node/prefer-global/process": "off",
|
|
@@ -1973,12 +1974,17 @@ async function vue(options = {}) {
|
|
|
1973
1974
|
"vue/no-useless-v-bind": "error",
|
|
1974
1975
|
"vue/no-v-html": "off",
|
|
1975
1976
|
"vue/no-v-text-v-html-on-component": "off",
|
|
1976
|
-
"vue/object-shorthand": [
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1977
|
+
"vue/object-shorthand": [
|
|
1978
|
+
"error",
|
|
1979
|
+
"always",
|
|
1980
|
+
{
|
|
1981
|
+
avoidQuotes: true,
|
|
1982
|
+
ignoreConstructors: false
|
|
1983
|
+
}
|
|
1984
|
+
],
|
|
1980
1985
|
"vue/prefer-separate-static-class": "error",
|
|
1981
1986
|
"vue/prefer-template": "error",
|
|
1987
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1982
1988
|
"vue/require-default-prop": "off",
|
|
1983
1989
|
"vue/require-prop-types": "off",
|
|
1984
1990
|
"vue/singleline-html-element-content-newline": "off",
|
|
@@ -1988,12 +1994,17 @@ async function vue(options = {}) {
|
|
|
1988
1994
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1989
1995
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1990
1996
|
"vue/block-spacing": ["error", "always"],
|
|
1991
|
-
"vue/block-tag-newline": ["error", {
|
|
1997
|
+
"vue/block-tag-newline": ["error", {
|
|
1998
|
+
multiline: "always",
|
|
1999
|
+
singleline: "always"
|
|
2000
|
+
}],
|
|
1992
2001
|
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: false }],
|
|
1993
2002
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1994
2003
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1995
2004
|
"vue/comma-style": ["error", "last"],
|
|
1996
|
-
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2005
|
+
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2006
|
+
exceptions: ["-"]
|
|
2007
|
+
}],
|
|
1997
2008
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1998
2009
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1999
2010
|
"vue/object-curly-newline": "off",
|
|
@@ -2018,6 +2029,9 @@ async function yaml(options = {}) {
|
|
|
2018
2029
|
overrides = {},
|
|
2019
2030
|
stylistic: stylistic2 = true
|
|
2020
2031
|
} = options;
|
|
2032
|
+
const {
|
|
2033
|
+
quotes = "single"
|
|
2034
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
2021
2035
|
const [
|
|
2022
2036
|
pluginYaml,
|
|
2023
2037
|
parserYaml
|
|
@@ -2057,7 +2071,7 @@ async function yaml(options = {}) {
|
|
|
2057
2071
|
"yaml/indent": ["error", 2],
|
|
2058
2072
|
"yaml/key-spacing": "error",
|
|
2059
2073
|
"yaml/no-tab-indent": "error",
|
|
2060
|
-
"yaml/quotes": ["error", { avoidEscape:
|
|
2074
|
+
"yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
|
|
2061
2075
|
"yaml/spaced-comment": "error"
|
|
2062
2076
|
} : {},
|
|
2063
2077
|
...overrides
|
|
@@ -2094,10 +2108,6 @@ var defaultPluginRenaming = {
|
|
|
2094
2108
|
"vitest": "test",
|
|
2095
2109
|
"yml": "yaml"
|
|
2096
2110
|
};
|
|
2097
|
-
var ReactPackages = [
|
|
2098
|
-
"react",
|
|
2099
|
-
"next"
|
|
2100
|
-
];
|
|
2101
2111
|
function lincy(options = {}, ...userConfigs) {
|
|
2102
2112
|
const {
|
|
2103
2113
|
autoRenamePlugins = true,
|
|
@@ -2106,7 +2116,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2106
2116
|
ignores: ignoresList = [],
|
|
2107
2117
|
jsx: enableJsx = true,
|
|
2108
2118
|
overrides = {},
|
|
2109
|
-
react: enableReact =
|
|
2119
|
+
react: enableReact = false,
|
|
2110
2120
|
regexp: enableRegexp = true,
|
|
2111
2121
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
2112
2122
|
unicorn: enableUnicorn = true,
|
|
@@ -2120,12 +2130,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2120
2130
|
console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2121
2131
|
}
|
|
2122
2132
|
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
|
-
}
|
|
2133
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2134
|
+
stylisticOptions.jsx = enableJsx;
|
|
2129
2135
|
const configs2 = [];
|
|
2130
2136
|
if (enableGitignore) {
|
|
2131
2137
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -2140,6 +2146,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2140
2146
|
})]));
|
|
2141
2147
|
}
|
|
2142
2148
|
}
|
|
2149
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2150
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2143
2151
|
configs2.push(
|
|
2144
2152
|
ignores({
|
|
2145
2153
|
ignores: [
|
|
@@ -2149,7 +2157,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2149
2157
|
}),
|
|
2150
2158
|
javascript({
|
|
2151
2159
|
isInEditor,
|
|
2152
|
-
overrides:
|
|
2160
|
+
overrides: getOverrides(options, "javascript")
|
|
2153
2161
|
}),
|
|
2154
2162
|
comments({
|
|
2155
2163
|
overrides: overrides.comments
|
|
@@ -2179,63 +2187,64 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2179
2187
|
if (enableVue) {
|
|
2180
2188
|
componentExts.push("vue");
|
|
2181
2189
|
}
|
|
2190
|
+
if (enableJsx) {
|
|
2191
|
+
configs2.push(jsx());
|
|
2192
|
+
}
|
|
2182
2193
|
if (enableTypeScript) {
|
|
2183
2194
|
configs2.push(typescript({
|
|
2184
|
-
...
|
|
2195
|
+
...typescriptOptions,
|
|
2185
2196
|
componentExts,
|
|
2186
|
-
overrides:
|
|
2197
|
+
overrides: getOverrides(options, "typescript"),
|
|
2187
2198
|
tsconfigPath,
|
|
2188
2199
|
type: options.type
|
|
2189
2200
|
}));
|
|
2190
2201
|
}
|
|
2191
|
-
if (enableJsx) {
|
|
2192
|
-
configs2.push(jsx());
|
|
2193
|
-
}
|
|
2194
2202
|
if (stylisticOptions) {
|
|
2195
2203
|
configs2.push(stylistic({
|
|
2196
|
-
overrides:
|
|
2204
|
+
overrides: getOverrides(options, "stylistic"),
|
|
2197
2205
|
stylistic: stylisticOptions
|
|
2198
2206
|
}));
|
|
2199
2207
|
}
|
|
2200
2208
|
if (enableRegexp) {
|
|
2201
2209
|
configs2.push(regexp({
|
|
2202
|
-
...
|
|
2203
|
-
|
|
2210
|
+
...resolveSubOptions(options, "regexp"),
|
|
2211
|
+
...getOverrides(options, "regexp")
|
|
2204
2212
|
}));
|
|
2205
2213
|
}
|
|
2206
2214
|
if (options.test ?? true) {
|
|
2207
2215
|
configs2.push(test({
|
|
2208
|
-
...
|
|
2216
|
+
...resolveSubOptions(options, "test"),
|
|
2209
2217
|
isInEditor,
|
|
2210
|
-
overrides:
|
|
2218
|
+
overrides: getOverrides(options, "test")
|
|
2211
2219
|
}));
|
|
2212
2220
|
}
|
|
2213
2221
|
if (enableVue) {
|
|
2214
2222
|
configs2.push(vue({
|
|
2215
|
-
...
|
|
2216
|
-
overrides:
|
|
2223
|
+
...resolveSubOptions(options, "vue"),
|
|
2224
|
+
overrides: getOverrides(options, "vue"),
|
|
2217
2225
|
stylistic: stylisticOptions,
|
|
2218
2226
|
typescript: !!enableTypeScript
|
|
2219
2227
|
}));
|
|
2220
2228
|
}
|
|
2221
2229
|
if (enableReact) {
|
|
2222
2230
|
configs2.push(react({
|
|
2223
|
-
|
|
2224
|
-
...
|
|
2225
|
-
overrides:
|
|
2231
|
+
...typescriptOptions,
|
|
2232
|
+
...resolveSubOptions(options, "react"),
|
|
2233
|
+
overrides: getOverrides(options, "react"),
|
|
2234
|
+
tsconfigPath
|
|
2226
2235
|
}));
|
|
2227
2236
|
}
|
|
2228
2237
|
if (enableUnoCSS) {
|
|
2229
2238
|
configs2.push(unocss({
|
|
2230
|
-
...
|
|
2231
|
-
overrides:
|
|
2239
|
+
...resolveSubOptions(options, "unocss"),
|
|
2240
|
+
overrides: getOverrides(options, "unocss")
|
|
2232
2241
|
}));
|
|
2233
2242
|
}
|
|
2234
2243
|
if (options.jsonc ?? true) {
|
|
2235
2244
|
configs2.push(
|
|
2236
2245
|
jsonc({
|
|
2237
|
-
...
|
|
2238
|
-
overrides:
|
|
2246
|
+
...resolveSubOptions(options, "jsonc"),
|
|
2247
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2239
2248
|
stylistic: stylisticOptions
|
|
2240
2249
|
}),
|
|
2241
2250
|
sortPackageJson(),
|
|
@@ -2244,23 +2253,27 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2244
2253
|
}
|
|
2245
2254
|
if (options.yaml ?? true) {
|
|
2246
2255
|
configs2.push(yaml({
|
|
2247
|
-
...
|
|
2248
|
-
overrides:
|
|
2256
|
+
...resolveSubOptions(options, "yaml"),
|
|
2257
|
+
overrides: getOverrides(options, "yaml"),
|
|
2249
2258
|
stylistic: stylisticOptions
|
|
2250
2259
|
}));
|
|
2251
2260
|
}
|
|
2252
|
-
if (options.toml) {
|
|
2261
|
+
if (options.toml ?? true) {
|
|
2253
2262
|
configs2.push(toml({
|
|
2254
|
-
overrides:
|
|
2263
|
+
overrides: getOverrides(options, "toml"),
|
|
2255
2264
|
stylistic: stylisticOptions
|
|
2256
2265
|
}));
|
|
2257
2266
|
}
|
|
2258
2267
|
if (options.markdown ?? true) {
|
|
2259
|
-
configs2.push(
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2268
|
+
configs2.push(
|
|
2269
|
+
markdown(
|
|
2270
|
+
{
|
|
2271
|
+
...resolveSubOptions(options, "markdown"),
|
|
2272
|
+
componentExts,
|
|
2273
|
+
overrides: getOverrides(options, "markdown")
|
|
2274
|
+
}
|
|
2275
|
+
)
|
|
2276
|
+
);
|
|
2264
2277
|
}
|
|
2265
2278
|
if (options.formatters) {
|
|
2266
2279
|
configs2.push(formatters(
|
|
@@ -2275,14 +2288,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2275
2288
|
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
2289
|
}
|
|
2277
2290
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2278
|
-
if (key in options)
|
|
2291
|
+
if (key in options)
|
|
2279
2292
|
acc[key] = options[key];
|
|
2280
|
-
}
|
|
2281
2293
|
return acc;
|
|
2282
2294
|
}, {});
|
|
2283
|
-
if (Object.keys(fusedConfig).length)
|
|
2295
|
+
if (Object.keys(fusedConfig).length)
|
|
2284
2296
|
configs2.push([fusedConfig]);
|
|
2285
|
-
}
|
|
2286
2297
|
let composer = new FlatConfigComposer();
|
|
2287
2298
|
composer = composer.append(
|
|
2288
2299
|
...configs2,
|
|
@@ -2293,6 +2304,16 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2293
2304
|
}
|
|
2294
2305
|
return composer;
|
|
2295
2306
|
}
|
|
2307
|
+
function resolveSubOptions(options, key) {
|
|
2308
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
2309
|
+
}
|
|
2310
|
+
function getOverrides(options, key) {
|
|
2311
|
+
const sub = resolveSubOptions(options, key);
|
|
2312
|
+
return {
|
|
2313
|
+
...options.overrides?.[key],
|
|
2314
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2296
2317
|
|
|
2297
2318
|
// src/index.ts
|
|
2298
2319
|
var src_default = lincy;
|
|
@@ -2333,6 +2354,7 @@ export {
|
|
|
2333
2354
|
disables,
|
|
2334
2355
|
ensurePackages,
|
|
2335
2356
|
formatters,
|
|
2357
|
+
getOverrides,
|
|
2336
2358
|
ignores,
|
|
2337
2359
|
imports,
|
|
2338
2360
|
interopDefault,
|
|
@@ -2352,6 +2374,7 @@ export {
|
|
|
2352
2374
|
regexp,
|
|
2353
2375
|
renamePluginInConfigs,
|
|
2354
2376
|
renameRules,
|
|
2377
|
+
resolveSubOptions,
|
|
2355
2378
|
sortPackageJson,
|
|
2356
2379
|
sortTsconfig,
|
|
2357
2380
|
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.1",
|
|
5
|
+
"packageManager": "pnpm@9.14.4",
|
|
6
6
|
"description": "LinCenYing's ESLint config",
|
|
7
7
|
"author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
|
|
8
8
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"release": "bumpp && npm publish -r --access public",
|
|
32
32
|
"test": "vitest",
|
|
33
33
|
"typegen": "esno scripts/typegen.ts",
|
|
34
|
-
"lint": "pnpm run stub && eslint .",
|
|
34
|
+
"lint": "pnpm run stub && eslint . --flag unstable_ts_config",
|
|
35
35
|
"lint:fix": "eslint . --flag unstable_ts_config --fix",
|
|
36
36
|
"lint:ts": "tsc --noEmit",
|
|
37
37
|
"prepare": "npx simple-git-hooks"
|
|
@@ -67,73 +67,75 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@antfu/eslint-define-config": "1.23.0-2",
|
|
70
|
-
"@antfu/install-pkg": "^0.
|
|
71
|
-
"@clack/prompts": "^0.
|
|
70
|
+
"@antfu/install-pkg": "^0.5.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
|
-
"@stylistic/eslint-plugin": "2.
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
76
|
-
"@typescript-eslint/parser": "8.
|
|
77
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
74
|
+
"@stylistic/eslint-plugin": "2.11.0",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "8.17.0",
|
|
76
|
+
"@typescript-eslint/parser": "8.17.0",
|
|
77
|
+
"@vitest/eslint-plugin": "^1.1.14",
|
|
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.
|
|
84
|
-
"eslint-plugin-jsdoc": "^50.
|
|
85
|
-
"eslint-plugin-jsonc": "^2.
|
|
86
|
-
"eslint-plugin-n": "^17.
|
|
83
|
+
"eslint-plugin-import-x": "^4.5.0",
|
|
84
|
+
"eslint-plugin-jsdoc": "^50.6.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.
|
|
90
|
-
"eslint-plugin-toml": "^0.
|
|
91
|
-
"eslint-plugin-unicorn": "^56.0.
|
|
88
|
+
"eslint-plugin-perfectionist": "^4.1.2",
|
|
89
|
+
"eslint-plugin-regexp": "^2.7.0",
|
|
90
|
+
"eslint-plugin-toml": "^0.12.0",
|
|
91
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
92
92
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
93
|
-
"eslint-plugin-vue": "^9.
|
|
94
|
-
"eslint-plugin-yml": "^1.
|
|
93
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
94
|
+
"eslint-plugin-yml": "^1.16.0",
|
|
95
95
|
"eslint-processor-vue-blocks": "^0.1.2",
|
|
96
|
-
"globals": "^15.
|
|
96
|
+
"globals": "^15.13.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.3",
|
|
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.10.1",
|
|
115
116
|
"@types/prompts": "^2.4.9",
|
|
116
|
-
"@unocss/eslint-plugin": "^0.
|
|
117
|
+
"@unocss/eslint-plugin": "^0.65.0",
|
|
117
118
|
"bumpp": "^9.8.1",
|
|
118
|
-
"eslint": "^9.
|
|
119
|
-
"eslint-plugin-format": "^0.1.
|
|
119
|
+
"eslint": "^9.16.0",
|
|
120
|
+
"eslint-plugin-format": "^0.1.3",
|
|
120
121
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
121
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
122
|
+
"eslint-plugin-react-refresh": "^0.4.16",
|
|
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
|
-
"prettier": "^3.
|
|
128
|
+
"prettier": "^3.4.1",
|
|
127
129
|
"react": "^18.3.1",
|
|
128
130
|
"rimraf": "^6.0.1",
|
|
129
131
|
"simple-git-hooks": "^2.11.1",
|
|
130
132
|
"simple-open-url": "^3.0.1",
|
|
131
133
|
"sucrase": "^3.35.0",
|
|
132
134
|
"tsup": "^8.3.5",
|
|
133
|
-
"typescript": "^5.
|
|
135
|
+
"typescript": "^5.7.2",
|
|
134
136
|
"unbuild": "^2.0.0",
|
|
135
|
-
"vitest": "^2.1.
|
|
136
|
-
"vue": "^3.5.
|
|
137
|
+
"vitest": "^2.1.8",
|
|
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.17.0",
|
|
150
|
+
"eslint": "^9.16.0",
|
|
149
151
|
"tsx": "^4.19.2"
|
|
150
152
|
},
|
|
151
153
|
"simple-git-hooks": {
|