Skip to content

Commit cd16585

Browse files
authored
Merge pull request #82 from oslabs-beta/rydang/eslint
eslint config compatibility with prettier
2 parents 8a19f74 + 5ada23c commit cd16585

File tree

14 files changed

+132
-91
lines changed

14 files changed

+132
-91
lines changed

.eslintrc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"extends": ["airbnb", "plugin:jest/recommended"],
33
"root": true,
4-
"plugins": ["jest"],
4+
"plugins": ["jest"],
55
"env": {
66
"jest/globals": true,
77
"browser": true,
8-
"webextensions": true,
8+
"webextensions": true
99
},
10-
"globals": {
11-
"fetch": false,
10+
"globals": {
11+
"fetch": false
12+
},
13+
"rules": {
14+
"arrow-parens": [2, "as-needed"]
1215
}
1316
}

package/tree.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ class Tree {
44
// give it a special state = 'root'
55
// a setState function that just calls the callback instantly
66
if (!useStateInstead) {
7-
this.component = (component === 'root') ? { state: 'root', setState: (partial, callback) => callback() } : component;
7+
this.component = component === 'root'
8+
? { state: 'root', setState: (partial, callback) => callback() }
9+
: component;
810
} else {
911
this.state = component;
1012
this.name = name;
@@ -21,7 +23,9 @@ class Tree {
2123
// deep copies only the state of each component and creates a new tree
2224
getCopy(copy = new Tree('root', true)) {
2325
// copy state of children
24-
copy.children = this.children.map(child => new Tree(child.component.state, true, child.component.constructor.name));
26+
copy.children = this.children.map(
27+
child => new Tree(child.component.state, true, child.component.constructor.name),
28+
);
2529

2630
// copy children's children recursively
2731
this.children.forEach((child, i) => child.getCopy(copy.children[i]));
@@ -31,15 +35,14 @@ class Tree {
3135
// print out the tree in the console
3236
print() {
3337
const children = ['children: '];
34-
this.children.forEach((child) => {
38+
this.children.forEach(child => {
3539
children.push(child.state || child.component.state);
3640
});
3741
if (this.name) console.log(this.name);
3842
if (children.length === 1) {
3943
console.log(this.state || this.component.state);
40-
}
41-
else console.log(this.state || this.component.state, ...children);
42-
this.children.forEach((child) => {
44+
} else console.log(this.state || this.component.state, ...children);
45+
this.children.forEach(child => {
4346
child.print();
4447
});
4548
}

src/app/__tests__/MainContainer.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ global.chrome = chrome;
3838
let eventListener;
3939
const port = {
4040
onMessage: {
41-
addListener: ((fn) => {
41+
addListener: fn => {
4242
eventListener = fn;
43-
}),
43+
},
4444
},
4545
onDisconnect: {
46-
addListener: () => { },
46+
addListener: () => {},
4747
},
4848
};
4949
chrome.runtime.connect.returns(port);

src/app/components/Action.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33

44
import { changeView, changeSlider } from '../actions/actions';
55

6-
const Action = (props) => {
6+
const Action = props => {
77
const {
88
selected, index, sliderIndex, dispatch,
99
} = props;
@@ -18,7 +18,7 @@ const Action = (props) => {
1818
<div className="action-component-text">{index}</div>
1919
<button
2020
className="jump-button"
21-
onClick={(e) => {
21+
onClick={e => {
2222
e.stopPropagation();
2323
dispatch(changeSlider(index));
2424
}}

src/app/components/Chart.jsx

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as d3 from 'd3';
99
let root = {};
1010
let duration = 750;
1111

12-
1312
class Chart extends Component {
1413
componentDidMount() {
1514
const { snapshot } = this.props;
@@ -35,31 +34,42 @@ class Chart extends Component {
3534
duration = 0;
3635

3736
const margin = {
38-
top: 20, right: 120, bottom: 20, left: 120,
37+
top: 20,
38+
right: 120,
39+
bottom: 20,
40+
left: 120,
3941
};
4042
// const width = 600 - margin.right - margin.left;
4143
const height = 600 - margin.top - margin.bottom;
4244

4345
let i = 0;
4446

45-
const tree = d3.layout.tree()
47+
const tree = d3.layout
48+
.tree()
4649
.nodeSize([20])
4750
.separation((a, b) => (a.parent === b.parent ? 3 : 1));
4851

49-
const diagonal = d3.svg.diagonal()
50-
.projection(d => [d.y, d.x]);
52+
const diagonal = d3.svg.diagonal().projection(d => [d.y, d.x]);
5153

52-
const svg = d3.select(this.refs.anchor).append('svg')
54+
const svg = d3
55+
.select(this.refs.anchor)
56+
.append('svg')
5357
.attr('width', '100%')
5458
.attr('height', '100%')
5559
.attr('cursor', '-webkit-grab')
5660
.attr('preserveAspectRatio', 'xMinYMin slice')
57-
.call(d3.behavior.zoom().on('zoom', () => svg.attr('transform', `translate(${d3.event.translate}) scale(${d3.event.scale})`)))
61+
.call(
62+
d3.behavior
63+
.zoom()
64+
.on('zoom', () => svg.attr('transform', `translate(${d3.event.translate}) scale(${d3.event.scale})`)),
65+
)
5866
.append('g')
5967
.attr('transform', `translate(60,${height / 2})`);
6068

6169
// Add tooltip div
62-
const div = d3.select('body').append('div')
70+
const div = d3
71+
.select('body')
72+
.append('div')
6373
.attr('class', 'tooltip')
6474
.style('opacity', 1e-6)
6575
.on('mouseover', tipMouseover)
@@ -74,32 +84,37 @@ class Chart extends Component {
7484
const links = tree.links(nodes);
7585

7686
// Normalize for fixed-depth.
77-
nodes.forEach((d) => { d.y = d.depth * 180; });
87+
nodes.forEach(d => {
88+
d.y = d.depth * 180;
89+
});
7890

7991
// Update the nodes…
80-
const node = svg.selectAll('g.node')
81-
.data(nodes, (d) => {
82-
if (!d.id) {
83-
i += 1;
84-
d.id = i;
85-
}
86-
return d.id;
87-
});
92+
const node = svg.selectAll('g.node').data(nodes, d => {
93+
if (!d.id) {
94+
i += 1;
95+
d.id = i;
96+
}
97+
return d.id;
98+
});
8899

89100
// Enter any new nodes at the parent's previous position.
90-
const nodeEnter = node.enter().append('g')
101+
const nodeEnter = node
102+
.enter()
103+
.append('g')
91104
.attr('class', 'node')
92105
.attr('transform', () => `translate(${source.y0},${source.x0})`)
93106
.on('click', click)
94107
.on('mouseover', mouseover)
95108
.on('mouseout', mouseout)
96109
.on('mousemove', d => mousemove(d));
97110

98-
nodeEnter.append('circle')
111+
nodeEnter
112+
.append('circle')
99113
.attr('r', 1e-6)
100114
.style('fill', d => (d._children ? 'lightsteelblue' : '#fff'));
101115

102-
nodeEnter.append('text')
116+
nodeEnter
117+
.append('text')
103118
.attr('x', d => (d.children || d._children ? -10 : 10))
104119
.attr('dy', '.35em')
105120
.attr('text-anchor', d => (d.children || d._children ? 'end' : 'start'))
@@ -108,48 +123,53 @@ class Chart extends Component {
108123
.style('fill-opacity', 1e-6);
109124

110125
// Transition nodes to their new position.
111-
const nodeUpdate = node.transition()
126+
const nodeUpdate = node
127+
.transition()
112128
.duration(duration)
113129
.attr('transform', d => `translate(${d.y},${d.x})`);
114130

115-
nodeUpdate.select('circle')
131+
nodeUpdate
132+
.select('circle')
116133
.attr('r', 7)
117134
.style('fill', d => (d._children ? '#A1C658' : '#D381C3'));
118135

119-
nodeUpdate.select('text')
120-
.style('fill-opacity', 1);
136+
nodeUpdate.select('text').style('fill-opacity', 1);
121137

122138
// Transition exiting nodes to the parent's new position.
123-
const nodeExit = node.exit().transition()
139+
const nodeExit = node
140+
.exit()
141+
.transition()
124142
.duration(duration)
125143
.attr('transform', () => `translate(${source.y},${source.x})`)
126144
.remove();
127145

128-
nodeExit.select('circle')
129-
.attr('r', 1e-6);
146+
nodeExit.select('circle').attr('r', 1e-6);
130147

131-
nodeExit.select('text')
132-
.style('fill-opacity', 1e-6);
148+
nodeExit.select('text').style('fill-opacity', 1e-6);
133149

134150
// Update the links…
135-
const link = svg.selectAll('path.link')
136-
.data(links, d => d.target.id);
151+
const link = svg.selectAll('path.link').data(links, d => d.target.id);
137152

138153
// Enter any new links at the parent's previous position.
139-
link.enter().insert('path', 'g')
154+
link
155+
.enter()
156+
.insert('path', 'g')
140157
.attr('class', 'link')
141158
.attr('d', () => {
142159
const o = { x: source.x0, y: source.y0 };
143160
return diagonal({ source: o, target: o });
144161
});
145162

146163
// Transition links to their new position.
147-
link.transition()
164+
link
165+
.transition()
148166
.duration(duration)
149167
.attr('d', diagonal);
150168

151169
// Transition exiting nodes to the parent's new position.
152-
link.exit().transition()
170+
link
171+
.exit()
172+
.transition()
153173
.duration(duration)
154174
.attr('d', () => {
155175
const o = { x: source.x, y: source.y };
@@ -158,7 +178,7 @@ class Chart extends Component {
158178
.remove();
159179

160180
// Stash the old positions for transition.
161-
nodes.forEach((d) => {
181+
nodes.forEach(d => {
162182
d.x0 = d.x;
163183
d.y0 = d.y;
164184
});
@@ -178,27 +198,31 @@ class Chart extends Component {
178198

179199
// Show state on mouse over
180200
function mouseover() {
181-
div.transition()
201+
div
202+
.transition()
182203
.duration(300)
183204
.style('display', 'block')
184205
.style('opacity', 1);
185206
}
186207

187208
function mouseout() {
188-
div.transition()
209+
div
210+
.transition()
189211
.duration(3000)
190212
.style('opacity', 1e-6)
191213
.style('display', 'none');
192214
}
193215

194216
function tipMouseover() {
195-
div.transition()
217+
div
218+
.transition()
196219
.duration(300)
197220
.style('opacity', 1);
198221
}
199222

200223
function tipMouseout() {
201-
div.transition()
224+
div
225+
.transition()
202226
.duration(3000)
203227
.style('opacity', 1e-6)
204228
.style('display', 'none');
@@ -223,9 +247,7 @@ class Chart extends Component {
223247
}
224248

225249
Chart.propTypes = {
226-
snapshot: PropTypes.arrayOf(
227-
PropTypes.object,
228-
).isRequired,
250+
snapshot: PropTypes.arrayOf(PropTypes.object).isRequired,
229251
};
230252

231253
export default Chart;

src/app/components/Dropdown.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import Select from 'react-select';
33
import PropTypes from 'prop-types';
44

5-
const Dropdown = (props) => {
5+
const Dropdown = props => {
66
const { speeds, setSpeed, selectedSpeed } = props;
77
return (
88
<Select

src/app/components/MainSlider.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useStoreContext } from '../store';
1010

1111
const { Handle } = Slider;
1212

13-
const handle = (props) => {
13+
const handle = props => {
1414
const {
1515
value, dragging, index, ...restProps
1616
} = props;
@@ -37,7 +37,7 @@ function MainSlider({ snapshotsLength }) {
3737
min={0}
3838
max={snapshotsLength - 1}
3939
value={sliderIndex}
40-
onChange={(index) => {
40+
onChange={index => {
4141
const newIndex = index === -1 ? 0 : index;
4242
dispatch(changeSlider(newIndex));
4343
dispatch(pause());

src/app/components/SwitchApp.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SwitchAppDropdown = () => {
99

1010
const tabsArray = [];
1111

12-
Object.keys(tabs).forEach((tab) => {
12+
Object.keys(tabs).forEach(tab => {
1313
tabsArray.push({ value: tab, label: tab });
1414
});
1515

@@ -24,7 +24,7 @@ const SwitchAppDropdown = () => {
2424
classNamePrefix="react-select"
2525
value={currTab}
2626
// onChange={dispatch(setTab(loadApp))}
27-
onChange={(e) => {
27+
onChange={e => {
2828
dispatch(setTab(parseInt(e.value, 10)));
2929
// console.log(e)
3030
}}

src/app/components/Tree.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getItemString = (type, data) => {
1515
return null;
1616
};
1717

18-
const Tree = (props) => {
18+
const Tree = props => {
1919
const { snapshot } = props;
2020
return (
2121
<React.Fragment>

0 commit comments

Comments
 (0)