Skip to content

Commit 9463915

Browse files
committed
Clean up module details
1 parent 1005beb commit 9463915

File tree

6 files changed

+43
-21
lines changed

6 files changed

+43
-21
lines changed

.eslintrc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
}
88
},
99
"rules": {
10-
"semi": 2
11-
}
10+
"semi": 2,
11+
"no-unused-vars": 2,
12+
"react/display-name": 2,
13+
"react/jsx-key": 2,
14+
"react/jsx-no-comment-textnodes": 2,
15+
"react/jsx-no-duplicate-props": 2,
16+
"react/jsx-no-target-blank": 2,
17+
"react/jsx-no-undef": 2,
18+
"react/jsx-uses-react": 2,
19+
"react/jsx-uses-vars": 2,
20+
"react/no-children-prop": 2,
21+
"react/no-danger-with-children": 2,
22+
"react/no-deprecated": 2,
23+
"react/no-direct-mutation-state": 2,
24+
"react/no-find-dom-node": 2,
25+
"react/no-is-mounted": 2,
26+
"react/no-render-return-value": 2,
27+
"react/no-string-refs": 2,
28+
"react/no-unescaped-entities": 2,
29+
"react/no-unknown-property": 2,
30+
"react/prop-types": 2,
31+
"react/react-in-jsx-scope": 2,
32+
"react/require-render-return": 2,
33+
},
34+
"plugins": [
35+
"react"
36+
]
1237
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
4242
| `frames` | `Array` | `undefined` | list of frame objects |
4343
| `fit` | `Boolean` | `false` | When true, disregards `layout.width` and `layout.height` and fits to the parent div size, updating on `window.resize` |
4444
| `debug` | `Boolean` | `false` | Assign the graph div to `window.gd` for debugging |
45-
| `onInitialized | `Function` | null | Callback executed once after plot is initialized |
46-
| `onUpdate | `Function` | null | Callback executed when a plotly.js API method is invoked |
47-
| `onError | `Function` | null | Callback executed when a plotly.js API method rejects |
45+
| `onInitialized` | `Function` | null | Callback executed once after plot is initialized |
46+
| `onUpdate` | `Function` | null | Callback executed when a plotly.js API method is invoked |
47+
| `onError` | `Function` | null | Callback executed when a plotly.js API method rejects |
4848

4949
### Event handler props
5050

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"start": "budo example/src/index.js --dir example/src --dir example --open --live --host localhost -- -p [ css-modulesify --after autoprefixer --autoprefixer.browsers \"> 5%\" -o example/assets/styles.css ] -t [ babelify --presets [ es2015 react ] --plugins transform-class-properties ] -t brfs",
1717
"example:build:html": "cp example/src/index.html example/dist/index.html",
18-
"example:build:js": "browserify example/src/index.js -p [ css-modulesify --after autoprefixer --autoprefixer.browsers \"> 5%\" -o example/dist/styles.css ] -t [ babelify --presets [ es2015 react ] --plugins transform-class-properties ] -t brfs -g [ envify --NODE_ENV production ] -g uglifyify -p bundle-collapser/plugin | uglifyjs --compress --mangle > example/dist/index.js",
18+
"example:build:js": "browserify example/src/index.js -p [ css-modulesify --after autoprefixer --autoprefixer.browsers \"> 5%\" -o example/dist/styles.css ] -t [ babelify --presets [ es2015 react ] --plugins transform-class-properties ] -t brfs -g [ envify --NODE_ENV production ] -p bundle-collapser/plugin | uglifyjs --compress --mangle > example/dist/index.js",
1919
"example:build:assets": "rm -rf example/dist/assets && cp -r example/assets example/dist/assets",
2020
"example:build": "rm -rf example/dist && mkdir -p example/dist && npm run example:build:html && npm run example:build:js && npm run example:build:assets",
2121
"example:deploy": "netlify deploy example/dist",
@@ -56,6 +56,7 @@
5656
"envify": "^4.1.0",
5757
"enzyme": "^2.9.1",
5858
"eslint": "^4.8.0",
59+
"eslint-plugin-react": "^7.4.0",
5960
"event-emitter": "^0.3.5",
6061
"gl": "^4.0.4",
6162
"husky": "^0.14.3",
@@ -66,7 +67,6 @@
6667
"netlify-cli": "^1.2.2",
6768
"nodemon": "^1.11.0",
6869
"onetime": "^1.1.0",
69-
"plotly.js": "^1.29.2",
7070
"prettier": "^1.5.3",
7171
"react": "^15.6.1",
7272
"react-addons-test-utils": "^15.6.0",
@@ -75,8 +75,10 @@
7575
"react-dom": "^15.6.1",
7676
"react-test-renderer": "^15.6.1",
7777
"throttle-debounce": "^1.0.1",
78-
"uglify-js": "^3.0.26",
79-
"uglifyify": "^4.0.3"
78+
"uglify-js": "^3.0.26"
79+
},
80+
"peerDependencies": {
81+
"plotly.js": ">1.0.0"
8082
},
8183
"browserify-global-shim": {
8284
"react": "React"

src/__mocks__/plotly.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default {
3131
}, ASYNC_DELAY);
3232
}),
3333
update: jest.fn(),
34-
purge: jest.fn(gd => {
34+
purge: jest.fn(() => {
3535
state.gd = nll;
3636
}),
3737
};

src/__tests__/react-plotly.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { mount, shallow } from "enzyme";
2+
import { mount } from "enzyme";
33
import createComponent from "../react-plotly";
44
import once from "onetime";
55

@@ -141,7 +141,6 @@ describe("<Plotly/>", () => {
141141
describe("responding to window events", () => {
142142
describe("with fit: true", () => {
143143
test("does not call relayout on initialization", done => {
144-
let relayoutCnt = 0;
145144
createPlot({
146145
fit: true,
147146
onRelayout: () => done.fail("Unexpected relayout event"),
@@ -172,7 +171,6 @@ describe("<Plotly/>", () => {
172171

173172
describe("with fit: false", () => {
174173
test("does not call relayout on init", done => {
175-
let relayoutCnt = 0;
176174
createPlot({
177175
fit: false,
178176
onRelayout: () => done.fail("Unexpected relayout event"),
@@ -184,7 +182,6 @@ describe("<Plotly/>", () => {
184182
});
185183

186184
test("does not call relayout on window resize", done => {
187-
let relayoutCnt = 0;
188185
createPlot({
189186
fit: false,
190187
onRelayout: () => done.fail("Unexpected relayout event"),

src/react-plotly.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import React, { Component } from "react";
22
import PropTypes from "prop-types";
33
import isNumeric from "fast-isnumeric";
44
import objectAssign from "object-assign";
5-
import throttle from "throttle-debounce/throttle";
6-
7-
function constructUpdate(diff) {
8-
var keys = Object.keys(diff);
9-
}
5+
// import throttle from "throttle-debounce/throttle";
106

117
// The naming convention is:
128
// - events are attached as `'plotly_' + eventName.toLowerCase()`
@@ -95,7 +91,6 @@ export default function createPlotlyComponent(Plotly) {
9591
}
9692

9793
componentWillReceiveProps(nextProps) {
98-
let dataDiff, layoutDiff, configDiff;
9994
let nextLayout = this.sizeAdjustedLayout(nextProps.layout);
10095

10196
this.p = this.p
@@ -256,14 +251,17 @@ export default function createPlotlyComponent(Plotly) {
256251
layout: PropTypes.object,
257252
frames: PropTypes.arrayOf(PropTypes.object),
258253
onInitialized: PropTypes.func,
254+
onError: PropTypes.func,
255+
onUpdate: PropTypes.func,
256+
debug: PropTypes.bool,
259257
};
260258

261259
for (let i = 0; i < eventNames.length; i++) {
262260
PlotlyComponent.propTypes["on" + eventNames[i]] = PropTypes.func;
263261
}
264262

265263
PlotlyComponent.defaultProps = {
266-
debug: true,
264+
debug: false,
267265
fit: false,
268266
data: [],
269267
};

0 commit comments

Comments
 (0)