From 828da4fba8914be74666cde3b381ce0b3ac4160c Mon Sep 17 00:00:00 2001 From: Andrew Kaiser Date: Mon, 4 Mar 2019 22:08:53 -0500 Subject: [PATCH] address lint --- src/settings/config/normalize.ts | 53 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/settings/config/normalize.ts b/src/settings/config/normalize.ts index 8adaf55..1f3eccc 100644 --- a/src/settings/config/normalize.ts +++ b/src/settings/config/normalize.ts @@ -48,36 +48,39 @@ const normalizeInputs = (inputsInit: ConfigInit['input']) => { } // TODO use type guards -const normalizeDownload = (download: DownloadConfigInit): DownloadConfig => - typeof download === 'string' - ? { - ...defaults.download, - urlTemplate: download - } - : { - ...defaults.download, - ...download, - method: download.method || defaults.download.method - } +const normalizeDownload = (download: DownloadConfigInit): DownloadConfig | undefined => + download === undefined + ? undefined + : typeof download === 'string' + ? { + ...defaults.download, + urlTemplate: download + } + : { + ...defaults.download, + ...download, + method: download.method || defaults.download.method + } -const normalizeParse = (parse: ParseConfigInit): ParseConfig => - typeof parse === 'string' - ? { - ...defaults.parse, - selector: parse - } - : { - ...defaults.parse, - ...parse, - expect: parse.expect || defaults.parse.expect - } +const normalizeParse = (parse: ParseConfigInit): ParseConfig | undefined => + parse === undefined + ? undefined + : typeof parse === 'string' + ? { + ...defaults.parse, + selector: parse + } + : { + ...defaults.parse, + ...parse, + expect: parse.expect || defaults.parse.expect + } const normalizeDefinition = (scrapeConfig: ScrapeConfigInit): ScrapeConfig => ({ ...defaults.definition, ...scrapeConfig, - download: - scrapeConfig.download === undefined ? undefined : normalizeDownload(scrapeConfig.download), - parse: scrapeConfig.parse === undefined ? undefined : normalizeParse(scrapeConfig.parse) + download: normalizeDownload(scrapeConfig.download), + parse: normalizeParse(scrapeConfig.parse) }) const normalizeScraperDefs = (scraperDefs: ConfigInit['scrapers']) => {