Skip to content

Commit

Permalink
Merge pull request react-bootstrap#1335 from AlexKVal/airbnb
Browse files Browse the repository at this point in the history
Left `Airbnb` rules.
  • Loading branch information
AlexKVal committed Sep 20, 2015
2 parents 350f28e + 3552723 commit dc669b6
Show file tree
Hide file tree
Showing 86 changed files with 783 additions and 806 deletions.
3 changes: 0 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
"constructor-super": 2,
"comma-dangle": 0,
"eqeqeq": [2, "allow-null"],
"func-names": 0,
"guard-for-in": 0,
"one-var": [2, { "initialized": "never" }],
"prefer-const": 0,
"key-spacing": 0,
"no-eq-null": 0,
"no-else-return": 0,
"no-param-reassign": 0,
"no-this-before-super": 2,
"no-undef": 2,
Expand Down
6 changes: 3 additions & 3 deletions docs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ if (development) {
let webpackPort = process.env.WEBPACK_DEV_PORT;
let target = `http://${ip.address()}:${webpackPort}`;

app.get('/assets/*', function(req, res) {
app.get('/assets/*', (req, res) => {
proxy.web(req, res, { target });
});

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

app.listen(port, function() {
app.listen(port, () => {
console.log(`Server started at:`);
console.log(`- http://localhost:${port}`);
console.log(`- http://${ip.address()}:${port}`);
Expand Down
4 changes: 2 additions & 2 deletions docs/src/PropTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ const PropTable = React.createClass({
return 'function';
} else if (typeName === 'bool') {
return 'boolean';
} else {
return typeName;
}

return typeName;
},

renderEnum(enumType) {
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint no-var: 0, babel/object-shorthand: 0, vars-on-top: 0 */
/* eslint no-var: 0, babel/object-shorthand: 0, vars-on-top: 0, func-names: 0 */
require('babel/register');

var webpackConfig = require('./webpack/test.config.js');
Expand Down
2 changes: 1 addition & 1 deletion src/ButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ButtonGroup = React.createClass({
*/
block: CustomPropTypes.all([
React.PropTypes.bool,
function(props) {
props => {
if (props.block && !props.vertical) {
return new Error('The block property requires the vertical property to be set to have any effect');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const Carousel = React.createClass({
renderIndicators() {
let indicators = [];
ValidComponentChildren
.forEach(this.props.children, function(child, index) {
.forEach(this.props.children, (child, index) => {
indicators.push(
this.renderIndicator(child, index),

Expand All @@ -233,7 +233,7 @@ const Carousel = React.createClass({
this.setState({
previousActiveIndex: null,
direction: null
}, function() {
}, () => {
this.waitForNext();

if (this.props.onSlideEnd) {
Expand Down
2 changes: 1 addition & 1 deletion src/Col.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const Col = React.createClass({
let ComponentClass = this.props.componentClass;
let classes = {};

Object.keys(styleMaps.SIZES).forEach(function(key) {
Object.keys(styleMaps.SIZES).forEach( key => {
let size = styleMaps.SIZES[key];
let prop = size;
let classPart = size + '-';
Expand Down
3 changes: 1 addition & 2 deletions src/CollapsibleNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ const CollapsibleNav = React.createClass({
{ nav }
</Collapse>
);
} else {
return nav;
}
return nav;
},

getChildActiveProp(child) {
Expand Down
2 changes: 1 addition & 1 deletion src/DropdownButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DropdownButton.propTypes = {
*/
navItem: CustomPropTypes.all([
React.PropTypes.bool,
function(props) {
props => {
if (props.navItem) {
deprecationWarning('navItem', 'NavDropdown component', 'https://github.com/react-bootstrap/react-bootstrap/issues/526');
}
Expand Down
6 changes: 3 additions & 3 deletions src/FadeMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import deprecationWarning from './utils/deprecationWarning';
function getElementsAndSelf(root, classes) {
let els = root.querySelectorAll('.' + classes.join('.'));

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

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

if (els.length) {
els.forEach(function(el) {
els.forEach( el => {
el.className += ' in';
});
}
Expand All @@ -40,7 +40,7 @@ export default {
let els = getElementsAndSelf(this._fadeOutEl, ['fade', 'in']);

if (els.length) {
els.forEach(function(el) {
els.forEach( el => {
el.className = el.className.replace(/\bin\b/, '');
});
}
Expand Down
6 changes: 2 additions & 4 deletions src/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ class InputBase extends React.Component {
} else if (this.props.type) {
if (this.props.type === 'select' && this.props.multiple) {
return this.getSelectedOptions();
} else {
return this.getInputDOMNode().value;
}
} else {
throw new Error('Cannot use getValue without specifying input type.');
return this.getInputDOMNode().value;
}
throw new Error('Cannot use getValue without specifying input type.');
}

getChecked() {
Expand Down
35 changes: 17 additions & 18 deletions src/Interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Interpolate = React.createClass({
delete props.unsafe;

if (unsafe) {
let content = format.split(REGEXP).reduce(function(memo, match, index) {
let content = format.split(REGEXP).reduce((memo, match, index) => {
let html;

if (index % 2 === 0) {
Expand All @@ -58,28 +58,27 @@ const Interpolate = React.createClass({
props.dangerouslySetInnerHTML = { __html: content };

return React.createElement(parent, props);
} else {
let kids = format.split(REGEXP).reduce(function(memo, match, index) {
let child;

if (index % 2 === 0) {
if (match.length === 0) {
return memo;
}
}
let kids = format.split(REGEXP).reduce((memo, match, index) => {
let child;

child = match;
} else {
child = props[match];
delete props[match];
if (index % 2 === 0) {
if (match.length === 0) {
return memo;
}

memo.push(child);
child = match;
} else {
child = props[match];
delete props[match];
}

return memo;
}, []);
memo.push(child);

return React.createElement(parent, props, kids);
}
return memo;
}, []);

return React.createElement(parent, props, kids);
}
});

Expand Down
3 changes: 1 addition & 2 deletions src/ListGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class ListGroup extends React.Component {

if (shouldRenderDiv) {
return this.renderDiv(items);
} else {
return this.renderUL(items);
}
return this.renderUL(items);
}

isAnchorOrButton(props) {
Expand Down
3 changes: 1 addition & 2 deletions src/ListGroupItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ const ListGroupItem = React.createClass({
return this.renderButton(classes);
} else if (this.props.listItem) {
return this.renderLi(classes);
} else {
return this.renderSpan(classes);
}
return this.renderSpan(classes);
},

renderLi(classes) {
Expand Down
2 changes: 1 addition & 1 deletion src/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MenuItem.propTypes = {
active: React.PropTypes.bool,
divider: CustomPropTypes.all([
React.PropTypes.bool,
function(props) {
props => {
if (props.divider && props.children) {
return new Error('Children will not be rendered for dividers');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ const Modal = React.createClass({
// IOS only allows click events to be delegated to the document on elements
// it considers 'clickable' - anchors, buttons, etc. We fake a click handler on the
// DOM nodes themselves. Remove if handled by React: https://github.com/facebook/react/issues/1169
React.findDOMNode(this.refs.modal).onclick = function() {};
React.findDOMNode(this.refs.backdrop).onclick = function() {};
React.findDOMNode(this.refs.modal).onclick = () => {};
React.findDOMNode(this.refs.backdrop).onclick = () => {};
},

_getStyles() {
Expand Down
4 changes: 2 additions & 2 deletions src/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const Panel = React.createClass({
addPanelBody(allChildren);
}
} else {
allChildren.forEach(function(child) {
allChildren.forEach( child => {
if (this.shouldRenderFill(child)) {
maybeRenderPanelBody();

Expand All @@ -141,7 +141,7 @@ const Panel = React.createClass({
} else {
panelBodyChildren.push(child);
}
}.bind(this));
});

maybeRenderPanelBody();
}
Expand Down
2 changes: 1 addition & 1 deletion src/SubNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const SubNav = React.createClass({

ValidComponentChildren.forEach(
child.props.children,
function(grandchild) {
grandchild => {
if (this.isChildActive(grandchild)) {
isActive = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TabbedArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TabbedArea = React.createClass({
render() {
const {children, ...props} = this.props;

const tabs = ValidComponentChildren.map(children, function(child) {
const tabs = ValidComponentChildren.map(children, child => {
const {tab: title, ...others} = child.props;
return <TabPane title={title} {...others} />;
});
Expand Down
34 changes: 17 additions & 17 deletions src/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let findChild = ValidComponentChildren.find;
function getDefaultActiveKeyFromChildren(children) {
let defaultActiveKey;

ValidComponentChildren.forEach(children, function(child) {
ValidComponentChildren.forEach(children, child => {
if (defaultActiveKey == null) {
defaultActiveKey = child.props.eventKey;
}
Expand Down Expand Up @@ -218,27 +218,27 @@ const Tabs = React.createClass({
{panes}
</div>
);
} else {
return (
<div {...containerProps}>
{panes}
{tabs}
</div>
);
}
} else {

return (
<div {...containerProps}>
<Nav {...tabsProps}>
{childTabs}
</Nav>

<div {...panesProps}>
{childPanes}
</div>
{panes}
{tabs}
</div>
);
}

return (
<div {...containerProps}>
<Nav {...tabsProps}>
{childTabs}
</Nav>

<div {...panesProps}>
{childPanes}
</div>
</div>
);
},

getActiveKey() {
Expand Down Expand Up @@ -299,7 +299,7 @@ const Tabs = React.createClass({
let panesColProps;
if (paneWidth == null) {
panesColProps = {};
Object.keys(tabsColProps).forEach(function(size) {
Object.keys(tabsColProps).forEach( size => {
panesColProps[size] = styleMaps.GRID_COLUMNS - tabsColProps[size];
});
} else if (paneWidth instanceof Object) {
Expand Down
32 changes: 16 additions & 16 deletions src/Thumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ const Thumbnail = React.createClass({
<img src={this.props.src} alt={this.props.alt} />
</SafeAnchor>
);
} else {
if (this.props.children) {
return (
<div {...this.props} className={classSet(this.props.className, classes)}>
<img src={this.props.src} alt={this.props.alt} />
<div className="caption">
{this.props.children}
</div>
</div>
);
} else {
return (
<div {...this.props} className={classSet(this.props.className, classes)}>
<img src={this.props.src} alt={this.props.alt} />
}

if (this.props.children) {
return (
<div {...this.props} className={classSet(this.props.className, classes)}>
<img src={this.props.src} alt={this.props.alt} />
<div className="caption">
{this.props.children}
</div>
);
}
</div>
);
}

return (
<div {...this.props} className={classSet(this.props.className, classes)}>
<img src={this.props.src} alt={this.props.alt} />
</div>
);
}
});

Expand Down
Loading

0 comments on commit dc669b6

Please sign in to comment.