File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,21 @@ import {
25
25
import type { OptionsConfig } from './types'
26
26
import { combine } from './utils'
27
27
28
+ const flatConfigProps : ( keyof FlatESLintConfigItem ) [ ] = [
29
+ 'files' ,
30
+ 'ignores' ,
31
+ 'languageOptions' ,
32
+ 'linterOptions' ,
33
+ 'processor' ,
34
+ 'plugins' ,
35
+ 'rules' ,
36
+ 'settings' ,
37
+ ]
38
+
28
39
/**
29
40
* Construct an array of ESLint flat config items.
30
41
*/
31
- export function coderwyd ( options : OptionsConfig = { } , ...userConfigs : ( FlatESLintConfigItem | FlatESLintConfigItem [ ] ) [ ] ) {
42
+ export function coderwyd ( options : OptionsConfig & FlatESLintConfigItem = { } , ...userConfigs : ( FlatESLintConfigItem | FlatESLintConfigItem [ ] ) [ ] ) {
32
43
const isInEditor = options . isInEditor ?? ! ! ( ( process . env . VSCODE_PID || process . env . JETBRAINS_IDE ) && ! process . env . CI )
33
44
34
45
const enableVue = options . vue ?? ( isPackageExists ( 'vue' ) || isPackageExists ( 'nuxt' ) || isPackageExists ( 'vitepress' ) || isPackageExists ( '@slidev/cli' ) )
@@ -96,6 +107,16 @@ export function coderwyd(options: OptionsConfig = {}, ...userConfigs: (FlatESLin
96
107
if ( options . markdown ?? true )
97
108
configs . push ( markdown ( { componentExts } ) )
98
109
110
+ // User can optionally pass a flat config item to the first argument
111
+ // We pick the known keys as ESLint would do schema validation
112
+ const fusedConfig = flatConfigProps . reduce ( ( acc , key ) => {
113
+ if ( key in options )
114
+ acc [ key ] = options [ key ]
115
+ return acc
116
+ } , { } as FlatESLintConfigItem )
117
+ if ( Object . keys ( fusedConfig ) . length )
118
+ configs . push ( [ fusedConfig ] )
119
+
99
120
return combine (
100
121
...configs ,
101
122
...userConfigs ,
You can’t perform that action at this time.
0 commit comments