+22
-1
lines changedFilter options
+22
-1
lines changed Original file line number Diff line number Diff line change
@@ -24,10 +24,21 @@ import {
24
24
import type { OptionsConfig } from './types'
25
25
import { combine } from './utils'
26
26
27
+
const flatConfigProps: (keyof FlatESLintConfigItem)[] = [
28
+
'files',
29
+
'ignores',
30
+
'languageOptions',
31
+
'linterOptions',
32
+
'processor',
33
+
'plugins',
34
+
'rules',
35
+
'settings',
36
+
]
37
+
27
38
/**
28
39
* Construct an array of ESLint flat config items.
29
40
*/
30
-
export function antfu(options: OptionsConfig = {}, ...userConfigs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]) {
41
+
export function antfu(options: OptionsConfig & FlatESLintConfigItem = {}, ...userConfigs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]) {
31
42
const isInEditor = options.isInEditor ?? !!((process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !process.env.CI)
32
43
const enableVue = options.vue ?? (isPackageExists('vue') || isPackageExists('nuxt') || isPackageExists('vitepress') || isPackageExists('@slidev/cli'))
33
44
const enableTypeScript = options.typescript ?? (isPackageExists('typescript'))
@@ -85,6 +96,16 @@ export function antfu(options: OptionsConfig = {}, ...userConfigs: (FlatESLintCo
85
96
if (options.markdown ?? true)
86
97
configs.push(markdown({ componentExts }))
87
98
99
+
// User can optionally pass a flat config item to the first argument
100
+
// We pick the known keys as ESLint would do schema validation
101
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
102
+
if (key in options)
103
+
acc[key] = options[key]
104
+
return acc
105
+
}, {} as FlatESLintConfigItem)
106
+
if (Object.keys(fusedConfig).length)
107
+
configs.push([fusedConfig])
108
+
88
109
return combine(
89
110
...configs,
90
111
...userConfigs,
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4