From c72cc12cb96a1d30d5afc2cbd14e7865bcaec031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Thu, 4 Aug 2016 11:26:51 +0200 Subject: [PATCH] *: update style to conform to eslint-config-airbnb@10.0.0 --- .eslintrc | 16 ++------ src/.eslintrc | 8 ++++ src/actions/BoothActionCreators.js | 5 ++- src/actions/ChatActionCreators.js | 4 +- src/actions/ErrorActionCreators.js | 1 + src/actions/PanelSelectActionCreators.js | 1 + src/components/Chat/Markup/Link.js | 2 +- src/components/Chat/index.js | 10 +++-- .../Dialogs/EditMediaDialog/index.js | 40 ++++++++++++++----- .../Dialogs/LoginDialog/LoginForm.js | 18 ++++++--- .../Dialogs/LoginDialog/RegisterForm.js | 26 ++++++++---- src/components/Dialogs/PromptDialog/index.js | 8 +++- .../FooterBar/Responses/Favorite.js | 9 +++-- src/components/Form/TextField.js | 10 +++-- .../MediaList/Actions/AddToPlaylist.js | 9 +++-- src/components/MediaList/Row.js | 1 - .../PlaylistManager/Header/SearchBar.js | 20 ++++++---- src/components/ReCaptcha/ReCaptcha.js | 8 +++- src/components/RoomHistory/Row.js | 1 - src/components/Video/VideoBackdrop.js | 4 +- src/components/Video/index.js | 23 ++++++----- src/constants/actionTypes/errors.js | 1 + src/constants/actionTypes/panel.js | 1 + src/containers/FooterBar.js | 9 +++-- src/reducers/playlists.js | 2 +- src/reducers/theme.js | 2 +- src/selectors/boothSelectors.js | 2 +- src/selectors/errorSelectors.js | 1 + src/selectors/roomHistorySelectors.js | 4 +- src/selectors/searchSelectors.js | 1 + src/sources/soundcloud/Player.js | 1 + src/sources/soundcloud/SongInfo.js | 2 + src/sources/youtube/ImportForm.js | 16 ++++++-- src/sources/youtube/PlayerEmbed.js | 8 +++- src/store/persistSettings.js | 2 +- src/store/request.js | 12 +++++- src/utils/Socket.js | 1 + src/utils/isDraggingNearTopOfRow.js | 3 ++ test/.eslintrc | 2 +- test/reducers/auth.js | 3 +- 40 files changed, 203 insertions(+), 94 deletions(-) create mode 100644 src/.eslintrc diff --git a/.eslintrc b/.eslintrc index 5b32ef3b7..f22298da5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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 ( - // - // stuff - // - // ) - "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 }] } } diff --git a/src/.eslintrc b/src/.eslintrc new file mode 100644 index 000000000..17ca7a506 --- /dev/null +++ b/src/.eslintrc @@ -0,0 +1,8 @@ +{ + "rules": { + "import/no-extraneous-dependencies": ["error", { "devDependencies": false }] + }, + "env": { + "browser": true + } +} diff --git a/src/actions/BoothActionCreators.js b/src/actions/BoothActionCreators.js index 2c3606789..835241f39 100644 --- a/src/actions/BoothActionCreators.js +++ b/src/actions/BoothActionCreators.js @@ -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 }, diff --git a/src/actions/ChatActionCreators.js b/src/actions/ChatActionCreators.js index 99c1c8092..fd927830d 100644 --- a/src/actions/ChatActionCreators.js +++ b/src/actions/ChatActionCreators.js @@ -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 } diff --git a/src/actions/ErrorActionCreators.js b/src/actions/ErrorActionCreators.js index 5128b7889..6204633c2 100644 --- a/src/actions/ErrorActionCreators.js +++ b/src/actions/ErrorActionCreators.js @@ -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 }; } diff --git a/src/actions/PanelSelectActionCreators.js b/src/actions/PanelSelectActionCreators.js index 2271f9137..0b740435f 100644 --- a/src/actions/PanelSelectActionCreators.js +++ b/src/actions/PanelSelectActionCreators.js @@ -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, diff --git a/src/components/Chat/Markup/Link.js b/src/components/Chat/Markup/Link.js index 2c2b62d07..3f1691f56 100644 --- a/src/components/Chat/Markup/Link.js +++ b/src/components/Chat/Markup/Link.js @@ -6,7 +6,7 @@ const Link = ({ text, href, ...props }) => ( href={href} title={href} target="_blank" - rel="noreferrer" + rel="noopener noreferrer" {...props} > {truncate(text, 60)} diff --git a/src/components/Chat/index.js b/src/components/Chat/index.js index 1cc3166bc..b2a5c3309 100644 --- a/src/components/Chat/index.js +++ b/src/components/Chat/index.js @@ -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; @@ -43,6 +43,10 @@ export default class Chat extends Component { return true; } + refContainer = container => { + this.container = container; + }; + renderMotd() { if (!this.props.motd) { return null; @@ -69,7 +73,7 @@ export default class Chat extends Component { render() { return ( -
+
{this.renderMotd()} {this.props.messages.map(this.renderMessage, this)}
diff --git a/src/components/Dialogs/EditMediaDialog/index.js b/src/components/Dialogs/EditMediaDialog/index.js index a0a1bdc8e..9ddc18f90 100644 --- a/src/components/Dialogs/EditMediaDialog/index.js +++ b/src/components/Dialogs/EditMediaDialog/index.js @@ -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'; @@ -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 = { @@ -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); @@ -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, @@ -89,7 +109,7 @@ export default class EditMediaDialog extends Component { if (open) { const artistInput = ( ); const artistTitleLabel = ( - +
); const titleInput = ( Play from: + ); const fromInput = ( ); const toLabel = ( - + ); const toInput = ( { + this.email = email; + }; + + refPassword = password => { + this.password = password; + }; + render() { const { error } = this.props; const { busy } = this.state; @@ -37,7 +45,7 @@ export default class LoginForm extends React.Component { {error && {error.message}} { + this.username = username; + }; + + refEmail = email => { + this.email = email; + }; + + refPassword = password => { + this.password = password; + }; + renderCaptcha() { if (!this.props.useReCaptcha) { return null; @@ -69,7 +81,7 @@ export default class RegisterForm extends React.Component { {error && {error.message}} } @@ -78,7 +90,7 @@ export default class RegisterForm extends React.Component { { 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 = () => { @@ -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, @@ -88,7 +92,7 @@ export default class PromptDialog extends React.Component { {children} { + this.button = button; + }; + render() { const { muiTheme } = this.context; const { active, count } = this.props; const CurrentIcon = active ? FavoritedIcon : FavoriteIcon; return (