Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Feb 22, 2018
1 parent 327eea8 commit c1eb1ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
10 changes: 5 additions & 5 deletions packages/metascraper-soundcloud/index.js
Original file line number Diff line number Diff line change
@@ -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}
)
]
})
44 changes: 16 additions & 28 deletions packages/metascraper/src/load-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit c1eb1ef

Please sign in to comment.