@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.cjs
CHANGED
|
@@ -66,6 +66,7 @@ __export(src_exports, {
|
|
|
66
66
|
disables: () => disables,
|
|
67
67
|
ensurePackages: () => ensurePackages,
|
|
68
68
|
formatters: () => formatters,
|
|
69
|
+
getOverrides: () => getOverrides,
|
|
69
70
|
ignores: () => ignores,
|
|
70
71
|
imports: () => imports,
|
|
71
72
|
interopDefault: () => interopDefault,
|
|
@@ -85,6 +86,7 @@ __export(src_exports, {
|
|
|
85
86
|
regexp: () => regexp,
|
|
86
87
|
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
87
88
|
renameRules: () => renameRules,
|
|
89
|
+
resolveSubOptions: () => resolveSubOptions,
|
|
88
90
|
sortPackageJson: () => sortPackageJson,
|
|
89
91
|
sortTsconfig: () => sortTsconfig,
|
|
90
92
|
stylistic: () => stylistic,
|
|
@@ -347,7 +349,8 @@ async function ensurePackages(packages) {
|
|
|
347
349
|
return;
|
|
348
350
|
const p = await import("@clack/prompts");
|
|
349
351
|
const result = await p.confirm({
|
|
350
|
-
message: `${nonExistingPackages.length === 1 ?
|
|
352
|
+
// message: `${nonExistingPackages.length === 1 ? 'Package is' : 'Packages are'} required for this config: ${nonExistingPackages.join(', ')}. Do you want to install them?`,
|
|
353
|
+
message: `\u6B64\u914D\u7F6E\u9700\u8981\u8F6F\u4EF6\u5305: ${nonExistingPackages.join(", ")}. \u4F60\u60F3\u5B89\u88C5\u5B83\u4EEC\u5417?`
|
|
351
354
|
});
|
|
352
355
|
if (result)
|
|
353
356
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
@@ -412,7 +415,6 @@ async function stylistic(options = {}) {
|
|
|
412
415
|
},
|
|
413
416
|
// 覆盖`stylistic`默认规则
|
|
414
417
|
"style/brace-style": ["error", "stroustrup"],
|
|
415
|
-
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
416
418
|
"style/multiline-ternary": ["error", "never"],
|
|
417
419
|
...overrides
|
|
418
420
|
}
|
|
@@ -435,13 +437,14 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
435
437
|
const defaultIndent = 4;
|
|
436
438
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
437
439
|
if (options === true) {
|
|
440
|
+
const isPrettierPluginXmlInScope2 = isPackageInScope("@prettier/plugin-xml");
|
|
438
441
|
options = {
|
|
439
442
|
css: false,
|
|
440
443
|
graphql: true,
|
|
441
444
|
html: true,
|
|
442
445
|
markdown: true,
|
|
443
|
-
svg:
|
|
444
|
-
xml:
|
|
446
|
+
svg: isPrettierPluginXmlInScope2,
|
|
447
|
+
xml: isPrettierPluginXmlInScope2
|
|
445
448
|
};
|
|
446
449
|
} else {
|
|
447
450
|
options = {
|
|
@@ -494,7 +497,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
494
497
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
495
498
|
const configs2 = [
|
|
496
499
|
{
|
|
497
|
-
name: "eslint/
|
|
500
|
+
name: "eslint/formatter/setup",
|
|
498
501
|
plugins: {
|
|
499
502
|
format: pluginFormat
|
|
500
503
|
}
|
|
@@ -507,12 +510,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
507
510
|
languageOptions: {
|
|
508
511
|
parser: parserPlain
|
|
509
512
|
},
|
|
510
|
-
name: "eslint/
|
|
513
|
+
name: "eslint/formatter/css",
|
|
511
514
|
rules: {
|
|
512
515
|
"format/prettier": [
|
|
513
516
|
"error",
|
|
514
517
|
mergePrettierOptions(prettierOptions, {
|
|
515
|
-
...prettierOptions,
|
|
516
518
|
parser: "css"
|
|
517
519
|
})
|
|
518
520
|
]
|
|
@@ -523,12 +525,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
523
525
|
languageOptions: {
|
|
524
526
|
parser: parserPlain
|
|
525
527
|
},
|
|
526
|
-
name: "eslint/
|
|
528
|
+
name: "eslint/formatter/scss",
|
|
527
529
|
rules: {
|
|
528
530
|
"format/prettier": [
|
|
529
531
|
"error",
|
|
530
532
|
mergePrettierOptions(prettierOptions, {
|
|
531
|
-
...prettierOptions,
|
|
532
533
|
parser: "scss"
|
|
533
534
|
})
|
|
534
535
|
]
|
|
@@ -539,12 +540,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
539
540
|
languageOptions: {
|
|
540
541
|
parser: parserPlain
|
|
541
542
|
},
|
|
542
|
-
name: "eslint/
|
|
543
|
+
name: "eslint/formatter/less",
|
|
543
544
|
rules: {
|
|
544
545
|
"format/prettier": [
|
|
545
546
|
"error",
|
|
546
547
|
mergePrettierOptions(prettierOptions, {
|
|
547
|
-
...prettierOptions,
|
|
548
548
|
parser: "less"
|
|
549
549
|
})
|
|
550
550
|
]
|
|
@@ -558,12 +558,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
558
558
|
languageOptions: {
|
|
559
559
|
parser: parserPlain
|
|
560
560
|
},
|
|
561
|
-
name: "eslint/
|
|
561
|
+
name: "eslint/formatter/html",
|
|
562
562
|
rules: {
|
|
563
563
|
"format/prettier": [
|
|
564
564
|
"error",
|
|
565
565
|
mergePrettierOptions(prettierOptions, {
|
|
566
|
-
...prettierOptions,
|
|
567
566
|
parser: "html"
|
|
568
567
|
})
|
|
569
568
|
]
|
|
@@ -596,7 +595,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
596
595
|
languageOptions: {
|
|
597
596
|
parser: parserPlain
|
|
598
597
|
},
|
|
599
|
-
name: "eslint/
|
|
598
|
+
name: "eslint/formatter/svg",
|
|
600
599
|
rules: {
|
|
601
600
|
"format/prettier": [
|
|
602
601
|
"error",
|
|
@@ -614,10 +613,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
614
613
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
615
614
|
configs2.push({
|
|
616
615
|
files: [GLOB_MARKDOWN],
|
|
616
|
+
ignores: [],
|
|
617
617
|
languageOptions: {
|
|
618
618
|
parser: parserPlain
|
|
619
619
|
},
|
|
620
|
-
name: "eslint/
|
|
620
|
+
name: "eslint/formatter/markdown",
|
|
621
621
|
rules: {
|
|
622
622
|
[`format/${formater}`]: [
|
|
623
623
|
"error",
|
|
@@ -638,7 +638,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
638
638
|
languageOptions: {
|
|
639
639
|
parser: parserPlain
|
|
640
640
|
},
|
|
641
|
-
name: "eslint/
|
|
641
|
+
name: "eslint/formatter/graphql",
|
|
642
642
|
rules: {
|
|
643
643
|
"format/prettier": [
|
|
644
644
|
"error",
|
|
@@ -1182,7 +1182,7 @@ async function perfectionist(options = {}) {
|
|
|
1182
1182
|
"object",
|
|
1183
1183
|
"unknown"
|
|
1184
1184
|
],
|
|
1185
|
-
internalPattern: ["
|
|
1185
|
+
internalPattern: ["^~/.*", "^@/.*"],
|
|
1186
1186
|
newlinesBetween: "ignore",
|
|
1187
1187
|
order: "asc",
|
|
1188
1188
|
type: "natural"
|
|
@@ -1202,13 +1202,18 @@ var ReactRefreshAllowConstantExportPackages = [
|
|
|
1202
1202
|
];
|
|
1203
1203
|
async function react(options = {}) {
|
|
1204
1204
|
const {
|
|
1205
|
-
files = [
|
|
1206
|
-
|
|
1205
|
+
files = [GLOB_SRC],
|
|
1206
|
+
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
1207
|
+
ignoresTypeAware = [
|
|
1208
|
+
`${GLOB_MARKDOWN}/**`
|
|
1209
|
+
],
|
|
1207
1210
|
overrides = {},
|
|
1208
|
-
|
|
1211
|
+
tsconfigPath
|
|
1209
1212
|
} = options;
|
|
1210
|
-
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1211
1213
|
const isTypeAware = !!tsconfigPath;
|
|
1214
|
+
const typeAwareRules = {
|
|
1215
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1216
|
+
};
|
|
1212
1217
|
await ensurePackages([
|
|
1213
1218
|
"@eslint-react/eslint-plugin",
|
|
1214
1219
|
"eslint-plugin-react-hooks",
|
|
@@ -1217,15 +1222,13 @@ async function react(options = {}) {
|
|
|
1217
1222
|
const [
|
|
1218
1223
|
pluginReact,
|
|
1219
1224
|
pluginReactHooks,
|
|
1220
|
-
pluginReactRefresh
|
|
1221
|
-
parserTs
|
|
1225
|
+
pluginReactRefresh
|
|
1222
1226
|
] = await Promise.all([
|
|
1223
1227
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1224
1228
|
// @ts-expect-error missing types
|
|
1225
1229
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1226
1230
|
// @ts-expect-error missing types
|
|
1227
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1228
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
1231
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1229
1232
|
]);
|
|
1230
1233
|
const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1231
1234
|
(i) => (0, import_local_pkg2.isPackageExists)(i)
|
|
@@ -1246,13 +1249,12 @@ async function react(options = {}) {
|
|
|
1246
1249
|
{
|
|
1247
1250
|
files,
|
|
1248
1251
|
languageOptions: {
|
|
1249
|
-
parser: parserTs,
|
|
1250
1252
|
parserOptions: {
|
|
1251
1253
|
ecmaFeatures: {
|
|
1252
|
-
jsx:
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
jsx: true
|
|
1255
|
+
}
|
|
1256
|
+
},
|
|
1257
|
+
sourceType: "module"
|
|
1256
1258
|
},
|
|
1257
1259
|
name: "eslint/react/rules",
|
|
1258
1260
|
rules: {
|
|
@@ -1312,18 +1314,18 @@ async function react(options = {}) {
|
|
|
1312
1314
|
"react/prefer-destructuring-assignment": "warn",
|
|
1313
1315
|
"react/prefer-shorthand-boolean": "warn",
|
|
1314
1316
|
"react/prefer-shorthand-fragment": "warn",
|
|
1315
|
-
...isTypeAware ? {
|
|
1316
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1317
|
-
} : {},
|
|
1318
1317
|
// overrides
|
|
1319
1318
|
...overrides
|
|
1320
|
-
},
|
|
1321
|
-
settings: {
|
|
1322
|
-
react: {
|
|
1323
|
-
version
|
|
1324
|
-
}
|
|
1325
1319
|
}
|
|
1326
|
-
}
|
|
1320
|
+
},
|
|
1321
|
+
...isTypeAware ? [{
|
|
1322
|
+
files: filesTypeAware,
|
|
1323
|
+
ignores: ignoresTypeAware,
|
|
1324
|
+
name: "eslint/react/type-aware-rules",
|
|
1325
|
+
rules: {
|
|
1326
|
+
...typeAwareRules
|
|
1327
|
+
}
|
|
1328
|
+
}] : []
|
|
1327
1329
|
];
|
|
1328
1330
|
}
|
|
1329
1331
|
|
|
@@ -1957,6 +1959,8 @@ async function vue(options = {}) {
|
|
|
1957
1959
|
]);
|
|
1958
1960
|
return [
|
|
1959
1961
|
{
|
|
1962
|
+
// This allows Vue plugin to work with auto imports
|
|
1963
|
+
// https://github.com/vuejs/eslint-plugin-vue/pull/2422
|
|
1960
1964
|
languageOptions: {
|
|
1961
1965
|
globals: {
|
|
1962
1966
|
computed: "readonly",
|
|
@@ -1999,21 +2003,21 @@ async function vue(options = {}) {
|
|
|
1999
2003
|
processorVueBlocks({
|
|
2000
2004
|
...sfcBlocks,
|
|
2001
2005
|
blocks: {
|
|
2002
|
-
|
|
2003
|
-
|
|
2006
|
+
styles: true,
|
|
2007
|
+
...sfcBlocks.blocks
|
|
2004
2008
|
}
|
|
2005
2009
|
})
|
|
2006
2010
|
]),
|
|
2007
2011
|
rules: {
|
|
2008
2012
|
...pluginVue.configs.base.rules,
|
|
2009
|
-
...vueVersion === "
|
|
2010
|
-
...pluginVue.configs["vue3-essential"].rules,
|
|
2011
|
-
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
2012
|
-
...pluginVue.configs["vue3-recommended"].rules
|
|
2013
|
-
} : {
|
|
2013
|
+
...vueVersion === "2" ? {
|
|
2014
2014
|
...pluginVue.configs.essential.rules,
|
|
2015
2015
|
...pluginVue.configs["strongly-recommended"].rules,
|
|
2016
2016
|
...pluginVue.configs.recommended.rules
|
|
2017
|
+
} : {
|
|
2018
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
2019
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
2020
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
2017
2021
|
},
|
|
2018
2022
|
"antfu/no-top-level-await": "off",
|
|
2019
2023
|
"node/prefer-global/process": "off",
|
|
@@ -2078,12 +2082,17 @@ async function vue(options = {}) {
|
|
|
2078
2082
|
"vue/no-useless-v-bind": "error",
|
|
2079
2083
|
"vue/no-v-html": "off",
|
|
2080
2084
|
"vue/no-v-text-v-html-on-component": "off",
|
|
2081
|
-
"vue/object-shorthand": [
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
+
"vue/object-shorthand": [
|
|
2086
|
+
"error",
|
|
2087
|
+
"always",
|
|
2088
|
+
{
|
|
2089
|
+
avoidQuotes: true,
|
|
2090
|
+
ignoreConstructors: false
|
|
2091
|
+
}
|
|
2092
|
+
],
|
|
2085
2093
|
"vue/prefer-separate-static-class": "error",
|
|
2086
2094
|
"vue/prefer-template": "error",
|
|
2095
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
2087
2096
|
"vue/require-default-prop": "off",
|
|
2088
2097
|
"vue/require-prop-types": "off",
|
|
2089
2098
|
"vue/singleline-html-element-content-newline": "off",
|
|
@@ -2093,12 +2102,17 @@ async function vue(options = {}) {
|
|
|
2093
2102
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2094
2103
|
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
2095
2104
|
"vue/block-spacing": ["error", "always"],
|
|
2096
|
-
"vue/block-tag-newline": ["error", {
|
|
2105
|
+
"vue/block-tag-newline": ["error", {
|
|
2106
|
+
multiline: "always",
|
|
2107
|
+
singleline: "always"
|
|
2108
|
+
}],
|
|
2097
2109
|
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: false }],
|
|
2098
2110
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
2099
2111
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
2100
2112
|
"vue/comma-style": ["error", "last"],
|
|
2101
|
-
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2113
|
+
"vue/html-comment-content-spacing": ["error", "always", {
|
|
2114
|
+
exceptions: ["-"]
|
|
2115
|
+
}],
|
|
2102
2116
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
2103
2117
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
2104
2118
|
"vue/object-curly-newline": "off",
|
|
@@ -2123,6 +2137,9 @@ async function yaml(options = {}) {
|
|
|
2123
2137
|
overrides = {},
|
|
2124
2138
|
stylistic: stylistic2 = true
|
|
2125
2139
|
} = options;
|
|
2140
|
+
const {
|
|
2141
|
+
quotes = "single"
|
|
2142
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
2126
2143
|
const [
|
|
2127
2144
|
pluginYaml,
|
|
2128
2145
|
parserYaml
|
|
@@ -2162,7 +2179,7 @@ async function yaml(options = {}) {
|
|
|
2162
2179
|
"yaml/indent": ["error", 2],
|
|
2163
2180
|
"yaml/key-spacing": "error",
|
|
2164
2181
|
"yaml/no-tab-indent": "error",
|
|
2165
|
-
"yaml/quotes": ["error", { avoidEscape:
|
|
2182
|
+
"yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
|
|
2166
2183
|
"yaml/spaced-comment": "error"
|
|
2167
2184
|
} : {},
|
|
2168
2185
|
...overrides
|
|
@@ -2199,10 +2216,6 @@ var defaultPluginRenaming = {
|
|
|
2199
2216
|
"vitest": "test",
|
|
2200
2217
|
"yml": "yaml"
|
|
2201
2218
|
};
|
|
2202
|
-
var ReactPackages = [
|
|
2203
|
-
"react",
|
|
2204
|
-
"next"
|
|
2205
|
-
];
|
|
2206
2219
|
function lincy(options = {}, ...userConfigs) {
|
|
2207
2220
|
const {
|
|
2208
2221
|
autoRenamePlugins = true,
|
|
@@ -2211,7 +2224,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2211
2224
|
ignores: ignoresList = [],
|
|
2212
2225
|
jsx: enableJsx = true,
|
|
2213
2226
|
overrides = {},
|
|
2214
|
-
react: enableReact =
|
|
2227
|
+
react: enableReact = false,
|
|
2215
2228
|
regexp: enableRegexp = true,
|
|
2216
2229
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2217
2230
|
unicorn: enableUnicorn = true,
|
|
@@ -2225,12 +2238,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2225
2238
|
console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2226
2239
|
}
|
|
2227
2240
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
if (!("jsx" in stylisticOptions)) {
|
|
2231
|
-
stylisticOptions.jsx = enableJsx;
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2241
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2242
|
+
stylisticOptions.jsx = enableJsx;
|
|
2234
2243
|
const configs2 = [];
|
|
2235
2244
|
if (enableGitignore) {
|
|
2236
2245
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -2245,6 +2254,8 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2245
2254
|
})]));
|
|
2246
2255
|
}
|
|
2247
2256
|
}
|
|
2257
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2258
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2248
2259
|
configs2.push(
|
|
2249
2260
|
ignores({
|
|
2250
2261
|
ignores: [
|
|
@@ -2254,7 +2265,7 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2254
2265
|
}),
|
|
2255
2266
|
javascript({
|
|
2256
2267
|
isInEditor,
|
|
2257
|
-
overrides:
|
|
2268
|
+
overrides: getOverrides(options, "javascript")
|
|
2258
2269
|
}),
|
|
2259
2270
|
comments({
|
|
2260
2271
|
overrides: overrides.comments
|
|
@@ -2284,63 +2295,64 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2284
2295
|
if (enableVue) {
|
|
2285
2296
|
componentExts.push("vue");
|
|
2286
2297
|
}
|
|
2298
|
+
if (enableJsx) {
|
|
2299
|
+
configs2.push(jsx());
|
|
2300
|
+
}
|
|
2287
2301
|
if (enableTypeScript) {
|
|
2288
2302
|
configs2.push(typescript({
|
|
2289
|
-
...
|
|
2303
|
+
...typescriptOptions,
|
|
2290
2304
|
componentExts,
|
|
2291
|
-
overrides:
|
|
2305
|
+
overrides: getOverrides(options, "typescript"),
|
|
2292
2306
|
tsconfigPath,
|
|
2293
2307
|
type: options.type
|
|
2294
2308
|
}));
|
|
2295
2309
|
}
|
|
2296
|
-
if (enableJsx) {
|
|
2297
|
-
configs2.push(jsx());
|
|
2298
|
-
}
|
|
2299
2310
|
if (stylisticOptions) {
|
|
2300
2311
|
configs2.push(stylistic({
|
|
2301
|
-
overrides:
|
|
2312
|
+
overrides: getOverrides(options, "stylistic"),
|
|
2302
2313
|
stylistic: stylisticOptions
|
|
2303
2314
|
}));
|
|
2304
2315
|
}
|
|
2305
2316
|
if (enableRegexp) {
|
|
2306
2317
|
configs2.push(regexp({
|
|
2307
|
-
...
|
|
2308
|
-
|
|
2318
|
+
...resolveSubOptions(options, "regexp"),
|
|
2319
|
+
...getOverrides(options, "regexp")
|
|
2309
2320
|
}));
|
|
2310
2321
|
}
|
|
2311
2322
|
if (options.test ?? true) {
|
|
2312
2323
|
configs2.push(test({
|
|
2313
|
-
...
|
|
2324
|
+
...resolveSubOptions(options, "test"),
|
|
2314
2325
|
isInEditor,
|
|
2315
|
-
overrides:
|
|
2326
|
+
overrides: getOverrides(options, "test")
|
|
2316
2327
|
}));
|
|
2317
2328
|
}
|
|
2318
2329
|
if (enableVue) {
|
|
2319
2330
|
configs2.push(vue({
|
|
2320
|
-
...
|
|
2321
|
-
overrides:
|
|
2331
|
+
...resolveSubOptions(options, "vue"),
|
|
2332
|
+
overrides: getOverrides(options, "vue"),
|
|
2322
2333
|
stylistic: stylisticOptions,
|
|
2323
2334
|
typescript: !!enableTypeScript
|
|
2324
2335
|
}));
|
|
2325
2336
|
}
|
|
2326
2337
|
if (enableReact) {
|
|
2327
2338
|
configs2.push(react({
|
|
2328
|
-
|
|
2329
|
-
...
|
|
2330
|
-
overrides:
|
|
2339
|
+
...typescriptOptions,
|
|
2340
|
+
...resolveSubOptions(options, "react"),
|
|
2341
|
+
overrides: getOverrides(options, "react"),
|
|
2342
|
+
tsconfigPath
|
|
2331
2343
|
}));
|
|
2332
2344
|
}
|
|
2333
2345
|
if (enableUnoCSS) {
|
|
2334
2346
|
configs2.push(unocss({
|
|
2335
|
-
...
|
|
2336
|
-
overrides:
|
|
2347
|
+
...resolveSubOptions(options, "unocss"),
|
|
2348
|
+
overrides: getOverrides(options, "unocss")
|
|
2337
2349
|
}));
|
|
2338
2350
|
}
|
|
2339
2351
|
if (options.jsonc ?? true) {
|
|
2340
2352
|
configs2.push(
|
|
2341
2353
|
jsonc({
|
|
2342
|
-
...
|
|
2343
|
-
overrides:
|
|
2354
|
+
...resolveSubOptions(options, "jsonc"),
|
|
2355
|
+
overrides: getOverrides(options, "jsonc"),
|
|
2344
2356
|
stylistic: stylisticOptions
|
|
2345
2357
|
}),
|
|
2346
2358
|
sortPackageJson(),
|
|
@@ -2349,23 +2361,27 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2349
2361
|
}
|
|
2350
2362
|
if (options.yaml ?? true) {
|
|
2351
2363
|
configs2.push(yaml({
|
|
2352
|
-
...
|
|
2353
|
-
overrides:
|
|
2364
|
+
...resolveSubOptions(options, "yaml"),
|
|
2365
|
+
overrides: getOverrides(options, "yaml"),
|
|
2354
2366
|
stylistic: stylisticOptions
|
|
2355
2367
|
}));
|
|
2356
2368
|
}
|
|
2357
|
-
if (options.toml) {
|
|
2369
|
+
if (options.toml ?? true) {
|
|
2358
2370
|
configs2.push(toml({
|
|
2359
|
-
overrides:
|
|
2371
|
+
overrides: getOverrides(options, "toml"),
|
|
2360
2372
|
stylistic: stylisticOptions
|
|
2361
2373
|
}));
|
|
2362
2374
|
}
|
|
2363
2375
|
if (options.markdown ?? true) {
|
|
2364
|
-
configs2.push(
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2376
|
+
configs2.push(
|
|
2377
|
+
markdown(
|
|
2378
|
+
{
|
|
2379
|
+
...resolveSubOptions(options, "markdown"),
|
|
2380
|
+
componentExts,
|
|
2381
|
+
overrides: getOverrides(options, "markdown")
|
|
2382
|
+
}
|
|
2383
|
+
)
|
|
2384
|
+
);
|
|
2369
2385
|
}
|
|
2370
2386
|
if (options.formatters) {
|
|
2371
2387
|
configs2.push(formatters(
|
|
@@ -2380,14 +2396,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2380
2396
|
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");
|
|
2381
2397
|
}
|
|
2382
2398
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2383
|
-
if (key in options)
|
|
2399
|
+
if (key in options)
|
|
2384
2400
|
acc[key] = options[key];
|
|
2385
|
-
}
|
|
2386
2401
|
return acc;
|
|
2387
2402
|
}, {});
|
|
2388
|
-
if (Object.keys(fusedConfig).length)
|
|
2403
|
+
if (Object.keys(fusedConfig).length)
|
|
2389
2404
|
configs2.push([fusedConfig]);
|
|
2390
|
-
}
|
|
2391
2405
|
let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
2392
2406
|
composer = composer.append(
|
|
2393
2407
|
...configs2,
|
|
@@ -2398,6 +2412,16 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2398
2412
|
}
|
|
2399
2413
|
return composer;
|
|
2400
2414
|
}
|
|
2415
|
+
function resolveSubOptions(options, key) {
|
|
2416
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
2417
|
+
}
|
|
2418
|
+
function getOverrides(options, key) {
|
|
2419
|
+
const sub = resolveSubOptions(options, key);
|
|
2420
|
+
return {
|
|
2421
|
+
...options.overrides?.[key],
|
|
2422
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
2401
2425
|
|
|
2402
2426
|
// src/index.ts
|
|
2403
2427
|
var src_default = lincy;
|
|
@@ -2438,6 +2462,7 @@ var src_default = lincy;
|
|
|
2438
2462
|
disables,
|
|
2439
2463
|
ensurePackages,
|
|
2440
2464
|
formatters,
|
|
2465
|
+
getOverrides,
|
|
2441
2466
|
ignores,
|
|
2442
2467
|
imports,
|
|
2443
2468
|
interopDefault,
|
|
@@ -2457,6 +2482,7 @@ var src_default = lincy;
|
|
|
2457
2482
|
regexp,
|
|
2458
2483
|
renamePluginInConfigs,
|
|
2459
2484
|
renameRules,
|
|
2485
|
+
resolveSubOptions,
|
|
2460
2486
|
sortPackageJson,
|
|
2461
2487
|
sortTsconfig,
|
|
2462
2488
|
stylistic,
|