Skip to content

Commit 5bb2d18

Browse files
committed
Sync dev tools with other plotly react projects; fix linter issues
1 parent b5bdd6f commit 5bb2d18

File tree

7 files changed

+331
-88
lines changed

7 files changed

+331
-88
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["react", "es2015"],
2+
"presets": ["react", "env"]
33
}

.eslintrc

+284-28
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,298 @@
11
{
2+
"extends": [
3+
"eslint:recommended",
4+
"prettier"
5+
],
6+
"parser": "babel-eslint",
27
"parserOptions": {
38
"ecmaVersion": 6,
49
"sourceType": "module",
510
"ecmaFeatures": {
11+
"arrowFunctions": true,
12+
"blockBindings": true,
13+
"classes": true,
14+
"defaultParams": true,
15+
"destructuring": true,
16+
"forOf": true,
17+
"generators": true,
18+
"modules": true,
19+
"templateStrings": true,
620
"jsx": true
721
}
822
},
9-
"rules": {
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,
23+
"env": {
24+
"browser": true,
25+
"es6": true,
26+
"jasmine": true,
27+
"jest": true,
28+
"node": true
29+
},
30+
"globals": {
31+
"jest": true
3332
},
3433
"plugins": [
35-
"react"
34+
"react",
35+
"import"
3636
],
37-
"settings": {
38-
"react": {
39-
"version": "^15.6.1"
37+
"overrides": [
38+
{
39+
"files": [
40+
"**/*.percy.{js,jsx}"
41+
],
42+
"env": {
43+
"react-percy/globals": true
44+
}
4045
}
46+
],
47+
"rules": {
48+
"accessor-pairs": [
49+
"error"
50+
],
51+
"block-scoped-var": [
52+
"error"
53+
],
54+
"consistent-return": [
55+
"error"
56+
],
57+
"curly": [
58+
"error",
59+
"all"
60+
],
61+
"default-case": [
62+
"error"
63+
],
64+
"dot-location": [
65+
"off"
66+
],
67+
"dot-notation": [
68+
"error"
69+
],
70+
"eqeqeq": [
71+
"error"
72+
],
73+
"guard-for-in": [
74+
"off"
75+
],
76+
"import/named": [
77+
"off"
78+
],
79+
"import/no-duplicates": [
80+
"error"
81+
],
82+
"import/no-named-as-default": [
83+
"error"
84+
],
85+
"new-cap": [
86+
"error"
87+
],
88+
"no-alert": [
89+
1
90+
],
91+
"no-caller": [
92+
"error"
93+
],
94+
"no-case-declarations": [
95+
"error"
96+
],
97+
"no-console": [
98+
"error"
99+
],
100+
"no-div-regex": [
101+
"error"
102+
],
103+
"no-dupe-keys": [
104+
"error"
105+
],
106+
"no-else-return": [
107+
"error"
108+
],
109+
"no-empty-pattern": [
110+
"error"
111+
],
112+
"no-eq-null": [
113+
"error"
114+
],
115+
"no-eval": [
116+
"error"
117+
],
118+
"no-extend-native": [
119+
"error"
120+
],
121+
"no-extra-bind": [
122+
"error"
123+
],
124+
"no-extra-boolean-cast": [
125+
"error"
126+
],
127+
"no-inline-comments": [
128+
"error"
129+
],
130+
"no-implicit-coercion": [
131+
"error"
132+
],
133+
"no-implied-eval": [
134+
"error"
135+
],
136+
"no-inner-declarations": [
137+
"off"
138+
],
139+
"no-invalid-this": [
140+
"error"
141+
],
142+
"no-iterator": [
143+
"error"
144+
],
145+
"no-labels": [
146+
"error"
147+
],
148+
"no-lone-blocks": [
149+
"error"
150+
],
151+
"no-loop-func": [
152+
"error"
153+
],
154+
"no-multi-str": [
155+
"error"
156+
],
157+
"no-native-reassign": [
158+
"error"
159+
],
160+
"no-new": [
161+
"error"
162+
],
163+
"no-new-func": [
164+
"error"
165+
],
166+
"no-new-wrappers": [
167+
"error"
168+
],
169+
"no-param-reassign": [
170+
"error"
171+
],
172+
"no-process-env": [
173+
"warn"
174+
],
175+
"no-proto": [
176+
"error"
177+
],
178+
"no-redeclare": [
179+
"error"
180+
],
181+
"no-return-assign": [
182+
"error"
183+
],
184+
"no-script-url": [
185+
"error"
186+
],
187+
"no-self-compare": [
188+
"error"
189+
],
190+
"no-sequences": [
191+
"error"
192+
],
193+
"no-shadow": [
194+
"off"
195+
],
196+
"no-throw-literal": [
197+
"error"
198+
],
199+
"no-undefined": [
200+
"error"
201+
],
202+
"no-unused-expressions": [
203+
"error"
204+
],
205+
"no-use-before-define": [
206+
"error",
207+
"nofunc"
208+
],
209+
"no-useless-call": [
210+
"error"
211+
],
212+
"no-useless-concat": [
213+
"error"
214+
],
215+
"no-with": [
216+
"error"
217+
],
218+
"prefer-const": [
219+
"error"
220+
],
221+
"radix": [
222+
"error"
223+
],
224+
"react/jsx-no-duplicate-props": [
225+
"error"
226+
],
227+
"react/jsx-no-undef": [
228+
"error"
229+
],
230+
"react/jsx-uses-react": [
231+
"error"
232+
],
233+
"react/jsx-uses-vars": [
234+
"error"
235+
],
236+
"react/no-did-update-set-state": [
237+
"error"
238+
],
239+
"react/no-direct-mutation-state": [
240+
"error"
241+
],
242+
"react/no-is-mounted": [
243+
"error"
244+
],
245+
"react/no-unknown-property": [
246+
"error"
247+
],
248+
"react/prefer-es6-class": [
249+
"error",
250+
"always"
251+
],
252+
"react/prop-types": "error",
253+
"valid-jsdoc": [
254+
"error"
255+
],
256+
"yoda": [
257+
"error"
258+
],
259+
"spaced-comment": [
260+
"error",
261+
"always",
262+
{
263+
"block": {
264+
"exceptions": [
265+
"*"
266+
]
267+
}
268+
}
269+
],
270+
"no-unused-vars": [
271+
"error",
272+
{
273+
"args": "after-used",
274+
"argsIgnorePattern": "^_",
275+
"caughtErrorsIgnorePattern": "^e$"
276+
}
277+
],
278+
"no-magic-numbers": [
279+
"error",
280+
{
281+
"ignoreArrayIndexes": true,
282+
"ignore": [
283+
-1,
284+
0,
285+
1,
286+
2,
287+
3,
288+
100,
289+
10,
290+
0.5
291+
]
292+
}
293+
],
294+
"no-underscore-dangle": [
295+
"off"
296+
]
41297
}
42298
}

.prettierrc

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"singleQuote": true,
3-
"bracketSpacing": false,
4-
"trailingComma": "es5"
2+
"singleQuote": true,
3+
"bracketSpacing": false,
4+
"trailingComma": "es5",
5+
"printWidth": 100
56
}

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"url": "https://github.com/plotly/react-plotly.js/issues"
1414
},
1515
"scripts": {
16-
"make:lib": "mkdirp lib && babel src --out-dir=lib --ignore __tests__/*.js,__mocks__/*.js --presets=es2015,react --source-maps --plugins babel-plugin-add-module-exports && mv lib/* ./ && rmdir lib",
17-
"make:dist": "mkdirp dist && browserify src/factory.js -o ./dist/create-plotly-component.js -t [ babelify --presets [ es2015 react ] --plugins add-module-exports ] -t browserify-global-shim --standalone createPlotlyComponent && uglifyjs ./dist/create-plotly-component.js --compress --mangle --output ./dist/create-plotly-component.min.js --source-map filename=dist/create-plotly-component.min.js.map",
16+
"make:lib": "mkdirp lib && babel src --out-dir=lib --ignore __tests__/*.js,__mocks__/*.js --presets=env,react --source-maps --plugins babel-plugin-add-module-exports && mv lib/* ./ && rmdir lib",
17+
"make:dist": "mkdirp dist && browserify src/factory.js -o ./dist/create-plotly-component.js -t [ babelify --presets [ env react ] --plugins add-module-exports ] -t browserify-global-shim --standalone createPlotlyComponent && uglifyjs ./dist/create-plotly-component.js --compress --mangle --output ./dist/create-plotly-component.min.js --source-map filename=dist/create-plotly-component.min.js.map",
1818
"clean": "rimraf lib dist react-plotly.js react-plotly.js.map factory.js factory.js.map",
1919
"prepublishOnly": "npm run clean && npm run make:lib && npm run make:dist",
2020
"lint": "prettier --trailing-comma es5 --write \"src/**/*.js\" && eslint src",
@@ -33,9 +33,10 @@
3333
],
3434
"devDependencies": {
3535
"babel-cli": "^6.24.1",
36+
"babel-eslint": "^10.0.1",
3637
"babel-plugin-add-module-exports": "^0.2.1",
3738
"babel-plugin-transform-class-properties": "^6.24.1",
38-
"babel-preset-es2015": "^6.24.1",
39+
"babel-preset-env": "^1.7.0",
3940
"babel-preset-react": "^6.24.1",
4041
"babelify": "^7.3.0",
4142
"brfs": "^1.4.3",
@@ -45,6 +46,8 @@
4546
"dependency-check": "^2.9.1",
4647
"enzyme": "^2.9.1",
4748
"eslint": "^4.8.0",
49+
"eslint-config-prettier": "^4.0.0",
50+
"eslint-plugin-import": "^2.16.0",
4851
"eslint-plugin-react": "^7.4.0",
4952
"event-emitter": "^0.3.5",
5053
"jest": "^20.0.4",

src/__mocks__/plotly.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ export default {
1212
}),
1313
newPlot: jest.fn(gd => {
1414
state.gd = gd;
15-
EventEmitter(state.gd);
15+
EventEmitter(state.gd); // eslint-disable-line new-cap
1616

1717
setTimeout(() => {
1818
state.gd.emit('plotly_afterplot');
1919
}, ASYNC_DELAY);
2020
}),
2121
react: jest.fn(gd => {
2222
state.gd = gd;
23-
EventEmitter(state.gd);
23+
EventEmitter(state.gd); // eslint-disable-line new-cap
2424

2525
setTimeout(() => {
2626
state.gd.emit('plotly_afterplot');
@@ -40,6 +40,6 @@ export default {
4040
}),
4141
update: jest.fn(),
4242
purge: jest.fn(() => {
43-
state.gd = nll;
43+
state.gd = null;
4444
}),
4545
};

0 commit comments

Comments
 (0)