Refactor util functions (#2616)
* Refactor getAllConfigs util function * Update eslint parser options to ES2020
This commit is contained in:
parent
d86cf0da8d
commit
77ef260156
1 changed files with 8 additions and 10 deletions
|
|
@ -1,21 +1,19 @@
|
|||
import defaultConfig from '../../stubs/defaultConfig.stub.js'
|
||||
import { flagEnabled } from '../featureFlags'
|
||||
import { flatMap, get, isFunction } from 'lodash'
|
||||
|
||||
export default function getAllConfigs(config) {
|
||||
const configs = flatMap([...get(config, 'presets', [defaultConfig])].reverse(), (preset) => {
|
||||
return getAllConfigs(isFunction(preset) ? preset() : preset)
|
||||
})
|
||||
const configs = (config?.presets ?? [defaultConfig])
|
||||
.slice()
|
||||
.reverse()
|
||||
.flatMap((preset) => getAllConfigs(preset instanceof Function ? preset() : preset))
|
||||
|
||||
const features = {
|
||||
// Add experimental configs here...
|
||||
}
|
||||
|
||||
Object.keys(features).forEach((feature) => {
|
||||
if (flagEnabled(config, feature)) {
|
||||
configs.unshift(features[feature])
|
||||
}
|
||||
})
|
||||
const experimentals = Object.keys(features)
|
||||
.filter((feature) => flagEnabled(config, feature))
|
||||
.map((feature) => features[feature])
|
||||
|
||||
return [config, ...configs]
|
||||
return [config, ...experimentals, ...configs]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue