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 {
2525import type { OptionsConfig } from './types'
2626import { combine } from './utils'
2727
28+ const flatConfigProps : ( keyof FlatESLintConfigItem ) [ ] = [
29+ 'files' ,
30+ 'ignores' ,
31+ 'languageOptions' ,
32+ 'linterOptions' ,
33+ 'processor' ,
34+ 'plugins' ,
35+ 'rules' ,
36+ 'settings' ,
37+ ]
38+
2839/**
2940 * Construct an array of ESLint flat config items.
3041 */
31- export function coderwyd ( options : OptionsConfig = { } , ...userConfigs : ( FlatESLintConfigItem | FlatESLintConfigItem [ ] ) [ ] ) {
42+ export function coderwyd ( options : OptionsConfig & FlatESLintConfigItem = { } , ...userConfigs : ( FlatESLintConfigItem | FlatESLintConfigItem [ ] ) [ ] ) {
3243 const isInEditor = options . isInEditor ?? ! ! ( ( process . env . VSCODE_PID || process . env . JETBRAINS_IDE ) && ! process . env . CI )
3344
3445 const enableVue = options . vue ?? ( isPackageExists ( 'vue' ) || isPackageExists ( 'nuxt' ) || isPackageExists ( 'vitepress' ) || isPackageExists ( '@slidev/cli' ) )
@@ -96,6 +107,16 @@ export function coderwyd(options: OptionsConfig = {}, ...userConfigs: (FlatESLin
96107 if ( options . markdown ?? true )
97108 configs . push ( markdown ( { componentExts } ) )
98109
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+
99120 return combine (
100121 ...configs ,
101122 ...userConfigs ,
You can’t perform that action at this time.
0 commit comments