Skip to content

Commit 9dbf33b

Browse files
committed
Impose 'brace-style' 'default-case' and 'ident' rules
part of `airbnb` style
1 parent 886054d commit 9dbf33b

20 files changed

+153
-159
lines changed

.eslintrc

Lines changed: 0 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 22 additions & 22 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 12 additions & 12 deletions
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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,21 @@ class Dropdown extends React.Component {
105105
};
106106

107107
switch(event.keyCode) {
108-
case keycode.codes.down:
109-
if (!this.props.open) {
110-
this.toggleOpen();
111-
}
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;
108+
case keycode.codes.down:
109+
if (!this.props.open) {
110+
this.toggleOpen();
111+
} else {
112+
focusNext();
113+
}
114+
event.preventDefault();
115+
break;
116+
case keycode.codes.esc:
117+
case keycode.codes.tab:
118+
if (this.props.open) {
119+
this.handleClose(event);
120+
}
121+
break;
122+
default:
123123
}
124124
}
125125

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

src/DropdownMenu.js

Lines changed: 13 additions & 12 deletions
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

Lines changed: 24 additions & 23 deletions
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

Lines changed: 10 additions & 10 deletions
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';

0 commit comments

Comments
 (0)