Skip to content

Commit

Permalink
Integrate prettier & eslint code styles + add linting as part of npm …
Browse files Browse the repository at this point in the history
…test (#58)

* Add prettier & eslint code style rules

* Include eslint process with npm test
  • Loading branch information
Kris Salvador authored and dandelany committed Apr 26, 2018
1 parent afb288e commit 5316e46
Show file tree
Hide file tree
Showing 78 changed files with 6,171 additions and 2,482 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"parser": "babel-eslint",
"extends": ["plugin:prettier/recommended"]
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
</div>

<div class="container-fluid" id="container">Loading...</div>
<script type="text/javascript" src="bundle.3d450b6d776ceddf9090.js"></script></body>
<script type="text/javascript" src="bundle.86be3b18d63cabf441b4.js"></script></body>
</html>
2 changes: 1 addition & 1 deletion docs/src/docs/AreaBarChart/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"required": false,
"description": "Class attribute to be applied to each bar.\nor accessor function which returns a class;",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/AreaChart/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"required": false,
"description": "if shouldShowGaps is true, isDefined function describes when a datum should be considered \"defined\" vs. when to show gap\nby default, shows gap if either y or yEnd are undefined",
"defaultValue": {
"value": "(d, i, accessors) => {\n return !_.isUndefined(accessors.y(d, i)) && !_.isUndefined(accessors.yEnd(d, i));\n}",
"value": "(d, i, accessors) => {\n return (\n !_.isUndefined(accessors.y(d, i)) &&\n !_.isUndefined(accessors.yEnd(d, i))\n );\n}",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/AreaHeatmap/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/Bar/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"required": false,
"description": "Class name(s) to be included on the bar's <rect> element",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/BarChart/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"required": false,
"description": "Class attribute to be applied to each bar.\nor accessor function which returns a class;",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/ColorHeatmap/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "'lab'",
"value": "\"lab\"",
"computed": false
}
},
Expand Down Expand Up @@ -144,7 +144,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
}
Expand Down
22 changes: 7 additions & 15 deletions docs/src/docs/Histogram/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,18 @@
"name": "array"
},
"required": true,
"description": "the array of data objects",
"description": "The array of data objects for the histogram.\nThese should be individual \"samples\" or \"facts\", not an array of bins -\nthis component will count and bin the samples for you. If you have data that is already binned,\nuse the `<AreaBarChart>` component.",
"defaultValue": {
"value": "[]",
"computed": false
}
},
"value": {
"type": {
"name": "custom",
"raw": "CustomPropTypes.valueOrAccessor"
},
"required": false,
"description": ""
},
"axisType": {
"type": {
"name": "object"
"name": "func"
},
"required": false,
"description": ""
"description": "Data value accessor function, called once per datum, which returns the values to bin and plot in the histogram.\nIf `data` is just an array of numbers, this may be the identity function (`function(d) { return d }`)."
},
"xScale": {
"type": {
Expand Down Expand Up @@ -120,14 +112,14 @@
"name": "array"
},
"required": false,
"description": "The domain to which your data will be mapped and binned. binDomain is defined as an array `[min, max]`.\n\nWarning: This prop takes priority if `nice = true`"
"description": "The domain over which your data will be binned. Defined as an array `[min, max]`.\nIf not provided, binDomain will be the domain of your data values by default.\n\nWarning: This prop takes priority if `nice = true`."
},
"nice": {
"type": {
"name": "bool"
},
"required": false,
"description": "Nicely rounds the start and end values of your bins. Implemented using [d3's ticks nicing logic](https://github.com/d3/d3-array#ticks)",
"description": "If true, nicely rounds the start and end values of your bins.\nImplemented using [d3's ticks nicing logic](https://github.com/d3/d3-array#ticks).",
"defaultValue": {
"value": "false",
"computed": false
Expand All @@ -146,7 +138,7 @@
]
},
"required": false,
"description": "Class attribute to be applied to each bar.\nor accessor function which returns a class;"
"description": "Class attribute to be applied to each bar,\nor accessor function which returns a class."
},
"barStyle": {
"type": {
Expand All @@ -161,7 +153,7 @@
]
},
"required": false,
"description": "Inline style object to be applied to each bar,\nor accessor function which returns a style object;"
"description": "Inline style object to be applied to each bar,\nor accessor function which returns a style object."
},
"onMouseMoveBar": {
"type": {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/KernelDensityEstimation/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/LineChart/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"required": false,
"description": "Class attribute to be applied to the line path",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/MeasuredValueLabel/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"style": {
"defaultValue": {
"value": "{\n fontFamily: \"Helvetica, sans-serif\",\n fontSize: '20px',\n lineHeight: 1,\n textAnchor: 'middle'\n}",
"value": "{\n fontFamily: \"Helvetica, sans-serif\",\n fontSize: \"20px\",\n lineHeight: 1,\n textAnchor: \"middle\"\n}",
"computed": false
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/PieChart/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "'marker-line'",
"value": "\"marker-line\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/RangeBarChart/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"required": false,
"description": "Class attribute to be applied to each bar.\nor accessor function which returns a class;",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/RangeRect/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"required": false,
"description": "Class attribute to be applied to the rectangle element",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
8 changes: 4 additions & 4 deletions docs/src/docs/SankeyDiagram/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@
"required": false,
"description": "Attributes object to be applied to each node terminal element,\nor accessor function which returns an object.",
"defaultValue": {
"value": "{rx: 2, ry: 2}",
"value": "{ rx: 2, ry: 2 }",
"computed": false
}
},
Expand Down Expand Up @@ -736,7 +736,7 @@
"required": false,
"description": "Accessor function `f(link, graph)` which returns the text to be used for link labels.",
"defaultValue": {
"value": "(link, graph, props) => {\n const valueText = numeral(link.value || 0).format(\"0.[0]a\");\n const sourceText = getValue(props.nodeLabelText, link.source, graph, props);\n const targetText = getValue(props.nodeLabelText, link.target, graph, props);\n return `${sourceText}→${targetText}: ${valueText}`;\n}",
"value": "(link, graph, props) => {\n const valueText = numeral(link.value || 0).format(\"0.[0]a\");\n const sourceText = getValue(\n props.nodeLabelText,\n link.source,\n graph,\n props\n );\n const targetText = getValue(\n props.nodeLabelText,\n link.target,\n graph,\n props\n );\n return `${sourceText}→${targetText}: ${valueText}`;\n}",
"computed": false
}
},
Expand Down Expand Up @@ -842,7 +842,7 @@
"required": false,
"description": "Accessor function `f(link, graph)` which returns the text to be used for link *source* labels.",
"defaultValue": {
"value": "(link, graph, props) => {\n const valueRelative = link.valueSourceRelative;\n if (!_.isFinite(valueRelative)) return \"\";\n const percentText = valueRelative < 0.001 ? \"<0.1%\" : numeral(valueRelative).format(\"0.[0]%\");\n return `${percentText} to ${getValue(props.nodeLabelText, link.target, graph, props)}`;\n}",
"value": "(link, graph, props) => {\n const valueRelative = link.valueSourceRelative;\n if (!_.isFinite(valueRelative)) return \"\";\n const percentText =\n valueRelative < 0.001\n ? \"<0.1%\"\n : numeral(valueRelative).format(\"0.[0]%\");\n return `${percentText} to ${getValue(\n props.nodeLabelText,\n link.target,\n graph,\n props\n )}`;\n}",
"computed": false
}
},
Expand Down Expand Up @@ -948,7 +948,7 @@
"required": false,
"description": "Accessor function `f(link, graph)` which returns the text to be used for link *target* labels.",
"defaultValue": {
"value": "(link, graph, props) => {\n const valueRelative = link.valueTargetRelative;\n if (!_.isFinite(valueRelative)) return \"\";\n const percentText = valueRelative < 0.001 ? \"<0.1%\" : numeral(valueRelative).format(\"0.[0]%\");\n return `${percentText} from ${getValue(props.nodeLabelText, link.source, graph, props)}`;\n}",
"value": "(link, graph, props) => {\n const valueRelative = link.valueTargetRelative;\n if (!_.isFinite(valueRelative)) return \"\";\n const percentText =\n valueRelative < 0.001\n ? \"<0.1%\"\n : numeral(valueRelative).format(\"0.[0]%\");\n return `${percentText} from ${getValue(\n props.nodeLabelText,\n link.source,\n graph,\n props\n )}`;\n}",
"computed": false
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/ScatterPlot/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "[0,0]",
"value": "[0, 0]",
"computed": false
}
},
Expand All @@ -181,7 +181,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
Expand Down
10 changes: 5 additions & 5 deletions docs/src/docs/TreeMap/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "'value'",
"value": "\"value\"",
"computed": false
}
},
Expand All @@ -43,7 +43,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "'children'",
"value": "\"children\"",
"computed": false
}
},
Expand All @@ -55,7 +55,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "'name'",
"value": "\"name\"",
"computed": false
}
},
Expand Down Expand Up @@ -188,7 +188,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "class TreeMapNode extends React.Component {\n static propTypes = {\n node: PropTypes.shape({\n parent: PropTypes.object,\n children: PropTypes.array,\n value: PropTypes.number,\n depth: PropTypes.number,\n x: PropTypes.number,\n y: PropTypes.number,\n dx: PropTypes.number,\n dy: PropTypes.number\n }),\n nodeStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n minLabelWidth: PropTypes.number,\n minLabelHeight: PropTypes.number,\n\n getLabel: CustomPropTypes.getter,\n labelStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n NodeLabelComponent: PropTypes.func\n };\n static defaultProps = {\n minLabelWidth: 0,\n minLabelHeight: 0\n };\n\n render() {\n const {node, getLabel, nodeStyle, labelStyle, minLabelWidth, minLabelHeight, NodeLabelComponent, parentNames}\n = this.props;\n const {depth, parent, x0, y0, x1, y1} = node;\n\n var parentName = _.get(parent, 'data.name');\n const nodeGroupClass = parent ?\n `node-group-${_.kebabCase(parentName)} node-group-i-${parentNames.indexOf(parentName)}` : '';\n const className = `tree-map-node node-depth-${depth} ${nodeGroupClass}`;\n\n let style = {position: 'absolute', width: (x1 - x0), height: (y1 - y0), top: y0, left: x0, transition: \"all .2s\"};\n const customStyle = _.isFunction(nodeStyle) ? nodeStyle(node) : (_.isObject(nodeStyle) ? nodeStyle : {});\n _.assign(style, customStyle);\n\n let handlers = ['onClick', 'onMouseEnter', 'onMouseLeave', 'onMouseMove'].reduce((handlers, eventName) => {\n const handler = this.props[`${eventName}Node`];\n if(handler) handlers[eventName] = handler.bind(null, node);\n return handlers;\n }, {});\n\n return <div {...{className, style}} {...handlers}>\n {(x1 - x0) > minLabelWidth && (y1 - y0) > minLabelHeight ? // show label if node is big enough\n <NodeLabelComponent {...{node, getLabel, labelStyle}} />\n : null\n }\n </div>;\n }\n}",
"value": "class TreeMapNode extends React.Component {\n static propTypes = {\n node: PropTypes.shape({\n parent: PropTypes.object,\n children: PropTypes.array,\n value: PropTypes.number,\n depth: PropTypes.number,\n x: PropTypes.number,\n y: PropTypes.number,\n dx: PropTypes.number,\n dy: PropTypes.number\n }),\n nodeStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n minLabelWidth: PropTypes.number,\n minLabelHeight: PropTypes.number,\n\n getLabel: CustomPropTypes.getter,\n labelStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n NodeLabelComponent: PropTypes.func\n };\n static defaultProps = {\n minLabelWidth: 0,\n minLabelHeight: 0\n };\n\n render() {\n const {\n node,\n getLabel,\n nodeStyle,\n labelStyle,\n minLabelWidth,\n minLabelHeight,\n NodeLabelComponent,\n parentNames\n } = this.props;\n const { depth, parent, x0, y0, x1, y1 } = node;\n\n var parentName = _.get(parent, \"data.name\");\n const nodeGroupClass = parent\n ? `node-group-${_.kebabCase(\n parentName\n )} node-group-i-${parentNames.indexOf(parentName)}`\n : \"\";\n const className = `tree-map-node node-depth-${depth} ${nodeGroupClass}`;\n\n let style = {\n position: \"absolute\",\n width: x1 - x0,\n height: y1 - y0,\n top: y0,\n left: x0,\n transition: \"all .2s\"\n };\n const customStyle = _.isFunction(nodeStyle)\n ? nodeStyle(node)\n : _.isObject(nodeStyle)\n ? nodeStyle\n : {};\n _.assign(style, customStyle);\n\n let handlers = [\n \"onClick\",\n \"onMouseEnter\",\n \"onMouseLeave\",\n \"onMouseMove\"\n ].reduce((handlers, eventName) => {\n const handler = this.props[`${eventName}Node`];\n if (handler) handlers[eventName] = handler.bind(null, node);\n return handlers;\n }, {});\n\n return (\n <div {...{ className, style }} {...handlers}>\n {x1 - x0 > minLabelWidth && y1 - y0 > minLabelHeight ? ( // show label if node is big enough\n <NodeLabelComponent {...{ node, getLabel, labelStyle }} />\n ) : null}\n </div>\n );\n }\n}",
"computed": false
}
},
Expand All @@ -199,7 +199,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "class TreeMapNodeLabel extends React.Component {\n static propTypes = {\n node: PropTypes.object,\n getLabel: CustomPropTypes.getter,\n labelStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n minLabelWidth: PropTypes.number,\n minLabelHeight: PropTypes.number\n };\n\n render() {\n const {node, getLabel, labelStyle} = this.props;\n const {x1, x0} = node;\n let style = {width: (x1 - x0)};\n const customStyle = _.isFunction(labelStyle) ? labelStyle(node) : (_.isObject(labelStyle) ? labelStyle : {});\n _.assign(style, customStyle);\n\n return <div className=\"node-label\" {...{style}}>\n {makeAccessor(getLabel)(node)}\n </div>\n }\n}",
"value": "class TreeMapNodeLabel extends React.Component {\n static propTypes = {\n node: PropTypes.object,\n getLabel: CustomPropTypes.getter,\n labelStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),\n minLabelWidth: PropTypes.number,\n minLabelHeight: PropTypes.number\n };\n\n render() {\n const { node, getLabel, labelStyle } = this.props;\n const { x1, x0 } = node;\n let style = { width: x1 - x0 };\n const customStyle = _.isFunction(labelStyle)\n ? labelStyle(node)\n : _.isObject(labelStyle)\n ? labelStyle\n : {};\n _.assign(style, customStyle);\n\n return (\n <div className=\"node-label\" {...{ style }}>\n {makeAccessor(getLabel)(node)}\n </div>\n );\n }\n}",
"computed": false
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/XAxis/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"required": false,
"description": "",
"defaultValue": {
"value": "'bottom'",
"value": "\"bottom\"",
"computed": false
}
},
Expand Down
6 changes: 3 additions & 3 deletions docs/src/docs/XAxisLabels/propDocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
},
"position": {
"defaultValue": {
"value": "'bottom'",
"value": "\"bottom\"",
"computed": false
}
},
Expand Down Expand Up @@ -131,13 +131,13 @@
},
"labelClassName": {
"defaultValue": {
"value": "''",
"value": "\"\"",
"computed": false
}
},
"labelStyle": {
"defaultValue": {
"value": "{\n fontFamily: \"Helvetica, sans-serif\",\n fontSize: '14px',\n lineHeight: 1,\n textAnchor: 'middle'\n}",
"value": "{\n fontFamily: \"Helvetica, sans-serif\",\n fontSize: \"14px\",\n lineHeight: 1,\n textAnchor: \"middle\"\n}",
"computed": false
}
},
Expand Down
Loading

0 comments on commit 5316e46

Please sign in to comment.