From 9e7880b366a670933a200ba62672f09d022adb0c Mon Sep 17 00:00:00 2001 From: bowlingx Date: Wed, 4 Dec 2019 15:49:52 -0600 Subject: [PATCH] chore(linter): fixed linting --- src/lib/utils.ts | 57 ++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c46eabb..3f577be 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -110,7 +110,7 @@ export const applyDiffWithCreateQueriesFromPatch = ( */ export const applyFlatConfigToState = ( config: MappedConfig, - queryValues: {readonly [index: string]:any}, + queryValues: { readonly [index: string]: any }, ns: string, state: object, initialState: object @@ -142,32 +142,37 @@ export const applyFlatConfigToState = ( * that can be used to generate a query string. * @return a key/value object with the object containing the defined parameters as key. */ -export const flattenConfig = - (config: Config, path: readonly string[] = []): MappedConfig => { - return Object.keys(config).reduce((next: {readonly [index: string]:any}, key) => { - const v = config[key] - const nextPath: ReadonlyArray = [...path, key] - if (typeof v === 'function') { - const { name, ...rest } = v() - if (next[name] !== undefined) { - throw new Error( - `Config invalid: Multiple definitions found for ${name}.` - ) - } - return { - ...next, - [name]: { - path: nextPath, - ...rest +export const flattenConfig = ( + config: Config, + path: readonly string[] = [] +): MappedConfig => { + return Object.keys(config).reduce( + (next: { readonly [index: string]: any }, key) => { + const v = config[key] + const nextPath: ReadonlyArray = [...path, key] + if (typeof v === 'function') { + const { name, ...rest } = v() + if (next[name] !== undefined) { + throw new Error( + `Config invalid: Multiple definitions found for ${name}.` + ) + } + return { + ...next, + [name]: { + path: nextPath, + ...rest + } } } - } - if (typeof v === 'object') { - return { - ...next, - ...flattenConfig(v, nextPath) + if (typeof v === 'object') { + return { + ...next, + ...flattenConfig(v, nextPath) + } } - } - return next - }, {}) + return next + }, + {} + ) }