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
This commit is contained in:
Yamagishi Kazutoshi
2017-05-21 00:31:47 +09:00
committed by Eugen Rochko
parent 812fe90eca
commit 2e112e2406
170 changed files with 919 additions and 904 deletions

View File

@ -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 = <IconButton disabled={true} icon='hourglass' title={intl.formatMessage(messages.requested)} />
buttons = <IconButton disabled={true} icon='hourglass' title={intl.formatMessage(messages.requested)} />;
} else if (blocking) {
buttons = <IconButton active={true} icon='unlock-alt' title={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.handleBlock} />;
} else if (muting) {

View File

@ -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 () {

View File

@ -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();
}
}

View File

@ -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) {

View File

@ -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 (

View File

@ -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 (

View File

@ -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;

View File

@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
class ColumnBackButton extends React.PureComponent {
static contextTypes = {
router: PropTypes.object
router: PropTypes.object,
};
handleClick = () => {

View File

@ -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 {
</div>
);
}
}
export default ColumnBackButtonSlim;

View File

@ -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 {
</div>
);
}
}
export default ColumnCollapsable;

View File

@ -6,7 +6,7 @@ import emojify from '../emoji';
class DisplayName extends React.PureComponent {
static propTypes = {
account: ImmutablePropTypes.map.isRequired
account: ImmutablePropTypes.map.isRequired,
};
render () {

View File

@ -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 = {

View File

@ -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 = () => {

View File

@ -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 (

View File

@ -9,7 +9,7 @@ const LoadMore = ({ onClick }) => (
);
LoadMore.propTypes = {
onClick: PropTypes.func
onClick: PropTypes.func,
};
export default LoadMore;

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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);

View File

@ -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 = () => {

View File

@ -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 = () => {

View File

@ -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 {
<Permalink to={`/accounts/${item.get('id')}`} href={item.get('url')} key={item.get('id')} className='mention'>
@<span>{item.get('username')}</span>
</Permalink>
)).reduce((aggregate, item) => [...aggregate, item, ' '], [])
)).reduce((aggregate, item) => [...aggregate, item, ' '], []);
const toggleText = hidden ? <FormattedMessage id='status.show_more' defaultMessage='Show more' /> : <FormattedMessage id='status.show_less' defaultMessage='Show less' />;

View File

@ -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) => {

View File

@ -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,
});
}