mirror of
https://github.com/wassname/talk.git
synced 2026-07-09 14:17:02 +08:00
Enable Linting
This commit is contained in:
@@ -3,5 +3,10 @@ client/lib
|
||||
**/*.html
|
||||
plugins/*
|
||||
!plugins/coral-plugin-facebook-auth
|
||||
!plugins/coral-plugin-auth
|
||||
!plugins/coral-plugin-respect
|
||||
!plugins/coral-plugin-offtopic
|
||||
!plugins/coral-plugin-like
|
||||
!plugins/coral-plugin-mod
|
||||
!plugins/coral-plugin-love
|
||||
node_modules
|
||||
|
||||
@@ -40,10 +40,10 @@ class ChangeUsernameContainer extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleChange = e => {
|
||||
handleChange = (e) => {
|
||||
const {name, value} = e.target;
|
||||
this.setState(
|
||||
state => ({
|
||||
(state) => ({
|
||||
...state,
|
||||
formData: {
|
||||
...state.formData,
|
||||
@@ -57,7 +57,7 @@ class ChangeUsernameContainer extends React.Component {
|
||||
};
|
||||
|
||||
addError = (name, error) => {
|
||||
return this.setState(state => ({
|
||||
return this.setState((state) => ({
|
||||
errors: {
|
||||
...state.errors,
|
||||
[name]: error
|
||||
@@ -75,20 +75,20 @@ class ChangeUsernameContainer extends React.Component {
|
||||
} else {
|
||||
const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line
|
||||
// Removes Error
|
||||
this.setState(state => ({...state, errors}));
|
||||
this.setState((state) => ({...state, errors}));
|
||||
}
|
||||
};
|
||||
|
||||
isCompleted = () => {
|
||||
const {formData} = this.state;
|
||||
return !Object.keys(formData).filter(prop => !formData[prop].length).length;
|
||||
return !Object.keys(formData).filter((prop) => !formData[prop].length).length;
|
||||
};
|
||||
|
||||
displayErrors = (show = true) => {
|
||||
this.setState({showErrors: show});
|
||||
};
|
||||
|
||||
handleSubmitUsername = e => {
|
||||
handleSubmitUsername = (e) => {
|
||||
e.preventDefault();
|
||||
const {errors} = this.state;
|
||||
const {validForm, invalidForm} = this.props;
|
||||
@@ -127,7 +127,7 @@ const mapStateToProps = ({auth}) => ({
|
||||
auth: auth.toJS()
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators(
|
||||
{
|
||||
createUsername,
|
||||
|
||||
@@ -69,4 +69,5 @@ export const FakeComment = ({username, created_at, body}) => (
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
const lang = new I18n(translations);
|
||||
|
||||
class ForgotContent extends React.Component {
|
||||
handleSubmit = e => {
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.fetchForgotPassword(this.emailInput.value);
|
||||
};
|
||||
@@ -25,7 +25,7 @@ class ForgotContent extends React.Component {
|
||||
<div className={styles.textField}>
|
||||
<label htmlFor="email">{lang.t('signIn.email')}</label>
|
||||
<input
|
||||
ref={input => (this.emailInput = input)}
|
||||
ref={(input) => (this.emailInput = input)}
|
||||
type="text"
|
||||
style={{fontSize: 16}}
|
||||
id="email"
|
||||
|
||||
@@ -18,7 +18,7 @@ const mapStateToProps = ({auth}) => ({
|
||||
loggedIn: auth.toJS().loggedIn
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({showSignInDialog}, dispatch);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(SignInButton);
|
||||
|
||||
@@ -61,7 +61,8 @@ class SignInContainer extends React.Component {
|
||||
window.removeEventListener('storage', this.handleAuth);
|
||||
}
|
||||
|
||||
handleAuth = e => {
|
||||
handleAuth = (e) => {
|
||||
|
||||
// Listening to FB changes
|
||||
// FB localStorage key is 'auth'
|
||||
const authCallback = this.props.facebookCallback;
|
||||
@@ -72,10 +73,10 @@ class SignInContainer extends React.Component {
|
||||
}
|
||||
};
|
||||
|
||||
handleChange = e => {
|
||||
handleChange = (e) => {
|
||||
const {name, value} = e.target;
|
||||
this.setState(
|
||||
state => ({
|
||||
(state) => ({
|
||||
...state,
|
||||
formData: {
|
||||
...state.formData,
|
||||
@@ -88,12 +89,12 @@ class SignInContainer extends React.Component {
|
||||
);
|
||||
};
|
||||
|
||||
handleChangeEmail = e => {
|
||||
handleChangeEmail = (e) => {
|
||||
const {value} = e.target;
|
||||
this.setState({emailToBeResent: value});
|
||||
};
|
||||
|
||||
handleResendVerification = e => {
|
||||
handleResendVerification = (e) => {
|
||||
e.preventDefault();
|
||||
this.props
|
||||
.requestConfirmEmail(
|
||||
@@ -102,6 +103,7 @@ class SignInContainer extends React.Component {
|
||||
)
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
|
||||
// allow success UI to be shown for a second, and then close the modal
|
||||
this.props.hideSignInDialog();
|
||||
}, 2500);
|
||||
@@ -109,7 +111,7 @@ class SignInContainer extends React.Component {
|
||||
};
|
||||
|
||||
addError = (name, error) => {
|
||||
return this.setState(state => ({
|
||||
return this.setState((state) => ({
|
||||
errors: {
|
||||
...state.errors,
|
||||
[name]: error
|
||||
@@ -133,20 +135,20 @@ class SignInContainer extends React.Component {
|
||||
} else {
|
||||
const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line
|
||||
// Removes Error
|
||||
this.setState(state => ({...state, errors}));
|
||||
this.setState((state) => ({...state, errors}));
|
||||
}
|
||||
};
|
||||
|
||||
isCompleted = () => {
|
||||
const {formData} = this.state;
|
||||
return !Object.keys(formData).filter(prop => !formData[prop].length).length;
|
||||
return !Object.keys(formData).filter((prop) => !formData[prop].length).length;
|
||||
};
|
||||
|
||||
displayErrors = (show = true) => {
|
||||
this.setState({showErrors: show});
|
||||
};
|
||||
|
||||
handleSignUp = e => {
|
||||
handleSignUp = (e) => {
|
||||
e.preventDefault();
|
||||
const {errors} = this.state;
|
||||
const {fetchSignUp, validForm, invalidForm} = this.props;
|
||||
@@ -159,7 +161,7 @@ class SignInContainer extends React.Component {
|
||||
}
|
||||
};
|
||||
|
||||
handleSignIn = e => {
|
||||
handleSignIn = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.fetchSignIn(this.state.formData);
|
||||
};
|
||||
@@ -183,17 +185,16 @@ class SignInContainer extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
const mapStateToProps = (state) => ({
|
||||
auth: state.auth.toJS()
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators(
|
||||
{
|
||||
checkLogin,
|
||||
facebookCallback,
|
||||
fetchSignUp,
|
||||
fetchSignUp,
|
||||
fetchSignIn,
|
||||
fetchSignInFacebook,
|
||||
fetchSignUpFacebook,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import styles from './styles.css';
|
||||
import React, {PropTypes} from 'react';
|
||||
import React from 'react';
|
||||
import translations from '../translations';
|
||||
import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import {Button, TextField, Spinner, Success, Alert} from 'coral-ui';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import translations from '../translations';
|
||||
import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import {showSignInDialog, logout} from 'coral-framework/actions/auth';
|
||||
import {logout} from 'coral-framework/actions/auth';
|
||||
const lang = new I18n(translations);
|
||||
|
||||
const UserBox = ({loggedIn, user, logout, onShowProfile}) => (
|
||||
@@ -23,12 +23,12 @@ const UserBox = ({loggedIn, user, logout, onShowProfile}) => (
|
||||
</div>
|
||||
);
|
||||
|
||||
const mapStateToProps = ({auth, user}) => ({
|
||||
const mapStateToProps = ({auth}) => ({
|
||||
loggedIn: auth.toJS().loggedIn,
|
||||
user: auth.toJS().user
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({logout}, dispatch);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(UserBox);
|
||||
|
||||
@@ -8,4 +8,5 @@ export default {
|
||||
stream: [UserBox, SignInButton, ChangeUserNameContainer],
|
||||
login: [SignInContainer]
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
module.exports = {};
|
||||
module.exports = {};
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import React, { Component } from 'react';
|
||||
import React, {Component} from 'react';
|
||||
import styles from './style.css';
|
||||
import Icon from './Icon';
|
||||
|
||||
import { I18n } from 'coral-framework';
|
||||
import {I18n} from 'coral-framework';
|
||||
import cn from 'classnames';
|
||||
import translations from '../translations.json';
|
||||
import { getMyActionSummary, getTotalActionCount } from 'coral-framework/utils';
|
||||
import {getMyActionSummary, getTotalActionCount} from 'coral-framework/utils';
|
||||
|
||||
const lang = new I18n(translations);
|
||||
const name = 'coral-plugin-like';
|
||||
|
||||
class LikeButton extends Component {
|
||||
handleClick = () => {
|
||||
const { postLike, showSignInDialog, deleteAction } = this.props;
|
||||
const { root: { me }, comment } = this.props;
|
||||
const {postLike, showSignInDialog, deleteAction} = this.props;
|
||||
const {root: {me}, comment} = this.props;
|
||||
|
||||
const myLikeActionSummary = getMyActionSummary(
|
||||
'LikeActionSummary',
|
||||
@@ -42,7 +41,7 @@ class LikeButton extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { comment } = this.props;
|
||||
const {comment} = this.props;
|
||||
|
||||
if (!comment) {
|
||||
return null;
|
||||
@@ -56,7 +55,7 @@ class LikeButton extends Component {
|
||||
<button
|
||||
className={cn(
|
||||
styles.button,
|
||||
{ [styles.liked]: myLike },
|
||||
{[styles.liked]: myLike},
|
||||
`${name}-button`
|
||||
)}
|
||||
onClick={this.handleClick}
|
||||
@@ -68,7 +67,7 @@ class LikeButton extends Component {
|
||||
className={cn(
|
||||
styles.icon,
|
||||
'material-icons',
|
||||
{ [styles.liked]: myLike },
|
||||
{[styles.liked]: myLike},
|
||||
`${name}-icon`
|
||||
)}
|
||||
aria-hidden={true}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import get from 'lodash/get';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { compose, gql, graphql } from 'react-apollo';
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {compose, gql, graphql} from 'react-apollo';
|
||||
import LikeButton from '../components/LikeButton';
|
||||
import withFragments from 'coral-framework/hocs/withFragments';
|
||||
import { showSignInDialog } from 'coral-framework/actions/auth';
|
||||
import{showSignInDialog} from 'coral-framework/actions/auth';
|
||||
|
||||
const isLikeAction = a => a.__typename === 'LikeActionSummary';
|
||||
const isLikeAction = (a) => a.__typename === 'LikeActionSummary';
|
||||
|
||||
const COMMENT_FRAGMENT = gql`
|
||||
fragment LikeButton_updateFragment on Comment {
|
||||
@@ -32,17 +32,17 @@ const withDeleteAction = graphql(
|
||||
}
|
||||
`,
|
||||
{
|
||||
props: ({ mutate }) => ({
|
||||
props: ({mutate}) => ({
|
||||
deleteAction: (id, commentId) => {
|
||||
return mutate({
|
||||
variables: { id },
|
||||
variables: {id},
|
||||
optimisticResponse: {
|
||||
deleteAction: {
|
||||
__typename: 'DeleteActionResponse',
|
||||
errors: null
|
||||
}
|
||||
},
|
||||
update: proxy => {
|
||||
update: (proxy) => {
|
||||
const fragmentId = `Comment_${commentId}`;
|
||||
|
||||
// Read the data from our cache for this query.
|
||||
@@ -93,10 +93,10 @@ const withPostLike = graphql(
|
||||
}
|
||||
`,
|
||||
{
|
||||
props: ({ mutate }) => ({
|
||||
postLike: like => {
|
||||
props: ({mutate}) => ({
|
||||
postLike: (like) => {
|
||||
return mutate({
|
||||
variables: { like },
|
||||
variables: {like},
|
||||
optimisticResponse: {
|
||||
createLike: {
|
||||
__typename: 'CreateLikeResponse',
|
||||
@@ -125,6 +125,7 @@ const withPostLike = graphql(
|
||||
}
|
||||
|
||||
if (idx < 0) {
|
||||
|
||||
// Add initial action when it doesn't exist.
|
||||
data.action_summaries.push({
|
||||
__typename: 'LikeActionSummary',
|
||||
@@ -153,8 +154,8 @@ const withPostLike = graphql(
|
||||
}
|
||||
);
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ showSignInDialog }, dispatch);
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({showSignInDialog}, dispatch);
|
||||
|
||||
const enhance = compose(
|
||||
withFragments({
|
||||
|
||||
@@ -14,7 +14,7 @@ class LoveButton extends React.Component {
|
||||
showSignInDialog,
|
||||
alreadyReacted
|
||||
} = this.props;
|
||||
const {root: {me}, comment} = this.props;
|
||||
const {root: {me}} = this.props;
|
||||
|
||||
// If the current user does not exist, trigger sign in dialog.
|
||||
if (!me) {
|
||||
|
||||
@@ -16,8 +16,8 @@ module.exports = {
|
||||
__resolveType: {
|
||||
post({action_type}) {
|
||||
switch (action_type) {
|
||||
case 'LOVE':
|
||||
return 'LoveAction';
|
||||
case 'LOVE':
|
||||
return 'LoveAction';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@ module.exports = {
|
||||
__resolveType: {
|
||||
post({action_type}) {
|
||||
switch (action_type) {
|
||||
case 'LOVE':
|
||||
return 'LoveActionSummary';
|
||||
case 'LOVE':
|
||||
return 'LoveActionSummary';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React from 'react';
|
||||
import styles from './styles.css'
|
||||
import styles from './styles.css';
|
||||
|
||||
export default (props) => (
|
||||
<div className={styles.box}>
|
||||
Comment Status: {props.comment.status}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import Box from './Box';
|
||||
import {Button} from 'coral-ui'
|
||||
import {Button} from 'coral-ui';
|
||||
import styles from './styles.css';
|
||||
|
||||
export default class Footer extends React.Component {
|
||||
@@ -13,9 +13,9 @@ export default class Footer extends React.Component {
|
||||
}
|
||||
|
||||
handleClick = () => {
|
||||
this.setState(state => ({
|
||||
this.setState((state) => ({
|
||||
show: !state.show
|
||||
}))
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
const {readFileSync} = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class OffTopicCheckbox extends React.Component {
|
||||
|
||||
handleChange = (e) => {
|
||||
if (e.target.checked) {
|
||||
this.props.addTag(this.label)
|
||||
this.props.addTag(this.label);
|
||||
} else {
|
||||
const idx = this.props.commentBox.tags.indexOf(this.label);
|
||||
this.props.removeTag(idx);
|
||||
@@ -25,14 +25,13 @@ class OffTopicCheckbox extends React.Component {
|
||||
Off-Topic
|
||||
</label>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const mapStateToProps = ({commentBox}) => ({commentBox});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({addTag, removeTag}, dispatch);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(OffTopicCheckbox);
|
||||
|
||||
@@ -2,8 +2,8 @@ import React from 'react';
|
||||
import styles from './styles.css';
|
||||
|
||||
const isOffTopic = (tags) => {
|
||||
return !!tags.filter(tag => tag.name === 'OFF_TOPIC').length
|
||||
}
|
||||
return !!tags.filter((tag) => tag.name === 'OFF_TOPIC').length;
|
||||
};
|
||||
|
||||
export default (props) => (
|
||||
<span>
|
||||
|
||||
Reference in New Issue
Block a user