From 2e112e240666b62b8c3d4fa201fb24b841f6c92b Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sun, 21 May 2017 00:31:47 +0900 Subject: Improve eslint rules (#3147) * Add semi to ESLint rules * Add padded-blocks to ESLint rules * Add comma-dangle to ESLint rules * add config/webpack and storyboard * add streaming/ * yarn test:lint -- --fix --- app/javascript/mastodon/components/account.js | 6 +++--- app/javascript/mastodon/components/attachment_list.js | 2 +- app/javascript/mastodon/components/autosuggest_textarea.js | 8 ++++---- app/javascript/mastodon/components/avatar.js | 8 ++++---- app/javascript/mastodon/components/avatar_overlay.js | 7 ++++--- app/javascript/mastodon/components/button.js | 6 +++--- app/javascript/mastodon/components/collapsable.js | 2 +- app/javascript/mastodon/components/column_back_button.js | 2 +- app/javascript/mastodon/components/column_back_button_slim.js | 3 ++- app/javascript/mastodon/components/column_collapsable.js | 5 +++-- app/javascript/mastodon/components/display_name.js | 2 +- app/javascript/mastodon/components/dropdown_menu.js | 6 +++--- app/javascript/mastodon/components/extended_video_player.js | 2 +- app/javascript/mastodon/components/icon_button.js | 8 ++++---- app/javascript/mastodon/components/load_more.js | 2 +- app/javascript/mastodon/components/media_gallery.js | 8 ++++---- app/javascript/mastodon/components/permalink.js | 4 ++-- app/javascript/mastodon/components/relative_timestamp.js | 2 +- app/javascript/mastodon/components/status.js | 4 ++-- app/javascript/mastodon/components/status_action_bar.js | 4 ++-- app/javascript/mastodon/components/status_content.js | 8 ++++---- app/javascript/mastodon/components/status_list.js | 4 ++-- app/javascript/mastodon/components/video_player.js | 8 ++++---- 23 files changed, 57 insertions(+), 54 deletions(-) (limited to 'app/javascript/mastodon/components') diff --git a/app/javascript/mastodon/components/account.js b/app/javascript/mastodon/components/account.js index 5850a8791..baac734aa 100644 --- a/app/javascript/mastodon/components/account.js +++ b/app/javascript/mastodon/components/account.js @@ -13,7 +13,7 @@ const messages = defineMessages({ unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' }, requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' }, unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' }, - unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' } + unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' }, }); class Account extends ImmutablePureComponent { @@ -24,7 +24,7 @@ class Account extends ImmutablePureComponent { onFollow: PropTypes.func.isRequired, onBlock: PropTypes.func.isRequired, onMute: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired + intl: PropTypes.object.isRequired, }; constructor (props, context) { @@ -62,7 +62,7 @@ class Account extends ImmutablePureComponent { const muting = account.getIn(['relationship', 'muting']); if (requested) { - buttons = + buttons = ; } else if (blocking) { buttons = ; } else if (muting) { diff --git a/app/javascript/mastodon/components/attachment_list.js b/app/javascript/mastodon/components/attachment_list.js index f6449e2c0..54d3643bd 100644 --- a/app/javascript/mastodon/components/attachment_list.js +++ b/app/javascript/mastodon/components/attachment_list.js @@ -6,7 +6,7 @@ const filename = url => url.split('/').pop().split('#')[0].split('?')[0]; class AttachmentList extends React.PureComponent { static propTypes = { - media: ImmutablePropTypes.list.isRequired + media: ImmutablePropTypes.list.isRequired, }; render () { diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js index 24fa2b920..0a9af5126 100644 --- a/app/javascript/mastodon/components/autosuggest_textarea.js +++ b/app/javascript/mastodon/components/autosuggest_textarea.js @@ -44,11 +44,11 @@ class AutosuggestTextarea extends ImmutablePureComponent { onKeyUp: PropTypes.func, onKeyDown: PropTypes.func, onPaste: PropTypes.func.isRequired, - autoFocus: PropTypes.bool + autoFocus: PropTypes.bool, }; static defaultProps = { - autoFocus: true + autoFocus: true, }; constructor (props, context) { @@ -57,7 +57,7 @@ class AutosuggestTextarea extends ImmutablePureComponent { suggestionsHidden: false, selectedSuggestion: 0, lastToken: null, - tokenStart: 0 + tokenStart: 0, }; this.onChange = this.onChange.bind(this); this.onKeyDown = this.onKeyDown.bind(this); @@ -164,7 +164,7 @@ class AutosuggestTextarea extends ImmutablePureComponent { onPaste (e) { if (e.clipboardData && e.clipboardData.files.length === 1) { - this.props.onPaste(e.clipboardData.files) + this.props.onPaste(e.clipboardData.files); e.preventDefault(); } } diff --git a/app/javascript/mastodon/components/avatar.js b/app/javascript/mastodon/components/avatar.js index 90c84f32a..d8e8e7dda 100644 --- a/app/javascript/mastodon/components/avatar.js +++ b/app/javascript/mastodon/components/avatar.js @@ -9,17 +9,17 @@ class Avatar extends React.PureComponent { size: PropTypes.number.isRequired, style: PropTypes.object, animate: PropTypes.bool, - inline: PropTypes.bool + inline: PropTypes.bool, }; static defaultProps = { animate: false, size: 20, - inline: false + inline: false, }; state = { - hovering: true + hovering: true, }; handleMouseEnter = () => { @@ -46,7 +46,7 @@ class Avatar extends React.PureComponent { ...this.props.style, width: `${size}px`, height: `${size}px`, - backgroundSize: `${size}px ${size}px` + backgroundSize: `${size}px ${size}px`, }; if (hovering || animate) { diff --git a/app/javascript/mastodon/components/avatar_overlay.js b/app/javascript/mastodon/components/avatar_overlay.js index b76750513..a9643499d 100644 --- a/app/javascript/mastodon/components/avatar_overlay.js +++ b/app/javascript/mastodon/components/avatar_overlay.js @@ -2,20 +2,21 @@ import React from 'react'; import PropTypes from 'prop-types'; class AvatarOverlay extends React.PureComponent { + static propTypes = { staticSrc: PropTypes.string.isRequired, - overlaySrc: PropTypes.string.isRequired + overlaySrc: PropTypes.string.isRequired, }; render() { const {staticSrc, overlaySrc} = this.props; const baseStyle = { - backgroundImage: `url(${staticSrc})` + backgroundImage: `url(${staticSrc})`, }; const overlayStyle = { - backgroundImage: `url(${overlaySrc})` + backgroundImage: `url(${overlaySrc})`, }; return ( diff --git a/app/javascript/mastodon/components/button.js b/app/javascript/mastodon/components/button.js index 7612bd233..cc6482cde 100644 --- a/app/javascript/mastodon/components/button.js +++ b/app/javascript/mastodon/components/button.js @@ -11,11 +11,11 @@ class Button extends React.PureComponent { secondary: PropTypes.bool, size: PropTypes.number, style: PropTypes.object, - children: PropTypes.node + children: PropTypes.node, }; static defaultProps = { - size: 36 + size: 36, }; handleClick = (e) => { @@ -29,7 +29,7 @@ class Button extends React.PureComponent { padding: `0 ${this.props.size / 2.25}px`, height: `${this.props.size}px`, lineHeight: `${this.props.size}px`, - ...this.props.style + ...this.props.style, }; return ( diff --git a/app/javascript/mastodon/components/collapsable.js b/app/javascript/mastodon/components/collapsable.js index ac42bc6c7..ad1453589 100644 --- a/app/javascript/mastodon/components/collapsable.js +++ b/app/javascript/mastodon/components/collapsable.js @@ -16,7 +16,7 @@ const Collapsable = ({ fullHeight, isVisible, children }) => ( Collapsable.propTypes = { fullHeight: PropTypes.number.isRequired, isVisible: PropTypes.bool.isRequired, - children: PropTypes.node.isRequired + children: PropTypes.node.isRequired, }; export default Collapsable; diff --git a/app/javascript/mastodon/components/column_back_button.js b/app/javascript/mastodon/components/column_back_button.js index a4971f5f8..9d2de40f5 100644 --- a/app/javascript/mastodon/components/column_back_button.js +++ b/app/javascript/mastodon/components/column_back_button.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; class ColumnBackButton extends React.PureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; handleClick = () => { diff --git a/app/javascript/mastodon/components/column_back_button_slim.js b/app/javascript/mastodon/components/column_back_button_slim.js index 6966a138d..6f6bbc0b8 100644 --- a/app/javascript/mastodon/components/column_back_button_slim.js +++ b/app/javascript/mastodon/components/column_back_button_slim.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; class ColumnBackButtonSlim extends React.PureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; handleClick = () => { @@ -22,6 +22,7 @@ class ColumnBackButtonSlim extends React.PureComponent { ); } + } export default ColumnBackButtonSlim; diff --git a/app/javascript/mastodon/components/column_collapsable.js b/app/javascript/mastodon/components/column_collapsable.js index c75f8ff36..fc4ed309c 100644 --- a/app/javascript/mastodon/components/column_collapsable.js +++ b/app/javascript/mastodon/components/column_collapsable.js @@ -8,11 +8,11 @@ class ColumnCollapsable extends React.PureComponent { title: PropTypes.string, fullHeight: PropTypes.number.isRequired, children: PropTypes.node, - onCollapse: PropTypes.func + onCollapse: PropTypes.func, }; state = { - collapsed: true + collapsed: true, }; handleToggleCollapsed = () => { @@ -41,6 +41,7 @@ class ColumnCollapsable extends React.PureComponent { ); } + } export default ColumnCollapsable; diff --git a/app/javascript/mastodon/components/display_name.js b/app/javascript/mastodon/components/display_name.js index e122debf4..6fbc1dfc0 100644 --- a/app/javascript/mastodon/components/display_name.js +++ b/app/javascript/mastodon/components/display_name.js @@ -6,7 +6,7 @@ import emojify from '../emoji'; class DisplayName extends React.PureComponent { static propTypes = { - account: ImmutablePropTypes.map.isRequired + account: ImmutablePropTypes.map.isRequired, }; render () { diff --git a/app/javascript/mastodon/components/dropdown_menu.js b/app/javascript/mastodon/components/dropdown_menu.js index 8dee211fa..ea8606626 100644 --- a/app/javascript/mastodon/components/dropdown_menu.js +++ b/app/javascript/mastodon/components/dropdown_menu.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; class DropdownMenu extends React.PureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; static propTypes = { @@ -13,11 +13,11 @@ class DropdownMenu extends React.PureComponent { items: PropTypes.array.isRequired, size: PropTypes.number.isRequired, direction: PropTypes.string, - ariaLabel: PropTypes.string + ariaLabel: PropTypes.string, }; static defaultProps = { - ariaLabel: "Menu" + ariaLabel: "Menu", }; state = { diff --git a/app/javascript/mastodon/components/extended_video_player.js b/app/javascript/mastodon/components/extended_video_player.js index a07d27186..4d92bd779 100644 --- a/app/javascript/mastodon/components/extended_video_player.js +++ b/app/javascript/mastodon/components/extended_video_player.js @@ -7,7 +7,7 @@ class ExtendedVideoPlayer extends React.PureComponent { src: PropTypes.string.isRequired, time: PropTypes.number, controls: PropTypes.bool.isRequired, - muted: PropTypes.bool.isRequired + muted: PropTypes.bool.isRequired, }; handleLoadedData = () => { diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js index 3ae22faef..c8df589b6 100644 --- a/app/javascript/mastodon/components/icon_button.js +++ b/app/javascript/mastodon/components/icon_button.js @@ -17,7 +17,7 @@ class IconButton extends React.PureComponent { disabled: PropTypes.bool, inverted: PropTypes.bool, animate: PropTypes.bool, - overlay: PropTypes.bool + overlay: PropTypes.bool, }; static defaultProps = { @@ -25,7 +25,7 @@ class IconButton extends React.PureComponent { active: false, disabled: false, animate: false, - overlay: false + overlay: false, }; handleClick = (e) => { @@ -43,7 +43,7 @@ class IconButton extends React.PureComponent { height: `${this.props.size * 1.28571429}px`, lineHeight: `${this.props.size}px`, ...this.props.style, - ...(this.props.active ? this.props.activeStyle : {}) + ...(this.props.active ? this.props.activeStyle : {}), }; const classes = ['icon-button']; @@ -65,7 +65,7 @@ class IconButton extends React.PureComponent { } if (this.props.className) { - classes.push(this.props.className) + classes.push(this.props.className); } return ( diff --git a/app/javascript/mastodon/components/load_more.js b/app/javascript/mastodon/components/load_more.js index 36dae79af..212011386 100644 --- a/app/javascript/mastodon/components/load_more.js +++ b/app/javascript/mastodon/components/load_more.js @@ -9,7 +9,7 @@ const LoadMore = ({ onClick }) => ( ); LoadMore.propTypes = { - onClick: PropTypes.func + onClick: PropTypes.func, }; export default LoadMore; diff --git a/app/javascript/mastodon/components/media_gallery.js b/app/javascript/mastodon/components/media_gallery.js index 10389751e..baa7f9afa 100644 --- a/app/javascript/mastodon/components/media_gallery.js +++ b/app/javascript/mastodon/components/media_gallery.js @@ -6,7 +6,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { isIOS } from '../is_mobile'; const messages = defineMessages({ - toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' } + toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' }, }); class Item extends React.PureComponent { @@ -16,7 +16,7 @@ class Item extends React.PureComponent { index: PropTypes.number.isRequired, size: PropTypes.number.isRequired, onClick: PropTypes.func.isRequired, - autoPlayGif: PropTypes.bool.isRequired + autoPlayGif: PropTypes.bool.isRequired, }; handleClick = (e) => { @@ -131,11 +131,11 @@ class MediaGallery extends React.PureComponent { height: PropTypes.number.isRequired, onOpenMedia: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, - autoPlayGif: PropTypes.bool.isRequired + autoPlayGif: PropTypes.bool.isRequired, }; state = { - visible: !this.props.sensitive + visible: !this.props.sensitive, }; handleOpen = (e) => { diff --git a/app/javascript/mastodon/components/permalink.js b/app/javascript/mastodon/components/permalink.js index 08f187728..b45969d85 100644 --- a/app/javascript/mastodon/components/permalink.js +++ b/app/javascript/mastodon/components/permalink.js @@ -4,14 +4,14 @@ import PropTypes from 'prop-types'; class Permalink extends React.PureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; static propTypes = { className: PropTypes.string, href: PropTypes.string.isRequired, to: PropTypes.string.isRequired, - children: PropTypes.node + children: PropTypes.node, }; handleClick = (e) => { diff --git a/app/javascript/mastodon/components/relative_timestamp.js b/app/javascript/mastodon/components/relative_timestamp.js index 9c7a8121e..13c36c0e4 100644 --- a/app/javascript/mastodon/components/relative_timestamp.js +++ b/app/javascript/mastodon/components/relative_timestamp.js @@ -14,7 +14,7 @@ const RelativeTimestamp = ({ intl, timestamp }) => { RelativeTimestamp.propTypes = { intl: PropTypes.object.isRequired, - timestamp: PropTypes.string.isRequired + timestamp: PropTypes.string.isRequired, }; export default injectIntl(RelativeTimestamp); diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 9ce43833f..ec83a5331 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -18,7 +18,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; class Status extends ImmutablePureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; static propTypes = { @@ -35,7 +35,7 @@ class Status extends ImmutablePureComponent { me: PropTypes.number, boostModal: PropTypes.bool, autoPlayGif: PropTypes.bool, - muted: PropTypes.bool + muted: PropTypes.bool, }; handleClick = () => { diff --git a/app/javascript/mastodon/components/status_action_bar.js b/app/javascript/mastodon/components/status_action_bar.js index 4d077fb98..1f9fa4c67 100644 --- a/app/javascript/mastodon/components/status_action_bar.js +++ b/app/javascript/mastodon/components/status_action_bar.js @@ -24,7 +24,7 @@ const messages = defineMessages({ class StatusActionBar extends React.PureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; static propTypes = { @@ -40,7 +40,7 @@ class StatusActionBar extends React.PureComponent { onMuteConversation: PropTypes.func, me: PropTypes.number.isRequired, withDismiss: PropTypes.bool, - intl: PropTypes.object.isRequired + intl: PropTypes.object.isRequired, }; handleReplyClick = () => { diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 4d002607d..1a474802a 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -10,16 +10,16 @@ import Permalink from './permalink'; class StatusContent extends React.PureComponent { static contextTypes = { - router: PropTypes.object + router: PropTypes.object, }; static propTypes = { status: ImmutablePropTypes.map.isRequired, - onClick: PropTypes.func + onClick: PropTypes.func, }; state = { - hidden: true + hidden: true, }; componentDidMount () { @@ -107,7 +107,7 @@ class StatusContent extends React.PureComponent { @{item.get('username')} - )).reduce((aggregate, item) => [...aggregate, item, ' '], []) + )).reduce((aggregate, item) => [...aggregate, item, ' '], []); const toggleText = hidden ? : ; diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js index 9e6c8fd18..b669a5564 100644 --- a/app/javascript/mastodon/components/status_list.js +++ b/app/javascript/mastodon/components/status_list.js @@ -20,11 +20,11 @@ class StatusList extends ImmutablePureComponent { isUnread: PropTypes.bool, hasMore: PropTypes.bool, prepend: PropTypes.node, - emptyMessage: PropTypes.node + emptyMessage: PropTypes.node, }; static defaultProps = { - trackScroll: true + trackScroll: true, }; handleScroll = (e) => { diff --git a/app/javascript/mastodon/components/video_player.js b/app/javascript/mastodon/components/video_player.js index cd4b69659..29da769e0 100644 --- a/app/javascript/mastodon/components/video_player.js +++ b/app/javascript/mastodon/components/video_player.js @@ -20,12 +20,12 @@ class VideoPlayer extends React.PureComponent { sensitive: PropTypes.bool, intl: PropTypes.object.isRequired, autoplay: PropTypes.bool, - onOpenVideo: PropTypes.func.isRequired + onOpenVideo: PropTypes.func.isRequired, }; static defaultProps = { width: 239, - height: 110 + height: 110, }; state = { @@ -33,7 +33,7 @@ class VideoPlayer extends React.PureComponent { preview: true, muted: true, hasAudio: true, - videoError: false + videoError: false, }; handleClick = () => { @@ -59,7 +59,7 @@ class VideoPlayer extends React.PureComponent { handleVisibility = () => { this.setState({ visible: !this.state.visible, - preview: true + preview: true, }); } -- cgit