From c1eb1ef27a6c22abf4c04e7d791e662617345297 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Thu, 22 Feb 2018 22:26:33 +0100 Subject: [PATCH] Fix lint --- packages/metascraper-soundcloud/index.js | 10 +++--- packages/metascraper/src/load-rules.js | 44 +++++++++--------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/packages/metascraper-soundcloud/index.js b/packages/metascraper-soundcloud/index.js index 7d32d9282..adb893b8e 100644 --- a/packages/metascraper-soundcloud/index.js +++ b/packages/metascraper-soundcloud/index.js @@ -1,19 +1,19 @@ 'use strict' -const { getValue, titleize } = require('@metascraper/helpers') +const {getValue, titleize} = require('@metascraper/helpers') module.exports = () => ({ author: [ - ({ htmlDom: $, meta, url: baseUrl }) => - titleize(getValue($, $('.soundTitle__username'))) + ({htmlDom: $, meta, url: baseUrl}) => + titleize(getValue($, $('.soundTitle__username'))) ], description: [ - ({ htmlDom: $, meta, url: baseUrl }) => + ({htmlDom: $, meta, url: baseUrl}) => titleize( $('.soundTitle__description') .first() .text(), - { capitalize: false } + {capitalize: false} ) ] }) diff --git a/packages/metascraper/src/load-rules.js b/packages/metascraper/src/load-rules.js index e4dd29f28..11d242b3f 100644 --- a/packages/metascraper/src/load-rules.js +++ b/packages/metascraper/src/load-rules.js @@ -4,16 +4,7 @@ const cwd = process.env.METASCRAPER_CWD || process.cwd() const config = require('cosmiconfig')('metascraper').load(cwd) const resolveFrom = require('resolve-from') -const { - map, - findIndex, - forEach, - chain, - isObject, - isArray, - isString, - get -} = require('lodash') +const {map, findIndex, forEach, chain, isObject, isArray, isString, get} = require('lodash') const DEFAULT_RULES = [ 'metascraper-author', @@ -30,25 +21,22 @@ const DEFAULT_RULES = [ const load = rules => chain(rules) - // merge rules with same props - .reduce((acc, rules) => { - forEach(rules, function (rule, propName) { - const index = findIndex(acc, item => item[propName]) - if (index !== -1) { - acc[index][propName] = acc[index][propName].concat(rule) - } else { - acc.push({ [propName]: rule }) - } + // merge rules with same props + .reduce((acc, rules) => { + forEach(rules, function (rule, propName) { + const index = findIndex(acc, item => item[propName]) + if (index !== -1) acc[index][propName] = acc[index][propName].concat(rule) + else acc.push({[propName]: rule}) + }) + return acc + }, []) + // export an array interface, it's easier to iterate + .map(obj => { + const key = Object.keys(obj)[0] + const value = obj[key] + return [key, value] }) - return acc - }, []) - // export an array interface, it's easier to iterate - .map(obj => { - const key = Object.keys(obj)[0] - const value = obj[key] - return [key, value] - }) - .value() + .value() const autoload = async () => { const configFile = await config