Skip to content

Commit 7202970

Browse files
committed
Impose 'brace-style' 'default-case' and 'ident' rules
part of `airbnb` style
1 parent a5ae517 commit 7202970

20 files changed

+153
-159
lines changed

.eslintrc

-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313
"babel"
1414
],
1515
"rules": {
16-
"brace-style": 0,
1716
"constructor-super": 2,
1817
"comma-dangle": 0,
1918
"comma-spacing": 2,
2019
"comma-style": [2, "last"],
21-
"default-case": 0,
2220
"func-names": 0,
2321
"guard-for-in": 0,
24-
"indent": 0,
2522
"one-var": [2, { "initialized": "never" }],
2623
"padded-blocks": 0,
2724
"prefer-const": 0,

docs/examples/ButtonInput.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const ButtonInputExample = React.createClass({
1717
let length = this.refs.input.getValue().length;
1818
let style = 'danger';
1919

20-
if (length > 10) { style = 'success'; }
21-
else if (length > 5) { style = 'warning'; }
20+
if (length > 10) style = 'success';
21+
else if (length > 5) style = 'warning';
2222

2323
let disabled = style !== 'success';
2424

docs/examples/Input.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const ExampleInput = React.createClass({
77

88
validationState() {
99
let length = this.state.value.length;
10-
if (length > 10) { return 'success'; }
11-
else if (length > 5) { return 'warning'; }
12-
else if (length > 0) { return 'error'; }
10+
if (length > 10) return 'success';
11+
else if (length > 5) return 'warning';
12+
else if (length > 0) return 'error';
1313
},
1414

1515
handleChange() {

docs/src/PropTable.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,28 @@ const PropTable = React.createClass({
146146
let doclets = prop.doclets || {};
147147

148148
switch (name) {
149-
case 'object':
150-
return name;
151-
case 'union':
152-
return type.value.reduce((current, val, i, list) => {
153-
let item = this.getType({ type: val });
154-
if (React.isValidElement(item)) {
155-
item = React.cloneElement(item, {key: i});
156-
}
157-
current = current.concat(item);
158-
159-
return i === (list.length - 1) ? current : current.concat(' | ');
160-
}, []);
161-
case 'array':
162-
let child = this.getType({ type: type.value });
163-
164-
return <span>{'array<'}{ child }{'>'}</span>;
165-
case 'enum':
166-
return this.renderEnum(type);
167-
case 'custom':
168-
return cleanDocletValue(doclets.type || name);
169-
default:
170-
return name;
149+
case 'object':
150+
return name;
151+
case 'union':
152+
return type.value.reduce((current, val, i, list) => {
153+
let item = this.getType({ type: val });
154+
if (React.isValidElement(item)) {
155+
item = React.cloneElement(item, {key: i});
156+
}
157+
current = current.concat(item);
158+
159+
return i === (list.length - 1) ? current : current.concat(' | ');
160+
}, []);
161+
case 'array':
162+
let child = this.getType({ type: type.value });
163+
164+
return <span>{'array<'}{ child }{'>'}</span>;
165+
case 'enum':
166+
return this.renderEnum(type);
167+
case 'custom':
168+
return cleanDocletValue(doclets.type || name);
169+
default:
170+
return name;
171171
}
172172
},
173173

src/AffixMixin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const AffixMixin = {
3030

3131
checkPosition() {
3232
let DOMNode, scrollHeight, scrollTop, position, offsetTop, offsetBottom,
33-
affix, affixType, affixPositionTop;
33+
affix, affixType, affixPositionTop;
3434

3535
// TODO: or not visible
3636
if (!this.isMounted()) {

src/Carousel.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,18 @@ const Carousel = React.createClass({
249249
this.state.previousActiveIndex === index && this.props.slide;
250250

251251
return cloneElement(
252-
child,
253-
{
254-
active: isActive,
255-
ref: child.ref,
256-
key: child.key ? child.key : index,
257-
index,
258-
animateOut: isPreviousActive,
259-
animateIn: isActive && this.state.previousActiveIndex != null && this.props.slide,
260-
direction: this.state.direction,
261-
onAnimateOutEnd: isPreviousActive ? this.handleItemAnimateOutEnd : null
262-
}
263-
);
252+
child,
253+
{
254+
active: isActive,
255+
ref: child.ref,
256+
key: child.key ? child.key : index,
257+
index,
258+
animateOut: isPreviousActive,
259+
animateIn: isActive && this.state.previousActiveIndex != null && this.props.slide,
260+
direction: this.state.direction,
261+
onAnimateOutEnd: isPreviousActive ? this.handleItemAnimateOutEnd : null
262+
}
263+
);
264264
},
265265

266266
handleSelect(index, direction) {

src/Dropdown.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,21 @@ class Dropdown extends React.Component {
106106
};
107107

108108
switch(event.keyCode) {
109-
case keycode.codes.down:
110-
if (!this.props.open) {
111-
this.toggleOpen();
112-
}
113-
else {
114-
focusNext();
115-
}
116-
event.preventDefault();
117-
break;
118-
case keycode.codes.esc:
119-
case keycode.codes.tab:
120-
if (this.props.open) {
121-
this.handleClose(event);
122-
}
123-
break;
109+
case keycode.codes.down:
110+
if (!this.props.open) {
111+
this.toggleOpen();
112+
} else {
113+
focusNext();
114+
}
115+
event.preventDefault();
116+
break;
117+
case keycode.codes.esc:
118+
case keycode.codes.tab:
119+
if (this.props.open) {
120+
this.handleClose(event);
121+
}
122+
break;
123+
default:
124124
}
125125
}
126126

@@ -134,8 +134,7 @@ class Dropdown extends React.Component {
134134
// to the next focusable input
135135
if (event && event.keyCode === keycode.codes.tab){
136136
setTimeout(this.toggleOpen);
137-
}
138-
else {
137+
} else {
139138
this.toggleOpen();
140139
}
141140

src/DropdownMenu.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ class DropdownMenu extends React.Component {
2020
handleKeyDown(event) {
2121

2222
switch(event.keyCode) {
23-
case keycode.codes.down:
24-
this.focusNext();
25-
event.preventDefault();
26-
break;
27-
case keycode.codes.up:
28-
this.focusPrevious();
29-
event.preventDefault();
30-
break;
31-
case keycode.codes.esc:
32-
case keycode.codes.tab:
33-
this.props.onClose(event);
34-
break;
23+
case keycode.codes.down:
24+
this.focusNext();
25+
event.preventDefault();
26+
break;
27+
case keycode.codes.up:
28+
this.focusPrevious();
29+
event.preventDefault();
30+
break;
31+
case keycode.codes.esc:
32+
case keycode.codes.tab:
33+
this.props.onClose(event);
34+
break;
35+
default:
3536
}
3637
}
3738

src/InputBase.js

+24-23
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ class InputBase extends React.Component {
7676

7777
let inputGroupClassName;
7878
switch (this.props.bsSize) {
79-
case 'small': inputGroupClassName = 'input-group-sm'; break;
80-
case 'large': inputGroupClassName = 'input-group-lg'; break;
79+
case 'small': inputGroupClassName = 'input-group-sm'; break;
80+
case 'large': inputGroupClassName = 'input-group-lg'; break;
81+
default:
8182
}
8283

8384
return addonBefore || addonAfter || buttonBefore || buttonAfter ? (
@@ -98,10 +99,10 @@ class InputBase extends React.Component {
9899
}
99100

100101
switch (this.props.bsStyle) {
101-
case 'success': return <Glyphicon formControlFeedback glyph="ok" key="icon" />;
102-
case 'warning': return <Glyphicon formControlFeedback glyph="warning-sign" key="icon" />;
103-
case 'error': return <Glyphicon formControlFeedback glyph="remove" key="icon" />;
104-
default: return <span className="form-control-feedback" key="icon" />;
102+
case 'success': return <Glyphicon formControlFeedback glyph="ok" key="icon" />;
103+
case 'warning': return <Glyphicon formControlFeedback glyph="warning-sign" key="icon" />;
104+
case 'error': return <Glyphicon formControlFeedback glyph="remove" key="icon" />;
105+
default: return <span className="form-control-feedback" key="icon" />;
105106
}
106107
} else {
107108
return null;
@@ -157,24 +158,24 @@ class InputBase extends React.Component {
157158
}
158159

159160
switch (this.props.type) {
160-
case 'select':
161-
return (
162-
<select {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input">
163-
{this.props.children}
164-
</select>
165-
);
166-
case 'textarea':
167-
return <textarea {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input" />;
168-
case 'static':
169-
return (
170-
<p {...this.props} className={classNames(this.props.className, 'form-control-static')} ref="input" key="input">
171-
{this.props.value}
172-
</p>
173-
);
161+
case 'select':
162+
return (
163+
<select {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input">
164+
{this.props.children}
165+
</select>
166+
);
167+
case 'textarea':
168+
return <textarea {...this.props} className={classNames(this.props.className, 'form-control')} ref="input" key="input" />;
169+
case 'static':
170+
return (
171+
<p {...this.props} className={classNames(this.props.className, 'form-control-static')} ref="input" key="input">
172+
{this.props.value}
173+
</p>
174+
);
175+
default:
176+
const className = this.isCheckboxOrRadio() || this.isFile() ? '' : 'form-control';
177+
return <input {...this.props} className={classNames(this.props.className, className)} ref="input" key="input" />;
174178
}
175-
176-
let className = this.isCheckboxOrRadio() || this.isFile() ? '' : 'form-control';
177-
return <input {...this.props} className={classNames(this.props.className, className)} ref="input" key="input" />;
178179
}
179180

180181
renderFormGroup(children) {

src/NavItem.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ const NavItem = React.createClass({
3939
'aria-controls': ariaControls,
4040
...props } = this.props;
4141
let classes = {
42-
active,
43-
disabled
44-
};
42+
active,
43+
disabled
44+
};
4545
let linkProps = {
46-
role,
47-
href,
48-
title,
49-
target,
50-
id: linkId,
51-
onClick: this.handleClick
52-
};
46+
role,
47+
href,
48+
title,
49+
target,
50+
id: linkId,
51+
onClick: this.handleClick
52+
};
5353

5454
if (!role && href === '#') {
5555
linkProps.role = 'button';

src/Navbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const Navbar = React.createClass({
139139
<span className="icon-bar" key={1}></span>,
140140
<span className="icon-bar" key={2}></span>,
141141
<span className="icon-bar" key={3}></span>
142-
];
142+
];
143143

144144
return (
145145
<button className="navbar-toggle" type="button" onClick={this.handleToggle}>

src/Overlay.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ Overlay.propTypes = {
5656
* Use animation
5757
*/
5858
animation: React.PropTypes.oneOfType([
59-
React.PropTypes.bool,
60-
elementType
59+
React.PropTypes.bool,
60+
elementType
6161
]),
6262

6363
/**

src/SplitButton.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SplitButton extends React.Component {
1717
bsStyle, // eslint-disable-line
1818
...props } = this.props;
1919

20-
let { disabled } = props;
20+
let { disabled } = props;
2121

2222
let button = (
2323
<Button

src/Tabs.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,16 @@ const Tabs = React.createClass({
205205
let paneIsAlreadyActive = previousActiveKey != null && child.props.eventKey === previousActiveKey;
206206

207207
return cloneElement(
208-
child,
209-
{
210-
active: shouldPaneBeSetActive && (thereIsNoActivePane || !this.props.animation),
211-
id: paneId(this.props, child),
212-
'aria-labelledby': tabId(this.props, child),
213-
key: child.key ? child.key : index,
214-
animation: this.props.animation,
215-
onAnimateOutEnd: paneIsAlreadyActive ? this.handlePaneAnimateOutEnd : null
216-
}
217-
);
208+
child,
209+
{
210+
active: shouldPaneBeSetActive && (thereIsNoActivePane || !this.props.animation),
211+
id: paneId(this.props, child),
212+
'aria-labelledby': tabId(this.props, child),
213+
key: child.key ? child.key : index,
214+
animation: this.props.animation,
215+
onAnimateOutEnd: paneIsAlreadyActive ? this.handlePaneAnimateOutEnd : null
216+
}
217+
);
218218
},
219219

220220
renderTab(child) {

src/Thumbnail.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const Thumbnail = React.createClass({
2727
<img src={this.props.src} alt={this.props.alt} />
2828
</SafeAnchor>
2929
);
30-
}
31-
else {
30+
} else {
3231
if(this.props.children) {
3332
return (
3433
<div {...this.props} className={classSet(this.props.className, classes)}>
@@ -38,8 +37,7 @@ const Thumbnail = React.createClass({
3837
</div>
3938
</div>
4039
);
41-
}
42-
else {
40+
} else {
4341
return (
4442
<div {...this.props} className={classSet(this.props.className, classes)}>
4543
<img src={this.props.src} alt={this.props.alt} />

src/utils/deprecationWarning.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ function deprecationWarning(oldname, newname, link) {
77

88
if (typeof oldname === 'object'){
99
message = oldname.message;
10-
}
11-
else {
10+
} else {
1211
message = `${oldname} is deprecated. Use ${newname} instead.`;
1312

1413
if (link) {
@@ -38,4 +37,3 @@ deprecationWarning.wrapper = function(Component, ...args){
3837
};
3938

4039
export default deprecationWarning;
41-

0 commit comments

Comments
 (0)