Skip to content

Commit 02ae37d

Browse files
committed
Format code per stricter linting rules
1 parent 5b6f7b2 commit 02ae37d

33 files changed

+250
-217
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"comma-dangle": 0,
1414
"import/first": 0,
1515
"import/no-extraneous-dependencies": 0,
16+
"jsx-a11y/click-events-have-key-events": 0,
1617
"jsx-a11y/label-has-for": 0,
1718
"jsx-a11y/no-static-element-interactions": 0,
1819
"no-restricted-properties": 0,

src/AppBar/AppBar.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ import Styles from './AppBar.css';
66
import Typography from '../Typography';
77
import Variables from '../variables';
88

9-
function AppBar({backgroundColor, className, elevation, children, primary, secondary, ...other}) {
9+
function AppBar({
10+
backgroundColor,
11+
className,
12+
elevation,
13+
children,
14+
primary,
15+
secondary,
16+
...other
17+
}) {
1018
return (
1119
<Paper
1220
{...other}

src/Button/Button.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ class Button extends React.Component {
123123
};
124124

125125
render() {
126-
const {buttonColor, children, className, component,
127-
focusRippleDisabled, icon, fab, style, textColor, ...other} = this.props;
126+
const {
127+
buttonColor, children, className, component,
128+
focusRippleDisabled, icon, fab, style, textColor, ...other
129+
} = this.props;
128130
const Component = component;
129131
const readableTextColor = this.readableTextColor();
130132
return (

src/Button/Button.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('Button', () => {
4242
});
4343

4444
it('should set mouseFocused to true onMouseDown', () => {
45-
const wrapper = mount(<Button label={'Label'} />);
45+
const wrapper = mount(<Button label="Label" />);
4646
wrapper.simulate('mousedown', fakeEventProps);
4747
assert(wrapper.state('mouseFocused'));
4848
});

src/Collapse/Collapse.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ class Collapse extends React.Component {
3131
}
3232
}
3333

34+
registerRoot = (c) => { this.root = c; }
35+
registerInner = (c) => { this.rootInner = c; }
36+
3437
render() {
35-
const {open, children, className, ...other} = this.props;
38+
const {
39+
open, children, className, ...other
40+
} = this.props;
3641
return (
3742
<div
3843
{...other}
@@ -41,10 +46,10 @@ class Collapse extends React.Component {
4146
height: this.state.height,
4247
overflow: this.state.overflow
4348
}}
44-
ref={c => (this.root = c)}
49+
ref={this.registerRoot}
4550
>
4651
<div
47-
ref={c => (this.rootInner = c)}
52+
ref={this.registerInner}
4853
>
4954
{children}
5055
</div>

src/Collapse/Collapse.spec.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ describe('Collapse', () => {
4444
});
4545

4646
it('should not animate on initial render if open is set to true', (done) => {
47-
const wrapper = mount(
48-
<Collapse open>
49-
{longDiv}
50-
</Collapse>,
51-
);
47+
const wrapper = mount(<Collapse open>{longDiv}</Collapse>);
5248
const initialHeight = wrapper.getDOMNode().style.height;
5349
assert(parseInt(initialHeight, 10) > '0');
5450
setTimeout(() => {
@@ -59,11 +55,7 @@ describe('Collapse', () => {
5955
});
6056

6157
it('should animate when open changes from false to true', (done) => {
62-
const wrapper = mount(
63-
<Collapse open={false}>
64-
{longDiv}
65-
</Collapse>
66-
);
58+
const wrapper = mount(<Collapse open={false}>{longDiv}</Collapse>);
6759
const initialHeight = wrapper.getDOMNode().style.height;
6860
wrapper.setProps({open: true});
6961
setTimeout(() => {
@@ -74,11 +66,7 @@ describe('Collapse', () => {
7466
});
7567

7668
it('should animate when open changes from true to false', (done) => {
77-
const wrapper = mount(
78-
<Collapse open>
79-
{longDiv}
80-
</Collapse>
81-
);
69+
const wrapper = mount(<Collapse open>{longDiv}</Collapse>);
8270
const initialHeight = wrapper.getDOMNode().style.height;
8371
setTimeout(() => {
8472
wrapper.setProps({open: false});

src/Dialog/Dialog.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ function FirstChild(props) {
99
}
1010

1111
class Dialog extends React.Component { // eslint-disable-line prefer-stateless-function
12+
register = (c) => { this.inner = c; }
13+
1214
render() {
1315
return (
1416
<TransitionGroup component={FirstChild}>
15-
{this.props.open && <DialogInner {...this.props} ref={c => (this.inner = c)} />}
17+
{this.props.open && <DialogInner {...this.props} ref={this.register} />}
1618
</TransitionGroup>
1719
);
1820
}

src/Dialog/Dialog.spec.js

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,18 @@ describe('Dialog', () => {
4444
});
4545

4646
it('should mount in an open state, then close', createTest(() => {
47-
const wrapper = mount(
48-
<Dialog
49-
open
50-
title="Title"
51-
description="Description"
52-
onClose={() => {
47+
const wrapper = mount(<Dialog
48+
open
49+
title="Title"
50+
description="Description"
51+
onClose={() => {
5352
wrapper.setProps({open: false});
5453
}}
55-
actions={[
56-
<Button key={'one'}>Foo</Button>,
57-
<Button key={'two'}>Bar</Button>
54+
actions={[
55+
<Button key="one">Foo</Button>,
56+
<Button key="two">Bar</Button>
5857
]}
59-
/>
60-
);
58+
/>);
6159
assert(wrapper.find(`.${Styles.root}`).length === 1);
6260
setTimeout(() => {
6361
wrapper.find(`.${Styles.root}`).simulate('keydown', {keyCode: keycode('esc')});
@@ -69,20 +67,18 @@ describe('Dialog', () => {
6967

7068

7169
it('should focus the first action on tab key press when last button has current focus', createTest(() => {
72-
const wrapper = mount(
73-
<Dialog
74-
open
75-
title="Title"
76-
description="Description"
77-
onClose={() => {
70+
const wrapper = mount(<Dialog
71+
open
72+
title="Title"
73+
description="Description"
74+
onClose={() => {
7875
wrapper.setProps({open: false});
7976
}}
80-
actions={[
81-
<Button key={'one'}>Foo</Button>,
82-
<Button key={'two'}>Bar</Button>
77+
actions={[
78+
<Button key="one">Foo</Button>,
79+
<Button key="two">Bar</Button>
8380
]}
84-
/>
85-
);
81+
/>);
8682
wrapper.find('button').last().instance().focus();
8783

8884
setTimeout(() => {
@@ -95,17 +91,15 @@ describe('Dialog', () => {
9591
}));
9692

9793
it('should focus the last action on shift+tab key press when first action has current focus', createTest(() => {
98-
const wrapper = mount(
99-
<Dialog
100-
open
101-
title="Title"
102-
description="Description"
103-
actions={[
104-
<Button key={'one'}>Foo</Button>,
105-
<Button key={'two'}>Bar</Button>
94+
const wrapper = mount(<Dialog
95+
open
96+
title="Title"
97+
description="Description"
98+
actions={[
99+
<Button key="one">Foo</Button>,
100+
<Button key="two">Bar</Button>
106101
]}
107-
/>
108-
);
102+
/>);
109103
wrapper.find('button').first().instance().focus();
110104

111105
setTimeout(() => {

src/Dialog/DialogInner.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,18 @@ class DialogInner extends React.Component {
7777
}, 350);
7878
}
7979

80+
registerRoot = (c) => { this.root = c; }
81+
registerActions = (c) => { this.actions = c; }
82+
8083
render() {
81-
const {actions, className, description, onClose, open, title, ...other} = this.props;
84+
const {
85+
actions, className, description, onClose, open, title, ...other
86+
} = this.props;
8287
return (
8388
<div // eslint-disable-line jsx-a11y/no-noninteractive-element-interactions
8489
{...other}
8590
className={makeClass(Styles.root, {[Styles.open]: open}, className)}
86-
ref={c => (this.root = c)}
91+
ref={this.registerRoot}
8792
role="document"
8893
tabIndex={-1}
8994
onKeyDown={__TEST__ ? this.onKeyDown : ontouchmove}
@@ -104,7 +109,7 @@ class DialogInner extends React.Component {
104109
</div>
105110
<div
106111
className={Styles.actions}
107-
ref={c => (this.actions = c)}
112+
ref={this.registerActions}
108113
>
109114
{actions}
110115
</div>

src/Grid/Grid.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import Styles from './Grid.css';
55

66
class Grid extends React.Component {
77
render() {
8-
const {children, className, margin, gutter, ...other} = this.props;
8+
const {
9+
children, className, margin, gutter, ...other
10+
} = this.props;
911

1012
const rootClasses = makeClass(
1113
Styles.root,

src/Grid/Grid.spec.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,27 @@ describe('Grid', () => {
1919
});
2020

2121
it('should render a Grid', createTest(() => {
22-
const wrapper = mount(
22+
const component = (
2323
<Grid margin={40} gutter={8}>
2424
{[1, 2, 3, 4, 5, 6, 7, 8].map(item => (
2525
<GridItem xs={12} sm={6} md={4} lg={3} key={item}>
2626
<div
2727
style={{
28-
display: 'flex',
29-
alignItems: 'center',
30-
justifyContent: 'center',
31-
height: '100px',
32-
backgroundColor: variables.$black54,
33-
color: variables.$white
34-
}}
28+
display: 'flex',
29+
alignItems: 'center',
30+
justifyContent: 'center',
31+
height: '100px',
32+
backgroundColor: variables.$black54,
33+
color: variables.$white
34+
}}
3535
>
3636
xs=12, sm=6, md=4, lg=3
3737
</div>
3838
</GridItem>
3939
))}
4040
</Grid>
4141
);
42+
const wrapper = mount(component);
4243
assert(wrapper);
4344
}));
4445
});

src/Grid/GridItem.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import Styles from './GridItem.css';
66

77
class GridItem extends React.Component {
88
render() {
9-
const {children, className, xs, sm, md, lg, ...other} = this.props;
9+
const {
10+
children, className, xs, sm, md, lg, ...other
11+
} = this.props;
1012
const classes = makeClass(
1113
Styles.root,
1214
GridStyles.gutterChild,

src/Grid/GridItem.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('GridItem', () => {
1818
});
1919

2020
it('should render a GridItem', createTest(() => {
21-
const wrapper = mount(
21+
const component = (
2222
<GridItem xs={12}>
2323
<div
2424
style={{
@@ -34,6 +34,7 @@ describe('GridItem', () => {
3434
</div>
3535
</GridItem>
3636
);
37+
const wrapper = mount(component);
3738
assert(wrapper);
3839
}));
3940
});

src/List/List.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ class List extends React.Component {
2424
this.props.onKeyDown(e, ...args);
2525
}
2626

27+
registerRoot = (c) => { this.root = c; }
28+
2729
render() {
28-
const {arrowNavigation, children, className, onKeyDown, ...other} = this.props;
30+
const {
31+
arrowNavigation, children, className, onKeyDown, ...other
32+
} = this.props;
2933
return (
30-
<div {...other} className={makeClass(Styles.root, className)} ref={c => (this.root = c)}>
34+
<div {...other} className={makeClass(Styles.root, className)} ref={this.registerRoot}>
3135
{React.Children.map(children, (child) => {
3236
const props = {
3337
buttonProps: deepAssign({focusRippleDisabled: true}, child.props.buttonProps)

src/List/List.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe('List', () => {
3434
it('should support arrow key navigation with arrowNavigation prop', createTest(() => {
3535
const component = (
3636
<List arrowNavigation>
37-
<ListItem id="first" primary={'First List Item'} />
38-
<ListItem id="second" primary={'Second List Item'} />
37+
<ListItem id="first" primary="First List Item" />
38+
<ListItem id="second" primary="Second List Item" />
3939
</List>
4040
);
4141
const wrapper = mount(component);

src/List/ListItem.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ import Styles from './ListItem.css';
66
import Typography from '../Typography';
77

88
class ListItem extends React.Component {
9+
registerButton = (c) => { this.Button = c; }
10+
911
render() {
10-
const {action, buttonProps, avatar, className, primary, secondary, ...other} = this.props;
12+
const {
13+
action, buttonProps, avatar, className, primary, secondary, ...other
14+
} = this.props;
1115
return (
1216
<div {...other} className={makeClass(Styles.root, className)}>
1317
<Button
1418
{...buttonProps}
1519
className={Styles.button}
16-
ref={c => (this.Button = c)}
20+
ref={this.registerButton}
1721
>
1822
{avatar && (
1923
<div className={Styles.avatar}>

0 commit comments

Comments
 (0)