Skip to content

Commit

Permalink
*: update style to conform to eslint-config-airbnb@10.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Aug 4, 2016
1 parent d1467f5 commit c72cc12
Show file tree
Hide file tree
Showing 40 changed files with 203 additions and 94 deletions.
16 changes: 4 additions & 12 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@
"new-cap": [ "error", {
"capIsNewExceptions": [ "DragDropContext", "DragSource", "DropTarget", "DragLayer", "ThemeDecorator" ]
} ],
// This rule is very heavy-handed and breaks a lot of places where we use
// parentheses for readability, particularly in React components where
// multiline JSX is surrounded by parens:
//
// return (
// <Component>
// stuff
// </Component>
// )
"no-extra-parens": "off",
// Conflicts with `_id` property names returned from the üWave HTTP API
"no-underscore-dangle": "off",
"global-require": "off",
// Temporarily disabled, see https://github.com/benmosher/eslint-plugin-import/issues/317
"import/no-mutable-exports": "off"
"react/jsx-filename-extension": "off",
// devDependencies are allowed in tests and build stuff. The eslintrc in
// src/ disallows using devDependencies in client app code.
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
}
}
8 changes: 8 additions & 0 deletions src/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": false }]
},
"env": {
"browser": true
}
}
5 changes: 4 additions & 1 deletion src/actions/BoothActionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export function advance(nextBooth) {
dispatch({
type: ADVANCE,
payload: {
userID, historyID, playlistID, user,
userID,
historyID,
playlistID,
user,
media: flattenPlaylistItem(media),
timestamp: playedAt
},
Expand Down
4 changes: 3 additions & 1 deletion src/actions/ChatActionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ export function muteUser(userID, { moderatorID, expiresAt }) {
dispatch({
type: MUTE_USER,
payload: {
userID, moderatorID, expiresAt,
userID,
moderatorID,
expiresAt,
expirationTimer: expireIn > 0 ?
setTimeout(() => dispatch(expireMute(userID)), expireIn) : null
}
Expand Down
1 change: 1 addition & 0 deletions src/actions/ErrorActionCreators.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ERROR_DISMISS } from '../constants/actionTypes/errors';

// eslint-disable-next-line import/prefer-default-export
export function dismiss() {
return { type: ERROR_DISMISS };
}
1 change: 1 addition & 0 deletions src/actions/PanelSelectActionCreators.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SELECT_PANEL } from '../constants/actionTypes/panel';

// eslint-disable-next-line import/prefer-default-export
export function selectPanel(name) {
return {
type: SELECT_PANEL,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chat/Markup/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Link = ({ text, href, ...props }) => (
href={href}
title={href}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
{...props}
>
{truncate(text, 60)}
Expand Down
10 changes: 7 additions & 3 deletions src/components/Chat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export default class Chat extends Component {
}

scrollToBottom() {
const el = this.refs.chat;
const el = this.container;
el.scrollTop = el.scrollHeight;
}

isScrolledToBottom() {
const el = this.refs.chat;
const el = this.container;
const lastMessage = el.lastElementChild;
if (lastMessage) {
const neededSize = el.scrollTop + el.offsetHeight + lastMessage.offsetHeight;
Expand All @@ -43,6 +43,10 @@ export default class Chat extends Component {
return true;
}

refContainer = container => {
this.container = container;
};

renderMotd() {
if (!this.props.motd) {
return null;
Expand All @@ -69,7 +73,7 @@ export default class Chat extends Component {

render() {
return (
<div className="Chat" ref="chat">
<div className="Chat" ref={this.refContainer}>
{this.renderMotd()}
{this.props.messages.map(this.renderMessage, this)}
</div>
Expand Down
40 changes: 31 additions & 9 deletions src/components/Dialogs/EditMediaDialog/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cx from 'classnames';
import React, { Component, PropTypes } from 'react';
import Dialog from 'material-ui/Dialog';
import uniqueId from 'lodash/uniqueId';

import ArtistIcon from 'material-ui/svg-icons/hardware/headset';
import TitleIcon from 'material-ui/svg-icons/image/music-note';
Expand All @@ -17,7 +18,7 @@ import TextField from '../../Form/TextField';
// naive HH:mm:ss → seconds
const parseDuration = str => str.split(':')
.map(part => parseInt(part.trim(), 10))
.reduce((duration, part) => duration * 60 + part, 0);
.reduce((duration, part) => (duration * 60) + part, 0);

export default class EditMediaDialog extends Component {
static propTypes = {
Expand All @@ -36,11 +37,14 @@ export default class EditMediaDialog extends Component {
errors: null
};

labelStart = uniqueId('editmedia');
labelEnd = uniqueId('editmedia');

handleSubmit = e => {
e.preventDefault();

const { media, onEditedMedia, onCloseDialog } = this.props;
const { artist, title, start, end } = this.refs;
const { artist, title, start, end } = this;

const startSeconds = parseDuration(start.value);
const endSeconds = parseDuration(end.value);
Expand Down Expand Up @@ -71,6 +75,22 @@ export default class EditMediaDialog extends Component {
onCloseDialog();
};

refArtist = artist => {
this.artist = artist;
};

refTitle = title => {
this.title = title;
};

refStart = start => {
this.start = start;
};

refEnd = end => {
this.end = end;
};

render() {
const {
open,
Expand All @@ -89,7 +109,7 @@ export default class EditMediaDialog extends Component {
if (open) {
const artistInput = (
<TextField
ref="artist"
ref={this.refArtist}
className="EditMediaDialogGroup-field"
placeholder="Artist"
defaultValue={media.artist}
Expand All @@ -99,11 +119,11 @@ export default class EditMediaDialog extends Component {
/>
);
const artistTitleLabel = (
<label className="EditMediaDialogGroup-label"></label>
<div className="EditMediaDialogGroup-label"></div>
);
const titleInput = (
<TextField
ref="title"
ref={this.refTitle}
className="EditMediaDialogGroup-field"
placeholder="Title"
defaultValue={media.title}
Expand All @@ -113,11 +133,12 @@ export default class EditMediaDialog extends Component {
);

const fromLabel = (
<label className="EditMediaDialogGroup-label">Play from:</label>
<label htmlFor={this.labelStart} className="EditMediaDialogGroup-label">Play from:</label>
);
const fromInput = (
<TextField
ref="start"
ref={this.refStart}
id={this.labelStart}
className="EditMediaDialogGroup-field"
placeholder="0:00"
defaultValue={formatDuration(media.start)}
Expand All @@ -126,11 +147,12 @@ export default class EditMediaDialog extends Component {
/>
);
const toLabel = (
<label className="EditMediaDialogGroup-label">to:</label>
<label htmlFor={this.labelEnd} className="EditMediaDialogGroup-label">to:</label>
);
const toInput = (
<TextField
ref="end"
ref={this.refEnd}
id={this.labelEnd}
className="EditMediaDialogGroup-field"
placeholder={formatDuration(media.duration)}
defaultValue={formatDuration(media.end)}
Expand Down
18 changes: 13 additions & 5 deletions src/components/Dialogs/LoginDialog/LoginForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import EmailIcon from 'material-ui/svg-icons/communication/email';
import PasswordIcon from 'material-ui/svg-icons/action/lock';
import Loader from '../../Loader';
Expand All @@ -23,11 +23,19 @@ export default class LoginForm extends React.Component {
event.preventDefault();
this.setState({ busy: true });
this.props.onLogin({
email: this.refs.email.value,
password: this.refs.password.value
email: this.email.value,
password: this.password.value
});
};

refEmail = email => {
this.email = email;
};

refPassword = password => {
this.password = password;
};

render() {
const { error } = this.props;
const { busy } = this.state;
Expand All @@ -37,7 +45,7 @@ export default class LoginForm extends React.Component {
{error && <FormGroup>{error.message}</FormGroup>}
<FormGroup>
<TextField
ref="email"
ref={this.refEmail}
className="LoginForm-field"
type="email"
placeholder="E-Mail"
Expand All @@ -47,7 +55,7 @@ export default class LoginForm extends React.Component {
</FormGroup>
<FormGroup>
<TextField
ref="password"
ref={this.refPassword}
className="LoginForm-field"
type="password"
placeholder="Password"
Expand Down
26 changes: 19 additions & 7 deletions src/components/Dialogs/LoginDialog/RegisterForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import EmailIcon from 'material-ui/svg-icons/communication/email';
import PasswordIcon from 'material-ui/svg-icons/action/lock';
import UserIcon from 'material-ui/svg-icons/social/person';
Expand Down Expand Up @@ -33,9 +33,9 @@ export default class RegisterForm extends React.Component {
event.preventDefault();
this.setState({ busy: true });
this.props.onRegister({
username: this.refs.username.value,
email: this.refs.email.value,
password: this.refs.password.value,
username: this.username.value,
email: this.email.value,
password: this.password.value,
grecaptcha: this.state.captchaResponse
});
};
Expand All @@ -46,6 +46,18 @@ export default class RegisterForm extends React.Component {
});
};

refUsername = username => {
this.username = username;
};

refEmail = email => {
this.email = email;
};

refPassword = password => {
this.password = password;
};

renderCaptcha() {
if (!this.props.useReCaptcha) {
return null;
Expand All @@ -69,7 +81,7 @@ export default class RegisterForm extends React.Component {
{error && <FormGroup>{error.message}</FormGroup>}
<FormGroup>
<TextField
ref="username"
ref={this.refUsername}
className="RegisterForm-field"
placeholder="Username"
icon={<UserIcon color="#9f9d9e" />}
Expand All @@ -78,7 +90,7 @@ export default class RegisterForm extends React.Component {
</FormGroup>
<FormGroup>
<TextField
ref="email"
ref={this.refEmail}
className="RegisterForm-field"
type="email"
placeholder="E-Mail"
Expand All @@ -87,7 +99,7 @@ export default class RegisterForm extends React.Component {
</FormGroup>
<FormGroup>
<TextField
ref="password"
ref={this.refPassword}
className="RegisterForm-field"
type="password"
placeholder="Password"
Expand Down
8 changes: 6 additions & 2 deletions src/components/Dialogs/PromptDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class PromptDialog extends React.Component {

handleSubmit = event => {
event.preventDefault();
const promise = this.props.onSubmit(this.refs.input.value);
const promise = this.props.onSubmit(this.input.value);
if (promise && promise.then) {
this.setState({ busy: true });
const onDone = () => {
Expand All @@ -56,6 +56,10 @@ export default class PromptDialog extends React.Component {
this.setState({ value: event.target.value });
};

refInput = input => {
this.input = input;
};

render() {
const {
children,
Expand Down Expand Up @@ -88,7 +92,7 @@ export default class PromptDialog extends React.Component {
{children}
<FormGroup>
<TextField
ref="input"
ref={this.refInput}
autofocus
type={inputType}
placeholder={placeholder}
Expand Down
9 changes: 6 additions & 3 deletions src/components/FooterBar/Responses/Favorite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component, PropTypes } from 'react';
import { findDOMNode } from 'react-dom';
import FavoritedIcon from 'material-ui/svg-icons/action/favorite';
import FavoriteIcon from 'material-ui/svg-icons/action/favorite-border';

Expand All @@ -17,7 +16,7 @@ export default class Favorite extends Component {
};

position() {
const pos = findDOMNode(this.refs.button).getBoundingClientRect();
const pos = this.button.getBoundingClientRect();
return {
x: pos.left,
y: pos.top
Expand All @@ -28,13 +27,17 @@ export default class Favorite extends Component {
this.props.onFavorite(this.position());
};

refButton = button => {
this.button = button;
};

render() {
const { muiTheme } = this.context;
const { active, count } = this.props;
const CurrentIcon = active ? FavoritedIcon : FavoriteIcon;
return (
<Button
ref="button"
ref={this.refButton}
tooltip="Favorite"
onClick={this.handleFavorite}
count={count}
Expand Down
Loading

0 comments on commit c72cc12

Please sign in to comment.