@lincy/eslint-config 5.2.6 → 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 +132 -97
- package/dist/index.d.cts +746 -596
- package/dist/index.d.ts +746 -596
- package/dist/index.js +129 -96
- 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
|
}
|
|
@@ -328,13 +328,23 @@ function mergePrettierOptions(options, overrides = {}) {
|
|
|
328
328
|
}
|
|
329
329
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
330
330
|
const defaultIndent = 4;
|
|
331
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
331
332
|
if (options === true) {
|
|
332
|
-
const
|
|
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,
|
|
339
|
+
svg: isPrettierPluginXmlInScope2,
|
|
340
|
+
xml: isPrettierPluginXmlInScope2
|
|
341
|
+
};
|
|
342
|
+
} else {
|
|
343
|
+
options = {
|
|
344
|
+
css: options.css ?? false,
|
|
345
|
+
graphql: options.graphql ?? true,
|
|
346
|
+
html: options.html ?? true,
|
|
347
|
+
markdown: options.markdown ?? true,
|
|
338
348
|
svg: isPrettierPluginXmlInScope,
|
|
339
349
|
xml: isPrettierPluginXmlInScope
|
|
340
350
|
};
|
|
@@ -380,7 +390,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
380
390
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
381
391
|
const configs2 = [
|
|
382
392
|
{
|
|
383
|
-
name: "eslint/
|
|
393
|
+
name: "eslint/formatter/setup",
|
|
384
394
|
plugins: {
|
|
385
395
|
format: pluginFormat
|
|
386
396
|
}
|
|
@@ -393,12 +403,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
393
403
|
languageOptions: {
|
|
394
404
|
parser: parserPlain
|
|
395
405
|
},
|
|
396
|
-
name: "eslint/
|
|
406
|
+
name: "eslint/formatter/css",
|
|
397
407
|
rules: {
|
|
398
408
|
"format/prettier": [
|
|
399
409
|
"error",
|
|
400
410
|
mergePrettierOptions(prettierOptions, {
|
|
401
|
-
...prettierOptions,
|
|
402
411
|
parser: "css"
|
|
403
412
|
})
|
|
404
413
|
]
|
|
@@ -409,12 +418,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
409
418
|
languageOptions: {
|
|
410
419
|
parser: parserPlain
|
|
411
420
|
},
|
|
412
|
-
name: "eslint/
|
|
421
|
+
name: "eslint/formatter/scss",
|
|
413
422
|
rules: {
|
|
414
423
|
"format/prettier": [
|
|
415
424
|
"error",
|
|
416
425
|
mergePrettierOptions(prettierOptions, {
|
|
417
|
-
...prettierOptions,
|
|
418
426
|
parser: "scss"
|
|
419
427
|
})
|
|
420
428
|
]
|
|
@@ -425,12 +433,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
425
433
|
languageOptions: {
|
|
426
434
|
parser: parserPlain
|
|
427
435
|
},
|
|
428
|
-
name: "eslint/
|
|
436
|
+
name: "eslint/formatter/less",
|
|
429
437
|
rules: {
|
|
430
438
|
"format/prettier": [
|
|
431
439
|
"error",
|
|
432
440
|
mergePrettierOptions(prettierOptions, {
|
|
433
|
-
...prettierOptions,
|
|
434
441
|
parser: "less"
|
|
435
442
|
})
|
|
436
443
|
]
|
|
@@ -444,12 +451,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
444
451
|
languageOptions: {
|
|
445
452
|
parser: parserPlain
|
|
446
453
|
},
|
|
447
|
-
name: "eslint/
|
|
454
|
+
name: "eslint/formatter/html",
|
|
448
455
|
rules: {
|
|
449
456
|
"format/prettier": [
|
|
450
457
|
"error",
|
|
451
458
|
mergePrettierOptions(prettierOptions, {
|
|
452
|
-
...prettierOptions,
|
|
453
459
|
parser: "html"
|
|
454
460
|
})
|
|
455
461
|
]
|
|
@@ -482,7 +488,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
482
488
|
languageOptions: {
|
|
483
489
|
parser: parserPlain
|
|
484
490
|
},
|
|
485
|
-
name: "eslint/
|
|
491
|
+
name: "eslint/formatter/svg",
|
|
486
492
|
rules: {
|
|
487
493
|
"format/prettier": [
|
|
488
494
|
"error",
|
|
@@ -500,10 +506,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
500
506
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
501
507
|
configs2.push({
|
|
502
508
|
files: [GLOB_MARKDOWN],
|
|
509
|
+
ignores: [],
|
|
503
510
|
languageOptions: {
|
|
504
511
|
parser: parserPlain
|
|
505
512
|
},
|
|
506
|
-
name: "eslint/
|
|
513
|
+
name: "eslint/formatter/markdown",
|
|
507
514
|
rules: {
|
|
508
515
|
[`format/${formater}`]: [
|
|
509
516
|
"error",
|
|
@@ -524,7 +531,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
524
531
|
languageOptions: {
|
|
525
532
|
parser: parserPlain
|
|
526
533
|
},
|
|
527
|
-
name: "eslint/
|
|
534
|
+
name: "eslint/formatter/graphql",
|
|
528
535
|
rules: {
|
|
529
536
|
"format/prettier": [
|
|
530
537
|
"error",
|
|
@@ -1068,7 +1075,7 @@ async function perfectionist(options = {}) {
|
|
|
1068
1075
|
"object",
|
|
1069
1076
|
"unknown"
|
|
1070
1077
|
],
|
|
1071
|
-
internalPattern: ["
|
|
1078
|
+
internalPattern: ["^~/.*", "^@/.*"],
|
|
1072
1079
|
newlinesBetween: "ignore",
|
|
1073
1080
|
order: "asc",
|
|
1074
1081
|
type: "natural"
|
|
@@ -1088,13 +1095,18 @@ var ReactRefreshAllowConstantExportPackages = [
|
|
|
1088
1095
|
];
|
|
1089
1096
|
async function react(options = {}) {
|
|
1090
1097
|
const {
|
|
1091
|
-
files = [
|
|
1092
|
-
|
|
1098
|
+
files = [GLOB_SRC],
|
|
1099
|
+
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
1100
|
+
ignoresTypeAware = [
|
|
1101
|
+
`${GLOB_MARKDOWN}/**`
|
|
1102
|
+
],
|
|
1093
1103
|
overrides = {},
|
|
1094
|
-
|
|
1104
|
+
tsconfigPath
|
|
1095
1105
|
} = options;
|
|
1096
|
-
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1097
1106
|
const isTypeAware = !!tsconfigPath;
|
|
1107
|
+
const typeAwareRules = {
|
|
1108
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1109
|
+
};
|
|
1098
1110
|
await ensurePackages([
|
|
1099
1111
|
"@eslint-react/eslint-plugin",
|
|
1100
1112
|
"eslint-plugin-react-hooks",
|
|
@@ -1103,15 +1115,13 @@ async function react(options = {}) {
|
|
|
1103
1115
|
const [
|
|
1104
1116
|
pluginReact,
|
|
1105
1117
|
pluginReactHooks,
|
|
1106
|
-
pluginReactRefresh
|
|
1107
|
-
parserTs
|
|
1118
|
+
pluginReactRefresh
|
|
1108
1119
|
] = await Promise.all([
|
|
1109
1120
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1110
1121
|
// @ts-expect-error missing types
|
|
1111
1122
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1112
1123
|
// @ts-expect-error missing types
|
|
1113
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1114
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
1124
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1115
1125
|
]);
|
|
1116
1126
|
const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1117
1127
|
(i) => isPackageExists2(i)
|
|
@@ -1132,13 +1142,12 @@ async function react(options = {}) {
|
|
|
1132
1142
|
{
|
|
1133
1143
|
files,
|
|
1134
1144
|
languageOptions: {
|
|
1135
|
-
parser: parserTs,
|
|
1136
1145
|
parserOptions: {
|
|
1137
1146
|
ecmaFeatures: {
|
|
1138
|
-
jsx:
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1147
|
+
jsx: true
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
sourceType: "module"
|
|
1142
1151
|
},
|
|
1143
1152
|
name: "eslint/react/rules",
|
|
1144
1153
|
rules: {
|
|
@@ -1198,18 +1207,18 @@ async function react(options = {}) {
|
|
|
1198
1207
|
"react/prefer-destructuring-assignment": "warn",
|
|
1199
1208
|
"react/prefer-shorthand-boolean": "warn",
|
|
1200
1209
|
"react/prefer-shorthand-fragment": "warn",
|
|
1201
|
-
...isTypeAware ? {
|
|
1202
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1203
|
-
} : {},
|
|
1204
1210
|
// overrides
|
|
1205
1211
|
...overrides
|
|
1206
|
-
},
|
|
1207
|
-
settings: {
|
|
1208
|
-
react: {
|
|
1209
|
-
version
|
|
1210
|
-
}
|
|
1211
1212
|
}
|
|
1212
|
-
}
|
|
1213
|
+
},
|
|
1214
|
+
...isTypeAware ? [{
|
|
1215
|
+
files: filesTypeAware,
|
|
1216
|
+
ignores: ignoresTypeAware,
|
|
1217
|
+
name: "eslint/react/type-aware-rules",
|
|
1218
|
+
rules: {
|
|
1219
|
+
...typeAwareRules
|
|
1220
|
+
}
|
|
1221
|
+
}] : []
|
|
1213
1222
|
];
|
|
1214
1223
|
}
|
|
1215
1224
|
|
|
@@ -1843,6 +1852,8 @@ async function vue(options = {}) {
|
|
|
1843
1852
|
]);
|
|
1844
1853
|
return [
|
|
1845
1854
|
{
|
|
1855
|
+
// This allows Vue plugin to work with auto imports
|
|
1856
|
+
// https://github.com/vuejs/eslint-plugin-vue/pull/2422
|
|
1846
1857
|
languageOptions: {
|
|
1847
1858
|
globals: {
|
|
1848
1859
|
computed: "readonly",
|
|
@@ -1885,21 +1896,21 @@ async function vue(options = {}) {
|
|
|
1885
1896
|
processorVueBlocks({
|
|
1886
1897
|
...sfcBlocks,
|
|
1887
1898
|
blocks: {
|
|
1888
|
-
|
|
1889
|
-
|
|
1899
|
+
styles: true,
|
|
1900
|
+
...sfcBlocks.blocks
|
|
1890
1901
|
}
|
|
1891
1902
|
})
|
|
1892
1903
|
]),
|
|
1893
1904
|
rules: {
|
|
1894
1905
|
...pluginVue.configs.base.rules,
|
|
1895
|
-
...vueVersion === "
|
|
1896
|
-
...pluginVue.configs["vue3-essential"].rules,
|
|
1897
|
-
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1898
|
-
...pluginVue.configs["vue3-recommended"].rules
|
|
1899
|
-
} : {
|
|
1906
|
+
...vueVersion === "2" ? {
|
|
1900
1907
|
...pluginVue.configs.essential.rules,
|
|
1901
1908
|
...pluginVue.configs["strongly-recommended"].rules,
|
|
1902
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
|
|
1903
1914
|
},
|
|
1904
1915
|
"antfu/no-top-level-await": "off",
|
|
1905
1916
|
"node/prefer-global/process": "off",
|
|
@@ -1964,12 +1975,17 @@ async function vue(options = {}) {
|
|
|
1964
1975
|
"vue/no-useless-v-bind": "error",
|
|
1965
1976
|
"vue/no-v-html": "off",
|
|
1966
1977
|
"vue/no-v-text-v-html-on-component": "off",
|
|
1967
|
-
"vue/object-shorthand": [
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1978
|
+
"vue/object-shorthand": [
|
|
1979
|
+
"error",
|
|
1980
|
+
"always",
|
|
1981
|
+
{
|
|
1982
|
+
avoidQuotes: true,
|
|
1983
|
+
ignoreConstructors: false
|
|
1984
|
+
}
|
|
1985
|
+
],
|
|
1971
1986
|
"vue/prefer-separate-static-class": "error",
|
|
1972
1987
|
"vue/prefer-template": "error",
|
|
1988
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1973
1989
|
"vue/require-default-prop": "off",
|
|
1974
1990
|
"vue/require-prop-types": "off",
|
|
1975
1991
|
"vue/singleline-html-element-content-newline": "off",
|
|
@@ -1979,12 +1995,17 @@ async function vue(options = {}) {
|
|
|
1979
1995
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1980
1996
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1981
1997
|
"vue/block-spacing": ["error", "always"],
|
|
1982
|
-
"vue/block-tag-newline": ["error", {
|
|
1998
|
+
"vue/block-tag-newline": ["error", {
|
|
1999
|
+
multiline: "always",
|
|
2000
|
+
singleline: "always"
|
|
2001
|
+
}],
|
|
1983
2002
|
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: false }],
|
|
1984
2003
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1985
2004
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1986
2005
|
"vue/comma-style": ["error", "last"],
|
|
1987
|
-
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2006
|
+
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2007
|
+
exceptions: ["-"]
|
|
2008
|
+
}],
|
|
1988
2009
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1989
2010
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1990
2011
|
"vue/object-curly-newline": "off",
|
|
@@ -2009,6 +2030,9 @@ async function yaml(options = {}) {
|
|
|
2009
2030
|
overrides = {},
|
|
2010
2031
|
stylistic: stylistic2 = true
|
|
2011
2032
|
} = options;
|
|
2033
|
+
const {
|
|
2034
|
+
quotes = "single"
|
|
2035
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
2012
2036
|
const [
|
|
2013
2037
|
pluginYaml,
|
|
2014
2038
|
parserYaml
|
|
@@ -2048,7 +2072,7 @@ async function yaml(options = {}) {
|
|
|
2048
2072
|
"yaml/indent": ["error", 2],
|
|
2049
2073
|
"yaml/key-spacing": "error",
|
|
2050
2074
|
"yaml/no-tab-indent": "error",
|
|
2051
|
-
"yaml/quotes": ["error", { avoidEscape:
|
|
2075
|
+
"yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
|
|
2052
2076
|
"yaml/spaced-comment": "error"
|
|
2053
2077
|
} : {},
|
|
2054
2078
|
...overrides
|
|
@@ -2085,10 +2109,6 @@ var defaultPluginRenaming = {
|
|
|
2085
2109
|
"vitest": "test",
|
|
2086
2110
|
"yml": "yaml"
|
|
2087
2111
|
};
|
|
2088
|
-
var ReactPackages = [
|
|
2089
|
-
"react",
|
|
2090
|
-
"next"
|
|
2091
|
-
];
|
|
2092
2112
|
function lincy(options = {}, ...userConfigs) {
|
|
2093
2113
|
const {
|
|
2094
2114
|
autoRenamePlugins = true,
|
|
@@ -2097,7 +2117,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2097
2117
|
ignores: ignoresList = [],
|
|
2098
2118
|
jsx: enableJsx = true,
|
|
2099
2119
|
overrides = {},
|
|
2100
|
-
react: enableReact =
|
|
2120
|
+
react: enableReact = false,
|
|
2101
2121
|
regexp: enableRegexp = true,
|
|
2102
2122
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
2103
2123
|
unicorn: enableUnicorn = true,
|
|
@@ -2111,12 +2131,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2111
2131
|
console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2112
2132
|
}
|
|
2113
2133
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
if (!("jsx" in stylisticOptions)) {
|
|
2117
|
-
stylisticOptions.jsx = enableJsx;
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2134
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2135
|
+
stylisticOptions.jsx = enableJsx;
|
|
2120
2136
|
const configs2 = [];
|
|
2121
2137
|
if (enableGitignore) {
|
|
2122
2138
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -2131,6 +2147,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2131
2147
|
})]));
|
|
2132
2148
|
}
|
|
2133
2149
|
}
|
|
2150
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2151
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2134
2152
|
configs2.push(
|
|
2135
2153
|
ignores({
|
|
2136
2154
|
ignores: [
|
|
@@ -2140,7 +2158,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2140
2158
|
}),
|
|
2141
2159
|
javascript({
|
|
2142
2160
|
isInEditor,
|
|
2143
|
-
overrides:
|
|
2161
|
+
overrides: getOverrides(options, "javascript")
|
|
2144
2162
|
}),
|
|
2145
2163
|
comments({
|
|
2146
2164
|
overrides: overrides.comments
|
|
@@ -2170,63 +2188,64 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2170
2188
|
if (enableVue) {
|
|
2171
2189
|
componentExts.push("vue");
|
|
2172
2190
|
}
|
|
2191
|
+
if (enableJsx) {
|
|
2192
|
+
configs2.push(jsx());
|
|
2193
|
+
}
|
|
2173
2194
|
if (enableTypeScript) {
|
|
2174
2195
|
configs2.push(typescript({
|
|
2175
|
-
...
|
|
2196
|
+
...typescriptOptions,
|
|
2176
2197
|
componentExts,
|
|
2177
|
-
overrides:
|
|
2198
|
+
overrides: getOverrides(options, "typescript"),
|
|
2178
2199
|
tsconfigPath,
|
|
2179
2200
|
type: options.type
|
|
2180
2201
|
}));
|
|
2181
2202
|
}
|
|
2182
|
-
if (enableJsx) {
|
|
2183
|
-
configs2.push(jsx());
|
|
2184
|
-
}
|
|
2185
2203
|
if (stylisticOptions) {
|
|
2186
2204
|
configs2.push(stylistic({
|
|
2187
|
-
overrides:
|
|
2205
|
+
overrides: getOverrides(options, "stylistic"),
|
|
2188
2206
|
stylistic: stylisticOptions
|
|
2189
2207
|
}));
|
|
2190
2208
|
}
|
|
2191
2209
|
if (enableRegexp) {
|
|
2192
2210
|
configs2.push(regexp({
|
|
2193
|
-
...
|
|
2194
|
-
|
|
2211
|
+
...resolveSubOptions(options, "regexp"),
|
|
2212
|
+
...getOverrides(options, "regexp")
|
|
2195
2213
|
}));
|
|
2196
2214
|
}
|
|
2197
2215
|
if (options.test ?? true) {
|
|
2198
2216
|
configs2.push(test({
|
|
2199
|
-
...
|
|
2217
|
+
...resolveSubOptions(options, "test"),
|
|
2200
2218
|
isInEditor,
|
|
2201
|
-
overrides:
|
|
2219
|
+
overrides: getOverrides(options, "test")
|
|
2202
2220
|
}));
|
|
2203
2221
|
}
|
|
2204
2222
|
if (enableVue) {
|
|
2205
2223
|
configs2.push(vue({
|
|
2206
|
-
...
|
|
2207
|
-
overrides:
|
|
2224
|
+
...resolveSubOptions(options, "vue"),
|
|
2225
|
+
overrides: getOverrides(options, "vue"),
|
|
2208
2226
|
stylistic: stylisticOptions,
|
|
2209
2227
|
typescript: !!enableTypeScript
|
|
2210
2228
|
}));
|
|
2211
2229
|
}
|
|
2212
2230
|
if (enableReact) {
|
|
2213
2231
|
configs2.push(react({
|
|
2214
|
-
|
|
2215
|
-
...
|
|
2216
|
-
overrides:
|
|
2232
|
+
...typescriptOptions,
|
|
2233
|
+
...resolveSubOptions(options, "react"),
|
|
2234
|
+
overrides: getOverrides(options, "react"),
|
|
2235
|
+
tsconfigPath
|
|
2217
2236
|
}));
|
|
2218
2237
|
}
|
|
2219
2238
|
if (enableUnoCSS) {
|
|
2220
2239
|
configs2.push(unocss({
|
|
2221
|
-
...
|
|
2222
|
-
overrides:
|
|
2240
|
+
...resolveSubOptions(options, "unocss"),
|
|
2241
|
+
overrides: getOverrides(options, "unocss")
|
|
2223
2242
|
}));
|
|
2224
2243
|
}
|
|
2225
2244
|
if (options.jsonc ?? true) {
|
|
2226
2245
|
configs2.push(
|
|
2227
2246
|
jsonc({
|
|
2228
|
-
...
|
|
2229
|
-
overrides:
|
|
2247
|
+
...resolveSubOptions(options, "jsonc"),
|
|
2248
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2230
2249
|
stylistic: stylisticOptions
|
|
2231
2250
|
}),
|
|
2232
2251
|
sortPackageJson(),
|
|
@@ -2235,23 +2254,27 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2235
2254
|
}
|
|
2236
2255
|
if (options.yaml ?? true) {
|
|
2237
2256
|
configs2.push(yaml({
|
|
2238
|
-
...
|
|
2239
|
-
overrides:
|
|
2257
|
+
...resolveSubOptions(options, "yaml"),
|
|
2258
|
+
overrides: getOverrides(options, "yaml"),
|
|
2240
2259
|
stylistic: stylisticOptions
|
|
2241
2260
|
}));
|
|
2242
2261
|
}
|
|
2243
|
-
if (options.toml) {
|
|
2262
|
+
if (options.toml ?? true) {
|
|
2244
2263
|
configs2.push(toml({
|
|
2245
|
-
overrides:
|
|
2264
|
+
overrides: getOverrides(options, "toml"),
|
|
2246
2265
|
stylistic: stylisticOptions
|
|
2247
2266
|
}));
|
|
2248
2267
|
}
|
|
2249
2268
|
if (options.markdown ?? true) {
|
|
2250
|
-
configs2.push(
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2269
|
+
configs2.push(
|
|
2270
|
+
markdown(
|
|
2271
|
+
{
|
|
2272
|
+
...resolveSubOptions(options, "markdown"),
|
|
2273
|
+
componentExts,
|
|
2274
|
+
overrides: getOverrides(options, "markdown")
|
|
2275
|
+
}
|
|
2276
|
+
)
|
|
2277
|
+
);
|
|
2255
2278
|
}
|
|
2256
2279
|
if (options.formatters) {
|
|
2257
2280
|
configs2.push(formatters(
|
|
@@ -2266,14 +2289,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2266
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");
|
|
2267
2290
|
}
|
|
2268
2291
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2269
|
-
if (key in options)
|
|
2292
|
+
if (key in options)
|
|
2270
2293
|
acc[key] = options[key];
|
|
2271
|
-
}
|
|
2272
2294
|
return acc;
|
|
2273
2295
|
}, {});
|
|
2274
|
-
if (Object.keys(fusedConfig).length)
|
|
2296
|
+
if (Object.keys(fusedConfig).length)
|
|
2275
2297
|
configs2.push([fusedConfig]);
|
|
2276
|
-
}
|
|
2277
2298
|
let composer = new FlatConfigComposer();
|
|
2278
2299
|
composer = composer.append(
|
|
2279
2300
|
...configs2,
|
|
@@ -2284,6 +2305,16 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2284
2305
|
}
|
|
2285
2306
|
return composer;
|
|
2286
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
|
+
}
|
|
2287
2318
|
|
|
2288
2319
|
// src/index.ts
|
|
2289
2320
|
var src_default = lincy;
|
|
@@ -2324,6 +2355,7 @@ export {
|
|
|
2324
2355
|
disables,
|
|
2325
2356
|
ensurePackages,
|
|
2326
2357
|
formatters,
|
|
2358
|
+
getOverrides,
|
|
2327
2359
|
ignores,
|
|
2328
2360
|
imports,
|
|
2329
2361
|
interopDefault,
|
|
@@ -2343,6 +2375,7 @@ export {
|
|
|
2343
2375
|
regexp,
|
|
2344
2376
|
renamePluginInConfigs,
|
|
2345
2377
|
renameRules,
|
|
2378
|
+
resolveSubOptions,
|
|
2346
2379
|
sortPackageJson,
|
|
2347
2380
|
sortTsconfig,
|
|
2348
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.
|
|
72
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.
|
|
71
|
+
"@clack/prompts": "^0.8.2",
|
|
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.10.1",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "8.13.0",
|
|
76
|
+
"@typescript-eslint/parser": "8.13.0",
|
|
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.3
|
|
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.
|
|
94
|
-
"eslint-plugin-yml": "^1.
|
|
93
|
+
"eslint-plugin-vue": "^9.31.0",
|
|
94
|
+
"eslint-plugin-yml": "^1.15.0",
|
|
95
95
|
"eslint-processor-vue-blocks": "^0.1.2",
|
|
96
|
-
"globals": "^15.
|
|
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
|
-
"@eslint/config-inspector": "^0.5.
|
|
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.
|
|
117
|
-
"bumpp": "^9.
|
|
118
|
-
"eslint": "^9.
|
|
117
|
+
"@unocss/eslint-plugin": "^0.64.1",
|
|
118
|
+
"bumpp": "^9.8.1",
|
|
119
|
+
"eslint": "^9.15.0",
|
|
119
120
|
"eslint-plugin-format": "^0.1.2",
|
|
120
121
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
121
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
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",
|
|
@@ -129,11 +131,11 @@
|
|
|
129
131
|
"simple-git-hooks": "^2.11.1",
|
|
130
132
|
"simple-open-url": "^3.0.1",
|
|
131
133
|
"sucrase": "^3.35.0",
|
|
132
|
-
"tsup": "^8.3.
|
|
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": {
|
|
@@ -143,10 +145,10 @@
|
|
|
143
145
|
}
|
|
144
146
|
},
|
|
145
147
|
"resolutions": {
|
|
146
|
-
"@eslint-community/eslint-utils": "^4.4.
|
|
147
|
-
"@typescript-eslint/utils": "^8.
|
|
148
|
-
"eslint": "^9.
|
|
149
|
-
"tsx": "^4.
|
|
148
|
+
"@eslint-community/eslint-utils": "^4.4.1",
|
|
149
|
+
"@typescript-eslint/utils": "^8.15.0",
|
|
150
|
+
"eslint": "^9.15.0",
|
|
151
|
+
"tsx": "^4.19.2"
|
|
150
152
|
},
|
|
151
153
|
"simple-git-hooks": {
|
|
152
154
|
"pre-commit": "npx lint-staged"
|