Skip to content

Commit 490d2ea

Browse files
committed
Impose 'no-else-return' airbnb rule
1 parent 117eebe commit 490d2ea

10 files changed

+62
-69
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"prefer-const": 0,
2222
"key-spacing": 0,
2323
"no-eq-null": 0,
24-
"no-else-return": 0,
2524
"no-param-reassign": 0,
2625
"no-this-before-super": 2,
2726
"no-undef": 2,

docs/src/PropTable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ const PropTable = React.createClass({
174174
return 'function';
175175
} else if (typeName === 'bool') {
176176
return 'boolean';
177-
} else {
178-
return typeName;
179177
}
178+
179+
return typeName;
180180
},
181181

182182
renderEnum(enumType) {

src/CollapsibleNav.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ const CollapsibleNav = React.createClass({
4444
{ nav }
4545
</Collapse>
4646
);
47-
} else {
48-
return nav;
4947
}
48+
return nav;
5049
},
5150

5251
getChildActiveProp(child) {

src/InputBase.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ class InputBase extends React.Component {
1414
} else if (this.props.type) {
1515
if (this.props.type === 'select' && this.props.multiple) {
1616
return this.getSelectedOptions();
17-
} else {
18-
return this.getInputDOMNode().value;
1917
}
20-
} else {
21-
throw new Error('Cannot use getValue without specifying input type.');
18+
return this.getInputDOMNode().value;
2219
}
20+
throw new Error('Cannot use getValue without specifying input type.');
2321
}
2422

2523
getChecked() {

src/Interpolate.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,27 @@ const Interpolate = React.createClass({
5858
props.dangerouslySetInnerHTML = { __html: content };
5959

6060
return React.createElement(parent, props);
61-
} else {
62-
let kids = format.split(REGEXP).reduce((memo, match, index) => {
63-
let child;
64-
65-
if (index % 2 === 0) {
66-
if (match.length === 0) {
67-
return memo;
68-
}
61+
}
62+
let kids = format.split(REGEXP).reduce((memo, match, index) => {
63+
let child;
6964

70-
child = match;
71-
} else {
72-
child = props[match];
73-
delete props[match];
65+
if (index % 2 === 0) {
66+
if (match.length === 0) {
67+
return memo;
7468
}
7569

76-
memo.push(child);
70+
child = match;
71+
} else {
72+
child = props[match];
73+
delete props[match];
74+
}
7775

78-
return memo;
79-
}, []);
76+
memo.push(child);
8077

81-
return React.createElement(parent, props, kids);
82-
}
78+
return memo;
79+
}, []);
80+
81+
return React.createElement(parent, props, kids);
8382
}
8483
});
8584

src/ListGroup.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ class ListGroup extends React.Component {
2323

2424
if (shouldRenderDiv) {
2525
return this.renderDiv(items);
26-
} else {
27-
return this.renderUL(items);
2826
}
27+
return this.renderUL(items);
2928
}
3029

3130
isAnchorOrButton(props) {

src/ListGroupItem.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ const ListGroupItem = React.createClass({
3535
return this.renderButton(classes);
3636
} else if (this.props.listItem) {
3737
return this.renderLi(classes);
38-
} else {
39-
return this.renderSpan(classes);
4038
}
39+
return this.renderSpan(classes);
4140
},
4241

4342
renderLi(classes) {

src/Tabs.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,27 @@ const Tabs = React.createClass({
218218
{panes}
219219
</div>
220220
);
221-
} else {
222-
return (
223-
<div {...containerProps}>
224-
{panes}
225-
{tabs}
226-
</div>
227-
);
228221
}
229-
} else {
222+
230223
return (
231224
<div {...containerProps}>
232-
<Nav {...tabsProps}>
233-
{childTabs}
234-
</Nav>
235-
236-
<div {...panesProps}>
237-
{childPanes}
238-
</div>
225+
{panes}
226+
{tabs}
239227
</div>
240228
);
241229
}
230+
231+
return (
232+
<div {...containerProps}>
233+
<Nav {...tabsProps}>
234+
{childTabs}
235+
</Nav>
236+
237+
<div {...panesProps}>
238+
{childPanes}
239+
</div>
240+
</div>
241+
);
242242
},
243243

244244
getActiveKey() {

src/Thumbnail.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ const Thumbnail = React.createClass({
2727
<img src={this.props.src} alt={this.props.alt} />
2828
</SafeAnchor>
2929
);
30-
} else {
31-
if (this.props.children) {
32-
return (
33-
<div {...this.props} className={classSet(this.props.className, classes)}>
34-
<img src={this.props.src} alt={this.props.alt} />
35-
<div className="caption">
36-
{this.props.children}
37-
</div>
38-
</div>
39-
);
40-
} else {
41-
return (
42-
<div {...this.props} className={classSet(this.props.className, classes)}>
43-
<img src={this.props.src} alt={this.props.alt} />
30+
}
31+
32+
if (this.props.children) {
33+
return (
34+
<div {...this.props} className={classSet(this.props.className, classes)}>
35+
<img src={this.props.src} alt={this.props.alt} />
36+
<div className="caption">
37+
{this.props.children}
4438
</div>
45-
);
46-
}
39+
</div>
40+
);
4741
}
42+
43+
return (
44+
<div {...this.props} className={classSet(this.props.className, classes)}>
45+
<img src={this.props.src} alt={this.props.alt} />
46+
</div>
47+
);
4848
}
4949
});
5050

test/OverlayTriggerSpec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,15 @@ describe('OverlayTrigger', () => {
233233
return (
234234
<div>replaced</div>
235235
);
236-
} else {
237-
return (
238-
<div>
239-
<a id="replace-overlay" onClick={this.handleClick}>
240-
original
241-
</a>
242-
</div>
243-
);
244236
}
237+
238+
return (
239+
<div>
240+
<a id="replace-overlay" onClick={this.handleClick}>
241+
original
242+
</a>
243+
</div>
244+
);
245245
}
246246
}
247247

0 commit comments

Comments
 (0)