Skip to content

Commit dc669b6

Browse files
committed
Merge pull request react-bootstrap#1335 from AlexKVal/airbnb
Left `Airbnb` rules.
2 parents 350f28e + 3552723 commit dc669b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+783
-806
lines changed

.eslintrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
"constructor-super": 2,
1717
"comma-dangle": 0,
1818
"eqeqeq": [2, "allow-null"],
19-
"func-names": 0,
20-
"guard-for-in": 0,
2119
"one-var": [2, { "initialized": "never" }],
2220
"prefer-const": 0,
2321
"key-spacing": 0,
2422
"no-eq-null": 0,
25-
"no-else-return": 0,
2623
"no-param-reassign": 0,
2724
"no-this-before-super": 2,
2825
"no-undef": 2,

docs/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ if (development) {
2121
let webpackPort = process.env.WEBPACK_DEV_PORT;
2222
let target = `http://${ip.address()}:${webpackPort}`;
2323

24-
app.get('/assets/*', function(req, res) {
24+
app.get('/assets/*', (req, res) => {
2525
proxy.web(req, res, { target });
2626
});
2727

28-
proxy.on('error', function(e) {
28+
proxy.on('error', e => {
2929
console.log('Could not connect to webpack proxy'.red);
3030
console.log(e.toString().red);
3131
});
@@ -49,7 +49,7 @@ if (development) {
4949
app.use(express.static(path.join(__dirname, '../docs-built')));
5050
}
5151

52-
app.listen(port, function() {
52+
app.listen(port, () => {
5353
console.log(`Server started at:`);
5454
console.log(`- http://localhost:${port}`);
5555
console.log(`- http://${ip.address()}:${port}`);

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) {

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint no-var: 0, babel/object-shorthand: 0, vars-on-top: 0 */
1+
/* eslint no-var: 0, babel/object-shorthand: 0, vars-on-top: 0, func-names: 0 */
22
require('babel/register');
33

44
var webpackConfig = require('./webpack/test.config.js');

src/ButtonGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const ButtonGroup = React.createClass({
1515
*/
1616
block: CustomPropTypes.all([
1717
React.PropTypes.bool,
18-
function(props) {
18+
props => {
1919
if (props.block && !props.vertical) {
2020
return new Error('The block property requires the vertical property to be set to have any effect');
2121
}

src/Carousel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ const Carousel = React.createClass({
208208
renderIndicators() {
209209
let indicators = [];
210210
ValidComponentChildren
211-
.forEach(this.props.children, function(child, index) {
211+
.forEach(this.props.children, (child, index) => {
212212
indicators.push(
213213
this.renderIndicator(child, index),
214214

@@ -233,7 +233,7 @@ const Carousel = React.createClass({
233233
this.setState({
234234
previousActiveIndex: null,
235235
direction: null
236-
}, function() {
236+
}, () => {
237237
this.waitForNext();
238238

239239
if (this.props.onSlideEnd) {

src/Col.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const Col = React.createClass({
149149
let ComponentClass = this.props.componentClass;
150150
let classes = {};
151151

152-
Object.keys(styleMaps.SIZES).forEach(function(key) {
152+
Object.keys(styleMaps.SIZES).forEach( key => {
153153
let size = styleMaps.SIZES[key];
154154
let prop = size;
155155
let classPart = size + '-';

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/DropdownButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ DropdownButton.propTypes = {
4848
*/
4949
navItem: CustomPropTypes.all([
5050
React.PropTypes.bool,
51-
function(props) {
51+
props => {
5252
if (props.navItem) {
5353
deprecationWarning('navItem', 'NavDropdown component', 'https://github.com/react-bootstrap/react-bootstrap/issues/526');
5454
}

src/FadeMixin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import deprecationWarning from './utils/deprecationWarning';
66
function getElementsAndSelf(root, classes) {
77
let els = root.querySelectorAll('.' + classes.join('.'));
88

9-
els = [].map.call(els, function(e) { return e; });
9+
els = [].map.call(els, e => e );
1010

1111
for (let i = 0; i < classes.length; i++) {
1212
if ( !root.className.match(new RegExp('\\b' + classes[i] + '\\b'))) {
@@ -29,7 +29,7 @@ export default {
2929
els = getElementsAndSelf(React.findDOMNode(this), ['fade']);
3030

3131
if (els.length) {
32-
els.forEach(function(el) {
32+
els.forEach( el => {
3333
el.className += ' in';
3434
});
3535
}
@@ -40,7 +40,7 @@ export default {
4040
let els = getElementsAndSelf(this._fadeOutEl, ['fade', 'in']);
4141

4242
if (els.length) {
43-
els.forEach(function(el) {
43+
els.forEach( el => {
4444
el.className = el.className.replace(/\bin\b/, '');
4545
});
4646
}

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: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Interpolate = React.createClass({
3636
delete props.unsafe;
3737

3838
if (unsafe) {
39-
let content = format.split(REGEXP).reduce(function(memo, match, index) {
39+
let content = format.split(REGEXP).reduce((memo, match, index) => {
4040
let html;
4141

4242
if (index % 2 === 0) {
@@ -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(function(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/MenuItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ MenuItem.propTypes = {
6666
active: React.PropTypes.bool,
6767
divider: CustomPropTypes.all([
6868
React.PropTypes.bool,
69-
function(props) {
69+
props => {
7070
if (props.divider && props.children) {
7171
return new Error('Children will not be rendered for dividers');
7272
}

src/Modal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ const Modal = React.createClass({
406406
// IOS only allows click events to be delegated to the document on elements
407407
// it considers 'clickable' - anchors, buttons, etc. We fake a click handler on the
408408
// DOM nodes themselves. Remove if handled by React: https://github.com/facebook/react/issues/1169
409-
React.findDOMNode(this.refs.modal).onclick = function() {};
410-
React.findDOMNode(this.refs.backdrop).onclick = function() {};
409+
React.findDOMNode(this.refs.modal).onclick = () => {};
410+
React.findDOMNode(this.refs.backdrop).onclick = () => {};
411411
},
412412

413413
_getStyles() {

src/Panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const Panel = React.createClass({
132132
addPanelBody(allChildren);
133133
}
134134
} else {
135-
allChildren.forEach(function(child) {
135+
allChildren.forEach( child => {
136136
if (this.shouldRenderFill(child)) {
137137
maybeRenderPanelBody();
138138

@@ -141,7 +141,7 @@ const Panel = React.createClass({
141141
} else {
142142
panelBodyChildren.push(child);
143143
}
144-
}.bind(this));
144+
});
145145

146146
maybeRenderPanelBody();
147147
}

src/SubNav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const SubNav = React.createClass({
6262

6363
ValidComponentChildren.forEach(
6464
child.props.children,
65-
function(grandchild) {
65+
grandchild => {
6666
if (this.isChildActive(grandchild)) {
6767
isActive = true;
6868
}

src/TabbedArea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const TabbedArea = React.createClass({
1515
render() {
1616
const {children, ...props} = this.props;
1717

18-
const tabs = ValidComponentChildren.map(children, function(child) {
18+
const tabs = ValidComponentChildren.map(children, child => {
1919
const {tab: title, ...others} = child.props;
2020
return <TabPane title={title} {...others} />;
2121
});

src/Tabs.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let findChild = ValidComponentChildren.find;
1717
function getDefaultActiveKeyFromChildren(children) {
1818
let defaultActiveKey;
1919

20-
ValidComponentChildren.forEach(children, function(child) {
20+
ValidComponentChildren.forEach(children, child => {
2121
if (defaultActiveKey == null) {
2222
defaultActiveKey = child.props.eventKey;
2323
}
@@ -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() {
@@ -299,7 +299,7 @@ const Tabs = React.createClass({
299299
let panesColProps;
300300
if (paneWidth == null) {
301301
panesColProps = {};
302-
Object.keys(tabsColProps).forEach(function(size) {
302+
Object.keys(tabsColProps).forEach( size => {
303303
panesColProps[size] = styleMaps.GRID_COLUMNS - tabsColProps[size];
304304
});
305305
} else if (paneWidth instanceof Object) {

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

0 commit comments

Comments
 (0)