Skip to content

Commit 8d1d5bf

Browse files
committed
Set prettier to more sane 100 chars
1 parent b96892c commit 8d1d5bf

File tree

8 files changed

+67
-188
lines changed

8 files changed

+67
-188
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"lint-staged": {
2727
"src/**/*.js": [
2828
"eslint",
29-
"prettier --write --single-quote --trailing-comma=all",
29+
"prettier --write --single-quote --trailing-comma=all --print-width 100",
3030
"git add"
3131
]
3232
},

src/Link/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export default class Link extends React.PureComponent {
3838
diagonalPath(linkData, orientation) {
3939
const diagonal = svg
4040
.diagonal()
41-
.projection(
42-
d => (orientation === 'horizontal' ? [d.y, d.x] : [d.x, d.y]),
43-
);
41+
.projection(d => (orientation === 'horizontal' ? [d.y, d.x] : [d.x, d.y]));
4442
return diagonal(linkData);
4543
}
4644

src/Link/tests/index.test.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ describe('<Link />', () => {
5656
it('calls the appropriate path func based on `props.pathFunc`', () => {
5757
const diagonalComponent = shallow(<Link {...mockProps} />);
5858
const elbowComponent = shallow(<Link {...mockProps} pathFunc="elbow" />);
59-
const straightComponent = shallow(
60-
<Link {...mockProps} pathFunc="straight" />,
61-
);
59+
const straightComponent = shallow(<Link {...mockProps} pathFunc="straight" />);
6260
shallow(<Link {...mockProps} pathFunc={pathFuncs.testPathFunc} />);
6361

6462
expect(diagonalComponent.instance().diagonalPath).toHaveBeenCalled();
@@ -70,23 +68,19 @@ describe('<Link />', () => {
7068

7169
it('returns an appropriate elbowPath according to `props.orientation`', () => {
7270
expect(Link.prototype.elbowPath(linkData, 'horizontal')).toBe(
73-
`M${linkData.source.y},${linkData.source.x}V${linkData.target
74-
.x}H${linkData.target.y}`,
71+
`M${linkData.source.y},${linkData.source.x}V${linkData.target.x}H${linkData.target.y}`,
7572
);
7673
expect(Link.prototype.elbowPath(linkData, 'vertical')).toBe(
77-
`M${linkData.source.x},${linkData.source.y}V${linkData.target
78-
.y}H${linkData.target.x}`,
74+
`M${linkData.source.x},${linkData.source.y}V${linkData.target.y}H${linkData.target.x}`,
7975
);
8076
});
8177

8278
it('returns an appropriate straightPath according to `props.orientation`', () => {
8379
expect(Link.prototype.straightPath(linkData, 'horizontal')).toBe(
84-
`M${linkData.source.y},${linkData.source.x}L${linkData.target
85-
.y},${linkData.target.x}`,
80+
`M${linkData.source.y},${linkData.source.x}L${linkData.target.y},${linkData.target.x}`,
8681
);
8782
expect(Link.prototype.straightPath(linkData, 'vertical')).toBe(
88-
`M${linkData.source.x},${linkData.source.y}L${linkData.target
89-
.x},${linkData.target.y}`,
83+
`M${linkData.source.x},${linkData.source.y}L${linkData.target.x},${linkData.target.y}`,
9084
);
9185
});
9286

src/Node/index.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ export default class Node extends React.Component {
5050
}
5151

5252
setTransformOrientation(x, y, orientation) {
53-
return orientation === 'horizontal'
54-
? `translate(${y},${x})`
55-
: `translate(${x},${y})`;
53+
return orientation === 'horizontal' ? `translate(${y},${x})` : `translate(${x},${y})`;
5654
}
5755

5856
applyTransform(transform, transitionDuration, opacity = 1, done = () => {}) {
@@ -76,27 +74,17 @@ export default class Node extends React.Component {
7674
}
7775

7876
componentWillLeave(done) {
79-
const {
80-
nodeData: { parent },
81-
orientation,
82-
transitionDuration,
83-
} = this.props;
77+
const { nodeData: { parent }, orientation, transitionDuration } = this.props;
8478
const originX = parent ? parent.x : 0;
8579
const originY = parent ? parent.y : 0;
86-
const transform = this.setTransformOrientation(
87-
originX,
88-
originY,
89-
orientation,
90-
);
80+
const transform = this.setTransformOrientation(originX, originY, orientation);
9181

9282
this.applyTransform(transform, transitionDuration, 0, done);
9383
}
9484

9585
render() {
9686
const { nodeData, nodeSvgShape, textLayout, styles } = this.props;
97-
const nodeStyle = nodeData._children
98-
? { ...styles.node }
99-
: { ...styles.leafNode };
87+
const nodeStyle = nodeData._children ? { ...styles.node } : { ...styles.leafNode };
10088
return (
10189
<g
10290
id={nodeData.id}

src/Node/tests/index.test.js

Lines changed: 23 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,11 @@ describe('<Node />', () => {
7272
};
7373
const leafNodeComponent = shallow(<Node {...mockProps} styles={fixture} />);
7474
const nodeComponent = shallow(
75-
<Node
76-
{...mockProps}
77-
nodeData={{ ...nodeData, _children: [] }}
78-
styles={fixture}
79-
/>,
75+
<Node {...mockProps} nodeData={{ ...nodeData, _children: [] }} styles={fixture} />,
8076
);
8177

82-
expect(leafNodeComponent.find('circle').prop('fill')).toBe(
83-
fixture.leafNode.circle.fill,
84-
);
85-
expect(nodeComponent.find('circle').prop('fill')).toBe(
86-
fixture.node.circle.fill,
87-
);
78+
expect(leafNodeComponent.find('circle').prop('fill')).toBe(fixture.leafNode.circle.fill);
79+
expect(nodeComponent.find('circle').prop('fill')).toBe(fixture.node.circle.fill);
8880
});
8981

9082
it('applies correct node name styles depending on `nodeData._children`', () => {
@@ -98,19 +90,11 @@ describe('<Node />', () => {
9890
};
9991
const leafNodeComponent = shallow(<Node {...mockProps} styles={fixture} />);
10092
const nodeComponent = shallow(
101-
<Node
102-
{...mockProps}
103-
nodeData={{ ...nodeData, _children: [] }}
104-
styles={fixture}
105-
/>,
93+
<Node {...mockProps} nodeData={{ ...nodeData, _children: [] }} styles={fixture} />,
10694
);
10795

108-
expect(leafNodeComponent.find('.nodeNameBase').prop('style')).toBe(
109-
fixture.leafNode.name,
110-
);
111-
expect(nodeComponent.find('.nodeNameBase').prop('style')).toBe(
112-
fixture.node.name,
113-
);
96+
expect(leafNodeComponent.find('.nodeNameBase').prop('style')).toBe(fixture.leafNode.name);
97+
expect(nodeComponent.find('.nodeNameBase').prop('style')).toBe(fixture.node.name);
11498
});
11599

116100
it('applies correct node attributes styles depending on `nodeData._children`', () => {
@@ -124,71 +108,47 @@ describe('<Node />', () => {
124108
};
125109
const leafNodeComponent = shallow(<Node {...mockProps} styles={fixture} />);
126110
const nodeComponent = shallow(
127-
<Node
128-
{...mockProps}
129-
nodeData={{ ...nodeData, _children: [] }}
130-
styles={fixture}
131-
/>,
111+
<Node {...mockProps} nodeData={{ ...nodeData, _children: [] }} styles={fixture} />,
132112
);
133113

134114
expect(leafNodeComponent.find('.nodeAttributesBase').prop('style')).toBe(
135115
fixture.leafNode.attributes,
136116
);
137-
expect(nodeComponent.find('.nodeAttributesBase').prop('style')).toBe(
138-
fixture.node.attributes,
139-
);
117+
expect(nodeComponent.find('.nodeAttributesBase').prop('style')).toBe(fixture.node.attributes);
140118
});
141119

142120
it('applies correct `transform` prop based on its `orientation`', () => {
143-
const horizontalTransform = `translate(${nodeData.parent.y},${nodeData
144-
.parent.x})`;
145-
const verticalTransform = `translate(${nodeData.parent.x},${nodeData.parent
146-
.y})`;
121+
const horizontalTransform = `translate(${nodeData.parent.y},${nodeData.parent.x})`;
122+
const verticalTransform = `translate(${nodeData.parent.x},${nodeData.parent.y})`;
147123
const horizontalComponent = shallow(<Node {...mockProps} />);
148-
const verticalComponent = shallow(
149-
<Node {...mockProps} orientation="vertical" />,
150-
);
151-
expect(horizontalComponent.find('g').prop('transform')).toBe(
152-
horizontalTransform,
153-
);
154-
expect(verticalComponent.find('g').prop('transform')).toBe(
155-
verticalTransform,
156-
);
124+
const verticalComponent = shallow(<Node {...mockProps} orientation="vertical" />);
125+
expect(horizontalComponent.find('g').prop('transform')).toBe(horizontalTransform);
126+
expect(verticalComponent.find('g').prop('transform')).toBe(verticalTransform);
157127
});
158128

159129
it('should take an `onClick` prop', () => {
160-
const renderedComponent = shallow(
161-
<Node {...mockProps} onClick={() => {}} />,
162-
);
130+
const renderedComponent = shallow(<Node {...mockProps} onClick={() => {}} />);
163131

164132
expect(renderedComponent.prop('onClick')).toBeDefined();
165133
});
166134

167135
it('handles click events and passes its nodeId to onClick handler', () => {
168136
const onClickSpy = jest.fn();
169-
const renderedComponent = shallow(
170-
<Node {...mockProps} onClick={onClickSpy} />,
171-
);
137+
const renderedComponent = shallow(<Node {...mockProps} onClick={onClickSpy} />);
172138

173139
renderedComponent.simulate('click');
174140
expect(onClickSpy).toHaveBeenCalledWith(nodeData.id);
175141
});
176142

177143
it('maps each `props.attributes` to a <tspan> element', () => {
178144
const fixture = { keyA: 'valA', keyB: 'valB' };
179-
const renderedComponent = shallow(
180-
<Node {...mockProps} attributes={fixture} />,
181-
);
145+
const renderedComponent = shallow(<Node {...mockProps} attributes={fixture} />);
182146
const textNode = renderedComponent
183147
.find('text')
184148
.findWhere(n => n.prop('className') === 'nodeAttributesBase');
185149

186-
expect(
187-
textNode.findWhere(n => n.text() === `keyA: ${fixture.keyA}`).length,
188-
).toBe(1);
189-
expect(
190-
textNode.findWhere(n => n.text() === `keyB: ${fixture.keyB}`).length,
191-
).toBe(1);
150+
expect(textNode.findWhere(n => n.text() === `keyA: ${fixture.keyA}`).length).toBe(1);
151+
expect(textNode.findWhere(n => n.text() === `keyB: ${fixture.keyB}`).length).toBe(1);
192152
});
193153

194154
it('applies the `textLayout` prop to the node name & attributes', () => {
@@ -197,9 +157,7 @@ describe('<Node />', () => {
197157
x: 999,
198158
y: 111,
199159
};
200-
const renderedComponent = shallow(
201-
<Node {...mockProps} textLayout={fixture} />,
202-
);
160+
const renderedComponent = shallow(<Node {...mockProps} textLayout={fixture} />);
203161
const nodeName = renderedComponent
204162
.find('text')
205163
.findWhere(n => n.prop('className') === 'nodeNameBase');
@@ -228,10 +186,8 @@ describe('<Node />', () => {
228186
y: 2,
229187
},
230188
};
231-
const initialTransform = `translate(${mockProps.nodeData.y},${mockProps
232-
.nodeData.x})`;
233-
const updatedTransform = `translate(${updatedProps.nodeData
234-
.y},${updatedProps.nodeData.x})`;
189+
const initialTransform = `translate(${mockProps.nodeData.y},${mockProps.nodeData.x})`;
190+
const updatedTransform = `translate(${updatedProps.nodeData.y},${updatedProps.nodeData.x})`;
235191
const renderedComponent = mount(<Node {...mockProps} />);
236192

237193
expect(renderedComponent.instance().applyTransform).toHaveBeenCalledWith(
@@ -252,9 +208,7 @@ describe('<Node />', () => {
252208
const nextProps = { ...mockProps, orientation: 'vertical' };
253209

254210
expect(
255-
renderedComponent
256-
.instance()
257-
.shouldNodeTransform(renderedComponent.props(), nextProps),
211+
renderedComponent.instance().shouldNodeTransform(renderedComponent.props(), nextProps),
258212
).toBe(true);
259213
});
260214

@@ -264,9 +218,7 @@ describe('<Node />', () => {
264218
const renderedComponent = shallow(<Node {...props} />);
265219

266220
expect(renderedComponent.find(fixture.shape).length).toBe(1);
267-
expect(renderedComponent.find(fixture.shape).props()).toEqual(
268-
fixture.shapeProps,
269-
);
221+
expect(renderedComponent.find(fixture.shape).props()).toEqual(fixture.shapeProps);
270222
});
271223

272224
// TODO: DEPRECATE in v2

src/Tree/index.js

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ export default class Tree extends React.Component {
7878
.zoom()
7979
.scaleExtent([scaleExtent.min, scaleExtent.max])
8080
.on('zoom', () => {
81-
g.attr(
82-
'transform',
83-
`translate(${event.translate}) scale(${event.scale})`,
84-
);
81+
g.attr('transform', `translate(${event.translate}) scale(${event.scale})`);
8582
})
8683
// Offset so that first pan and zoom does not jump back to [0,0] coords
8784
.translate([translate.x, translate.y]),
@@ -185,9 +182,7 @@ export default class Tree extends React.Component {
185182
const targetNode = matches[0];
186183

187184
if (this.props.collapsible) {
188-
targetNode._collapsed
189-
? this.expandNode(targetNode)
190-
: this.collapseNode(targetNode);
185+
targetNode._collapsed ? this.expandNode(targetNode) : this.collapseNode(targetNode);
191186
this.setState({ data }, () => this.handleOnClickCb(targetNode));
192187
} else {
193188
this.handleOnClickCb(targetNode);
@@ -217,26 +212,13 @@ export default class Tree extends React.Component {
217212
* @return {object} Object containing `nodes` and `links`.
218213
*/
219214
generateTree() {
220-
const {
221-
initialDepth,
222-
depthFactor,
223-
separation,
224-
nodeSize,
225-
orientation,
226-
} = this.props;
215+
const { initialDepth, depthFactor, separation, nodeSize, orientation } = this.props;
227216

228217
const tree = layout
229218
.tree()
230-
.nodeSize(
231-
orientation === 'horizontal'
232-
? [nodeSize.y, nodeSize.x]
233-
: [nodeSize.x, nodeSize.y],
234-
)
219+
.nodeSize(orientation === 'horizontal' ? [nodeSize.y, nodeSize.x] : [nodeSize.x, nodeSize.y])
235220
.separation(
236-
(a, b) =>
237-
deepEqual(a.parent, b.parent)
238-
? separation.siblings
239-
: separation.nonSiblings,
221+
(a, b) => (deepEqual(a.parent, b.parent) ? separation.siblings : separation.nonSiblings),
240222
)
241223
.children(d => (d._collapsed ? null : d._children));
242224

@@ -273,11 +255,7 @@ export default class Tree extends React.Component {
273255
} = this.props;
274256

275257
return (
276-
<div
277-
className={`rd3t-tree-container ${zoomable
278-
? 'rd3t-grabbable'
279-
: undefined}`}
280-
>
258+
<div className={`rd3t-tree-container ${zoomable ? 'rd3t-grabbable' : undefined}`}>
281259
<svg className="rd3t-svg" width="100%" height="100%">
282260
<TransitionGroup
283261
component="g"

0 commit comments

Comments
 (0)