Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint] Enforce brace-style #2920

Merged
merged 1 commit into from
Jan 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rules:
array-bracket-spacing: [2, never]
arrow-spacing: 2
block-spacing: [2, always]
brace-style: 0 # Wishlist, one day
brace-style: 2
comma-dangle: [2, always-multiline]
comma-spacing: [2, {before: false, after: true}]
comma-style: [2, last]
Expand Down
3 changes: 1 addition & 2 deletions docs/src/app/components/pages/customization/themes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ const ThemesPage = React.createClass({

if (!this.state.isThemeDark) {
newMuiTheme = ThemeManager.getMuiTheme(DarkRawTheme);
}
else {
} else {
newMuiTheme = ThemeManager.getMuiTheme(DefaultRawTheme);
}

Expand Down
3 changes: 1 addition & 2 deletions src/DropDownMenu/DropDownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ const DropDownMenu = React.createClass({
if (this.props.autoWidth) this._setWidth();
if (nextProps.hasOwnProperty('value') || nextProps.hasOwnProperty('valueLink')) {
return;
}
else if (nextProps.hasOwnProperty('selectedIndex')) {
} else if (nextProps.hasOwnProperty('selectedIndex')) {
this._setSelectedIndex(nextProps.selectedIndex);
}
},
Expand Down
9 changes: 3 additions & 6 deletions src/TextField/TextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,9 @@ const TextField = React.createClass({

if (hasValueLinkProp) {
newState.hasValue = isValid(nextProps.valueLink.value);
}
else if (hasValueProp) {
} else if (hasValueProp) {
newState.hasValue = isValid(nextProps.value);
}
else if (hasNewDefaultValue) {
} else if (hasNewDefaultValue) {
newState.hasValue = isValid(nextProps.defaultValue);
}

Expand Down Expand Up @@ -382,8 +380,7 @@ const TextField = React.createClass({
if (this.isMounted()) {
if (this.props.multiLine) {
this.refs.input.setValue(newValue);
}
else {
} else {
this._getInputNode().value = newValue;
}

Expand Down
6 changes: 2 additions & 4 deletions src/auto-complete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ const AutoComplete = React.createClass({
chosenRequest = this.requestsList[parseInt(child.key, 10)];
index = dataSource.indexOf(chosenRequest);
searchText = dataSource[index];
}
else {
} else {
chosenRequest = child.key;
index = dataSource.indexOf(
dataSource.filter((item) => chosenRequest === item.text)[0]);
Expand Down Expand Up @@ -453,8 +452,7 @@ AutoComplete.levenshteinDistance = (searchText, key) => {
if (i && j) {
if (searchText.charAt(j - 1) === key.charAt(i - 1)) value = prev;
else value = Math.min(current[j], current[j - 1], prev) + 1;
}
else {
} else {
value = i + j;
}
prev = current[j];
Expand Down
3 changes: 1 addition & 2 deletions src/card/card-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ const CardHeader = React.createClass({
if (React.isValidElement(this.props.avatar)) {
let avatarMergedStyle = this.mergeStyles(styles.avatar, avatar.props.style);
avatar = React.cloneElement(avatar, {style: avatarMergedStyle});
}
else if (avatar !== null) {
} else if (avatar !== null) {
avatar = <Avatar src={this.props.avatar} style={styles.avatar}/>;
}

Expand Down
6 changes: 2 additions & 4 deletions src/card/card-media.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ const CardMedia = React.createClass({
titleColor: Styles.Colors.darkWhite,
subtitleColor: Styles.Colors.lightWhite,
});
}
else if (child.type.displayName === 'CardText') {
} else if (child.type.displayName === 'CardText') {
return React.cloneElement(child, {
color: Styles.Colors.darkWhite,
});
}
else {
} else {
return child;
}
});
Expand Down
6 changes: 2 additions & 4 deletions src/circular-progress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ const CircularProgress = React.createClass({
path.style.strokeDasharray = '1, 200';
path.style.strokeDashoffset = 0;
path.style.transitionDuration = '0ms';
}
else if (step === 1) {
} else if (step === 1) {
path.style.strokeDasharray = '89, 200';
path.style.strokeDashoffset = -35;
path.style.transitionDuration = '750ms';
}
else {
} else {
path.style.strokeDasharray = '89,200';
path.style.strokeDashoffset = -124;
path.style.transitionDuration = '850ms';
Expand Down
3 changes: 1 addition & 2 deletions src/date-picker/calendar-month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const CalendarMonth = React.createClass({
if (isSameDate) {
if (disabled) {
this._selectedDateDisabled = true;
}
else {
} else {
this._selectedDateDisabled = false;
}
}
Expand Down
30 changes: 10 additions & 20 deletions src/date-picker/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,14 @@ const Calendar = React.createClass({
let adjustedDate = date;
if (DateTime.isBeforeDate(date, this.props.minDate)) {
adjustedDate = this.props.minDate;
}
else if (DateTime.isAfterDate(date, this.props.maxDate)) {
} else if (DateTime.isAfterDate(date, this.props.maxDate)) {
adjustedDate = this.props.maxDate;
}

let newDisplayDate = DateTime.getFirstDayOfMonth(adjustedDate);
if (newDisplayDate !== this.state.displayDate) {
this._setDisplayDate(newDisplayDate, adjustedDate);
}
else {
} else {
this.setState({
selectedDate: adjustedDate,
});
Expand Down Expand Up @@ -202,47 +200,39 @@ const Calendar = React.createClass({
case KeyCode.UP:
if (e.altKey && e.shiftKey) {
this._addSelectedYears(-1);
}
else if (e.shiftKey) {
} else if (e.shiftKey) {
this._addSelectedMonths(-1);
}
else {
} else {
this._addSelectedDays(-7);
}
break;

case KeyCode.DOWN:
if (e.altKey && e.shiftKey) {
this._addSelectedYears(1);
}
else if (e.shiftKey) {
} else if (e.shiftKey) {
this._addSelectedMonths(1);
}
else {
} else {
this._addSelectedDays(7);
}
break;

case KeyCode.RIGHT:
if (e.altKey && e.shiftKey) {
this._addSelectedYears(1);
}
else if (e.shiftKey) {
} else if (e.shiftKey) {
this._addSelectedMonths(1);
}
else {
} else {
this._addSelectedDays(1);
}
break;

case KeyCode.LEFT:
if (e.altKey && e.shiftKey) {
this._addSelectedYears(-1);
}
else if (e.shiftKey) {
} else if (e.shiftKey) {
this._addSelectedMonths(-1);
}
else {
} else {
this._addSelectedDays(-1);
}
break;
Expand Down
3 changes: 1 addition & 2 deletions src/date-picker/day-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ const DayButton = React.createClass({
styles.label.color = this.getTheme().selectTextColor;
styles.buttonState.opacity = 1;
styles.buttonState.transform = 'scale(1)';
}
else if (this.props.disabled) {
} else if (this.props.disabled) {
styles.root.opacity = '0.6';
}

Expand Down
9 changes: 3 additions & 6 deletions src/enhanced-switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,11 @@ const EnhancedSwitch = React.createClass({

if (hasCheckedProp) {
newState.switched = nextProps.checked;
}
else if (hasToggledProp) {
} else if (hasToggledProp) {
newState.switched = nextProps.toggled;
}
else if (hasCheckedLinkProp) {
} else if (hasCheckedLinkProp) {
newState.switched = nextProps.checkedLink.value;
}
else if (hasNewDefaultProp) {
} else if (hasNewDefaultProp) {
newState.switched = nextProps.defaultSwitched;
}

Expand Down
3 changes: 1 addition & 2 deletions src/floating-action-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ const FloatingActionButton = React.createClass({
this.setState({zDepth: this.state.initialZDepth + 1});
ReactDOM.findDOMNode(this.refs.overlay).style.backgroundColor =
ColorManipulator.fade(this.getStyles().icon.color, 0.4);
}
else if (!this.state.hovered) {
} else if (!this.state.hovered) {
this.setState({zDepth: this.state.initialZDepth});
ReactDOM.findDOMNode(this.refs.overlay).style.backgroundColor = 'transparent';
}
Expand Down
3 changes: 1 addition & 2 deletions src/icon-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ const IconButton = React.createClass({
if (keyboardFocused && !this.props.disabled) {
this._showTooltip();
if (this.props.onFocus) this.props.onFocus(e);
}
else if (!this.state.hovered) {
} else if (!this.state.hovered) {
this._hideTooltip();
if (this.props.onBlur) this.props.onBlur(e);
}
Expand Down
15 changes: 5 additions & 10 deletions src/left-nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ const LeftNav = React.createClass({
if (this.state.swiping) {
e.preventDefault();
this._setPosition(this._getTranslateX(currentX));
}
else if (this._maybeSwiping) {
} else if (this._maybeSwiping) {
const dXAbs = Math.abs(currentX - this._touchStartX);
const dYAbs = Math.abs(currentY - this._touchStartY);
// If the user has moved his thumb ten pixels in either direction,
Expand All @@ -450,8 +449,7 @@ const LeftNav = React.createClass({
swiping: this.state.open ? 'closing' : 'opening',
});
this._setPosition(this._getTranslateX(currentX));
}
else if (dXAbs <= threshold && dYAbs > threshold) {
} else if (dXAbs <= threshold && dYAbs > threshold) {
this._onBodyTouchEnd();
}
}
Expand All @@ -476,16 +474,14 @@ const LeftNav = React.createClass({
} else {
this._close('swipe');
}
}
else {
} else {
if (swiping === 'opening') {
this._open('swipe');
} else {
this._setPosition(0);
}
}
}
else {
} else {
this._maybeSwiping = false;
}

Expand Down Expand Up @@ -527,8 +523,7 @@ const LeftNav = React.createClass({
let children;
if (menuItems === undefined) {
children = this.props.children;
}
else {
} else {
children = (
<Menu
ref="menuItems"
Expand Down
12 changes: 4 additions & 8 deletions src/linear-progress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,12 @@ const LinearProgress = React.createClass({
if (step === 0) {
barElement.style[left] = stepValues[0][0] + '%';
barElement.style[right] = stepValues[0][1] + '%';
}
else if (step === 1) {
} else if (step === 1) {
barElement.style.transitionDuration = '840ms';
}
else if (step === 2) {
} else if (step === 2) {
barElement.style[left] = stepValues[1][0] + '%';
barElement.style[right] = stepValues[1][1] + '%';
}
else if (step === 3) {
} else if (step === 3) {
barElement.style.transitionDuration = '0ms';
}
this.timers[id] = setTimeout(() => this._barUpdate(id, step + 1, barElement, stepValues), 420);
Expand Down Expand Up @@ -175,8 +172,7 @@ const LinearProgress = React.createClass({
bottom: 0,
transition: Transitions.create('all', '840ms', null, 'cubic-bezier(0.165, 0.840, 0.440, 1.000)'),
};
}
else {
} else {
styles.bar.backgroundColor = this.props.color || this.getTheme().primary1Color;
styles.bar.transition = Transitions.create('width', '.3s', null, 'linear');
styles.bar.width = this._getRelativeValue() + '%';
Expand Down
3 changes: 1 addition & 2 deletions src/menus/menu-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ const MenuItem = React.createClass({

_cloneMenuItem(item) {
return React.cloneElement(item, {
onTouchTap: (event) =>
{
onTouchTap: (event) => {
if (!item.props.menuItems) {
this._onRequestClose();
}
Expand Down
6 changes: 2 additions & 4 deletions src/menus/menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ const Menu = React.createClass({
e.preventDefault();
if (e.shiftKey) {
this._decrementKeyboardFocusIndex();
}
else {
} else {
this._incrementKeyboardFocusIndex(filteredChildren);
}
break;
Expand Down Expand Up @@ -389,8 +388,7 @@ const Menu = React.createClass({
update(menuValue, {$splice: [[index, 1]]});

valueLink.requestChange(e, newMenuValue);
}
else if (!multiple && itemValue !== menuValue) {
} else if (!multiple && itemValue !== menuValue) {
valueLink.requestChange(e, itemValue);
}

Expand Down
3 changes: 1 addition & 2 deletions src/raised-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ const RaisedButton = React.createClass({
let amount = (this.props.primary || this.props.secondary) ? 0.4 : 0.08;
ReactDOM.findDOMNode(this.refs.overlay).style.backgroundColor =
ColorManipulator.fade(this.prepareStyles(this.getStyles().label, this.props.labelStyle).color, amount);
}
else if (!this.state.hovered) {
} else if (!this.state.hovered) {
this.setState({zDepth: this.state.initialZDepth});
ReactDOM.findDOMNode(this.refs.overlay).style.backgroundColor = 'transparent';
}
Expand Down
8 changes: 6 additions & 2 deletions src/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ const Slider = React.createClass({
},

_dragHandler(e) {
if (this._dragRunning) { return; }
if (this._dragRunning) {
return;
}
this._dragRunning = true;
requestAnimationFrame(() => {
this._onDragUpdate(e, e.clientX - this._getTrackLeft());
Expand All @@ -348,7 +350,9 @@ const Slider = React.createClass({
},

_dragTouchHandler(e) {
if (this._dragRunning) { return; }
if (this._dragRunning) {
return;
}
this._dragRunning = true;
requestAnimationFrame(() => {
this._onDragUpdate(e, e.touches[0].clientX - this._getTrackLeft());
Expand Down
Loading