Skip to content

Commit

Permalink
fix(lodash): add missing deps & use scoped imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte authored and Raphaël Benitte committed May 18, 2018
1 parent 66a7208 commit f04660f
Show file tree
Hide file tree
Showing 74 changed files with 178 additions and 78 deletions.
1 change: 1 addition & 0 deletions packages/nivo-bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@nivo/legends": "0.35.0",
"d3-scale": "^1.0.6",
"d3-shape": "^1.2.0",
"lodash": "^4.17.4",
"react-motion": "^0.5.2",
"recompose": "^0.26.0"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/nivo-bar/src/compute/grouped.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { range, min, max } from 'lodash'
import min from 'lodash/min'
import max from 'lodash/max'
import range from 'lodash/range'
import { scaleLinear } from 'd3-scale'
import { getIndexedScale } from './common'

Expand Down
4 changes: 3 additions & 1 deletion packages/nivo-bar/src/compute/stacked.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { flattenDepth, min, max } from 'lodash'
import min from 'lodash/min'
import max from 'lodash/max'
import flattenDepth from 'lodash/flattenDepth'
import { scaleLinear } from 'd3-scale'
import { stack, stackOffsetDiverging } from 'd3-shape'
import { getIndexedScale } from './common'
Expand Down
4 changes: 4 additions & 0 deletions packages/nivo-bar/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

lodash@^4.17.4:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

loose-envify@^1.0.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
Expand Down
1 change: 1 addition & 0 deletions packages/nivo-calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"d3-scale": "^1.0.6",
"d3-time": "^1.0.7",
"d3-time-format": "^2.0.5",
"lodash": "^4.17.4",
"recompose": "^0.26.0"
},
"peerDependencies": {
Expand Down
20 changes: 12 additions & 8 deletions packages/nivo-calendar/src/computeCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
* file that was distributed with this source code.
*/

import _ from 'lodash'
import memoize from 'lodash/memoize'
import isDate from 'lodash/isDate'
import range from 'lodash/range'
import max from 'lodash/max'
import assign from 'lodash/assign'
import { DIRECTION_HORIZONTAL } from './constants'
import { timeFormat } from 'd3-time-format'
import { timeDays, timeWeek, timeWeeks, timeMonths, timeYear } from 'd3-time'
Expand Down Expand Up @@ -113,7 +117,7 @@ const monthPathAndBBox = ({ date, cellSize, yearIndex, yearSpacing, daySpacing,
/**
* Creates a memoized version of monthPathAndBBox function.
*/
const memoMonthPathAndBBox = _.memoize(
const memoMonthPathAndBBox = memoize(
monthPathAndBBox,
({ date, cellSize, yearIndex, yearSpacing, daySpacing, direction }) => {
return `${date.toString()}.${cellSize}.${yearIndex}.${yearSpacing}.${daySpacing}.${direction}`
Expand Down Expand Up @@ -196,12 +200,12 @@ const CalendarLayout = ({
daySpacing,
}) => {
// time related data
const fromDate = _.isDate(from) ? from : new Date(from)
const toDate = _.isDate(to) ? to : new Date(to)
const fromDate = isDate(from) ? from : new Date(from)
const toDate = isDate(to) ? to : new Date(to)

let yearRange = _.range(fromDate.getFullYear(), toDate.getFullYear() + 1)
let yearRange = range(fromDate.getFullYear(), toDate.getFullYear() + 1)
const maxWeeks =
_.max(
max(
yearRange.map(year => timeWeeks(new Date(year, 0, 1), new Date(year + 1, 0, 1)).length)
) + 1

Expand Down Expand Up @@ -237,7 +241,7 @@ const CalendarLayout = ({

days = days.concat(
timeDays(yearStart, yearEnd).map(dayDate =>
_.assign(
assign(
{
date: dayDate,
day: dayFormat(dayDate),
Expand All @@ -249,7 +253,7 @@ const CalendarLayout = ({
)

const yearMonths = timeMonths(yearStart, yearEnd).map(monthDate =>
_.assign(
assign(
{ date: monthDate },
memoMonthPathAndBBox({
date: monthDate,
Expand Down
3 changes: 2 additions & 1 deletion packages/nivo-calendar/src/enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import compose from 'recompose/compose'
import defaultProps from 'recompose/defaultProps'
import withPropsOnChange from 'recompose/withPropsOnChange'
import pure from 'recompose/pure'
import { minBy, maxBy } from 'lodash'
import minBy from 'lodash/minBy'
import maxBy from 'lodash/maxBy'
import { scaleQuantize } from 'd3-scale'
import { withTheme, withDimensions } from '@nivo/core'
import { CalendarDefaultProps } from './props'
Expand Down
4 changes: 4 additions & 0 deletions packages/nivo-calendar/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

lodash@^4.17.4:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

loose-envify@^1.0.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
Expand Down
1 change: 1 addition & 0 deletions packages/nivo-chord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"d3-chord": "^1.0.4",
"d3-format": "^1.2.0",
"d3-shape": "^1.2.0",
"lodash": "^4.17.4",
"react-motion": "^0.5.2",
"recompose": "^0.26.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-chord/src/ChordCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
import React, { Component } from 'react'
import { partial } from 'lodash'
import partial from 'lodash/partial'
import { midAngle, getPolarLabelProps, degreesToRadians } from '@nivo/core'
import { getRelativeCursor, getHoveredArc } from '@nivo/core'
import { Container } from '@nivo/core'
Expand Down
3 changes: 2 additions & 1 deletion packages/nivo-chord/src/ChordRibbons.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/
import React from 'react'
import PropTypes from 'prop-types'
import { isFunction, mapValues } from 'lodash'
import isFunction from 'lodash/isFunction'
import mapValues from 'lodash/mapValues'
import { TransitionMotion, spring } from 'react-motion'
import { format as d3Format } from 'd3-format'
import compose from 'recompose/compose'
Expand Down
4 changes: 4 additions & 0 deletions packages/nivo-chord/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

lodash@^4.17.4:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

loose-envify@^1.0.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
Expand Down
1 change: 1 addition & 0 deletions packages/nivo-circle-packing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@nivo/core": "0.35.0",
"d3-hierarchy": "^1.1.5",
"lodash": "^4.17.4",
"react-motion": "^0.5.2",
"recompose": "^0.26.0"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/nivo-circle-packing/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

lodash@^4.17.4:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

loose-envify@^1.0.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
Expand Down
1 change: 1 addition & 0 deletions packages/nivo-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"d3-scale": "^1.0.6",
"d3-scale-chromatic": "^1.1.1",
"d3-shape": "^1.2.0",
"lodash": "^4.17.4",
"react-measure": "^2.0.2",
"react-motion": "^0.5.2",
"recompose": "^0.26.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-core/src/components/axes/Axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import React from 'react'
import PropTypes from 'prop-types'
import { isEqual } from 'lodash'
import isEqual from 'lodash/isEqual'
import shouldUpdate from 'recompose/shouldUpdate'
import { motionPropTypes } from '../../props'
import Axis, { axisPropType } from './Axis'
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-core/src/components/axes/Axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import React from 'react'
import PropTypes from 'prop-types'
import { isFunction } from 'lodash'
import isFunction from 'lodash/isFunction'
import { format as d3Format } from 'd3-format'
import compose from 'recompose/compose'
import withPropsOnChange from 'recompose/withPropsOnChange'
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-core/src/components/tooltip/BasicTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import React from 'react'
import PropTypes from 'prop-types'
import { isFunction } from 'lodash'
import isFunction from 'lodash/isFunction'
import { format as d3Format } from 'd3-format'
import compose from 'recompose/compose'
import withPropsOnChange from 'recompose/withPropsOnChange'
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-core/src/hocs/withDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
import PropTypes from 'prop-types'
import { isEqual } from 'lodash'
import isEqual from 'lodash/isEqual'
import compose from 'recompose/compose'
import setPropTypes from 'recompose/setPropTypes'
import defaultProps from 'recompose/defaultProps'
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-core/src/hocs/withMotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { partialRight } from 'lodash'
import partialRight from 'lodash/partialRight'
import compose from 'recompose/compose'
import defaultProps from 'recompose/defaultProps'
import withPropsOnChange from 'recompose/withPropsOnChange'
Expand Down
2 changes: 1 addition & 1 deletion packages/nivo-core/src/hocs/withTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PropTypes from 'prop-types'
import compose from 'recompose/compose'
import setPropTypes from 'recompose/setPropTypes'
import withPropsOnChange from 'recompose/withPropsOnChange'
import { merge } from 'lodash'
import merge from 'lodash/merge'
import { defaultTheme } from '../defaults'

/**
Expand Down
14 changes: 8 additions & 6 deletions packages/nivo-core/src/lib/colors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import _ from 'lodash'
import get from 'lodash/get'
import isFunction from 'lodash/isFunction'
import isArray from 'lodash/isArray'
import {
scaleOrdinal,
schemeCategory10,
Expand Down Expand Up @@ -50,29 +52,29 @@ export const getColorRange = instruction => {

if (instruction === 'nivo') return nivoCategoricalColors()

if (_.isFunction(instruction)) return instruction
if (isFunction(instruction)) return instruction

if (ordinalColorScales[instruction]) return ordinalColorScales[instruction]

if (_.isArray(instruction)) return scaleOrdinal(instruction)
if (isArray(instruction)) return scaleOrdinal(instruction)

return () => instruction
}

export const getColorsGenerator = (colors, colorBy) => {
// skip range, color should be bound to data
if (_.isFunction(colorBy)) return colorBy
if (isFunction(colorBy)) return colorBy

let scale
let getColorId = d => _.get(d, colorBy)
let getColorId = d => get(d, colorBy)

if (colors === 'nivo') {
// use default nivo categorical colors
scale = nivoCategoricalColors()
} else if (ordinalColorScales[colors]) {
// use predefined d3 ordinal color scale
scale = ordinalColorScales[colors]
} else if (_.isArray(colors)) {
} else if (isArray(colors)) {
// user defined color range
scale = scaleOrdinal(colors)
} else {
Expand Down
4 changes: 3 additions & 1 deletion packages/nivo-core/src/lib/colors/inherit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memoize, isFunction, get } from 'lodash'
import memoize from 'lodash/memoize'
import isFunction from 'lodash/isFunction'
import get from 'lodash/get'
import { rgb } from 'd3-color'

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/nivo-core/src/lib/colors/quantize.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { last, isArray, isFunction } from 'lodash'
import last from 'lodash/last'
import isArray from 'lodash/isArray'
import isFunction from 'lodash/isFunction'
import { scaleQuantize } from 'd3-scale'
import {
// Diverging
Expand Down
7 changes: 6 additions & 1 deletion packages/nivo-core/src/lib/defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { isFunction, isPlainObject, pick, isEqual, get, set } from 'lodash'
import isFunction from 'lodash/isFunction'
import isPlainObject from 'lodash/isPlainObject'
import pick from 'lodash/pick'
import isEqual from 'lodash/isEqual'
import get from 'lodash/get'
import set from 'lodash/set'
import { gradientTypes, patternTypes } from '../components/defs'

const gradientKeys = Object.keys(gradientTypes)
Expand Down
9 changes: 5 additions & 4 deletions packages/nivo-core/src/lib/propertiesConverters.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import _ from 'lodash'
import isFunction from 'lodash/isFunction'
import get from 'lodash/get'
import { format } from 'd3-format'

export const getLabelGenerator = (_label, labelFormat) => {
const getRawLabel = _.isFunction(_label) ? _label : d => _.get(d, _label)
const getRawLabel = isFunction(_label) ? _label : d => get(d, _label)
let formatter
if (labelFormat) {
formatter = _.isFunction(labelFormat) ? labelFormat : format(labelFormat)
formatter = isFunction(labelFormat) ? labelFormat : format(labelFormat)
}

if (formatter) return d => formatter(getRawLabel(d))
return getRawLabel
}

export const getAccessorFor = directive => (_.isFunction(directive) ? directive : d => d[directive])
export const getAccessorFor = directive => (isFunction(directive) ? directive : d => d[directive])
4 changes: 4 additions & 0 deletions packages/nivo-core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

lodash@^4.17.4:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

loose-envify@^1.0.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
Expand Down
4 changes: 1 addition & 3 deletions packages/nivo-generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
"dependencies": {
"d3-time": "^1.0.7",
"d3-time-format": "^2.0.5",
"lodash.random": "^3.2.0",
"lodash.range": "^3.2.0",
"lodash.shuffle": "^4.2.0"
"lodash": "^4.17.4"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/nivo-generators/src/chord.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import range from 'lodash.range'
import random from 'lodash.random'
import range from 'lodash/range'
import random from 'lodash/random'
import { names } from './sets'

export default ({ keys = names, size = 7, minValue = 0, maxValue = 2000 } = {}) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/nivo-generators/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import range from 'lodash.range'
import random from 'lodash.random'
import shuffle from 'lodash.shuffle'
import range from 'lodash/range'
import random from 'lodash/random'
import shuffle from 'lodash/shuffle'
import { timeDays } from 'd3-time'
import { timeFormat } from 'd3-time-format'
import * as color from './color'
Expand Down
Loading

0 comments on commit f04660f

Please sign in to comment.