Resolve linter issues

This commit is contained in:
Chi Vinh Le
2018-06-05 04:28:54 +02:00
parent d9a1d739dc
commit ccff6ed63b
148 changed files with 1171 additions and 265 deletions
@@ -5,4 +5,7 @@ import CheckSpamHook from '../components/CheckSpamHook';
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
export default connect(null, mapDispatchToProps)(CheckSpamHook);
export default connect(
null,
mapDispatchToProps
)(CheckSpamHook);
@@ -58,6 +58,9 @@ const mapDispatchToProps = dispatch =>
);
export default compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withForgotPassword
)(ForgotPasswordContainer);
@@ -50,4 +50,7 @@ const mapDispatchToProps = dispatch =>
dispatch
);
export default connect(mapStateToProps, mapDispatchToProps)(MainContainer);
export default connect(
mapStateToProps,
mapDispatchToProps
)(MainContainer);
@@ -59,6 +59,9 @@ const mapDispatchToProps = dispatch =>
);
export default compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withResendEmailConfirmation
)(ResendEmailConfirmatonContainer);
@@ -89,6 +89,9 @@ const mapDispatchToProps = dispatch =>
);
export default compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withSignIn
)(SignInContainer);
@@ -145,6 +145,9 @@ const mapDispatchToProps = dispatch =>
);
export default compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withSignUp
)(SignUpContainer);
@@ -58,7 +58,10 @@ const mapStateToProps = state => ({
});
export default compose(
connect(mapStateToProps, null),
connect(
mapStateToProps,
null
),
withSetUsername,
branch(props => !props.username, renderNothing)
)(SetUsernameDialogContainer);
@@ -11,4 +11,7 @@ const mapStateToProps = state => ({
const mapDispatchToProps = dispatch =>
bindActionCreators({ showSignInDialog }, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(SignInButton);
export default connect(
mapStateToProps,
mapDispatchToProps
)(SignInButton);
@@ -10,4 +10,7 @@ const mapStateToProps = state => ({
const mapDispatchToProps = dispatch => bindActionCreators({ logout }, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(UserBox);
export default connect(
mapStateToProps,
mapDispatchToProps
)(UserBox);
@@ -122,7 +122,10 @@ const withAuthorNameFragments = withFragments({
});
const enhance = compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withAuthorNameFragments
);
@@ -85,7 +85,13 @@ module.exports = {
}),
resolvers: {
Comment: {
deepReplyCount({ id }, args, { loaders: { Comments } }) {
deepReplyCount(
{ id },
args,
{
loaders: { Comments },
}
) {
return Comments.getDeepCount.load(id);
},
},
@@ -6,4 +6,7 @@ import FacebookButton from '../components/FacebookButton';
const mapDispatchToProps = dispatch =>
bindActionCreators({ onClick: loginWithFacebook }, dispatch);
export default connect(null, mapDispatchToProps)(FacebookButton);
export default connect(
null,
mapDispatchToProps
)(FacebookButton);
@@ -5,7 +5,11 @@ module.exports = router => {
*/
router.get('/api/v1/auth/facebook', (req, res, next) => {
const {
connectors: { services: { Passport: { passport } } },
connectors: {
services: {
Passport: { passport },
},
},
} = req.context;
return passport.authenticate('facebook', {
@@ -22,7 +26,9 @@ module.exports = router => {
router.get('/api/v1/auth/facebook/callback', (req, res, next) => {
const {
connectors: {
services: { Passport: { passport, HandleAuthPopupCallback } },
services: {
Passport: { passport, HandleAuthPopupCallback },
},
},
} = req.context;
@@ -19,7 +19,10 @@ const mapDispatchToProps = dispatch =>
);
const enhance = compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withTags('featured')
);
@@ -13,7 +13,10 @@ const mapDispatchToProps = dispatch =>
);
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withTags('featured')
);
@@ -12,7 +12,13 @@ class ModIndicatorSubscription extends React.Component {
document: COMMENT_FEATURED_SUBSCRIPTION,
updateQuery: (
prev,
{ subscriptionData: { data: { commentFeatured: { comment } } } }
{
subscriptionData: {
data: {
commentFeatured: { comment },
},
},
}
) => {
return this.props.handleCommentChange(prev, comment);
},
@@ -21,7 +27,13 @@ class ModIndicatorSubscription extends React.Component {
document: COMMENT_UNFEATURED_SUBSCRIPTION,
updateQuery: (
prev,
{ subscriptionData: { data: { commentUnfeatured: { comment } } } }
{
subscriptionData: {
data: {
commentUnfeatured: { comment },
},
},
}
) => {
return this.props.handleCommentChange(prev, comment);
},
@@ -28,7 +28,13 @@ class ModSubscription extends React.Component {
},
updateQuery: (
prev,
{ subscriptionData: { data: { commentFeatured: { user, comment } } } }
{
subscriptionData: {
data: {
commentFeatured: { user, comment },
},
},
}
) => {
const notifyText =
this.props.user.id === user.id
@@ -50,7 +56,9 @@ class ModSubscription extends React.Component {
prev,
{
subscriptionData: {
data: { commentUnfeatured: { user, comment } },
data: {
commentUnfeatured: { user, comment },
},
},
}
) => {
@@ -117,7 +125,10 @@ const mapStateToProps = state => ({
});
export default compose(
connect(mapStateToProps, null),
connect(
mapStateToProps,
null
),
withVariables,
withSubscribeToMore
)(ModSubscription);
@@ -22,7 +22,10 @@ const fragments = {
`,
};
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withTags('featured', { fragments })
);
@@ -90,7 +90,10 @@ const mapDispatchToProps = dispatch =>
);
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withFetchMore,
withVariables,
withFragments({
+16 -4
View File
@@ -59,8 +59,14 @@ module.exports = {
addTag: {
async post(
obj,
{ tag: { name, id, item_type } },
{ user, mutators: { Comment }, pubsub }
{
tag: { name, id, item_type },
},
{
user,
mutators: { Comment },
pubsub,
}
) {
if (name === 'FEATURED' && item_type === 'COMMENTS') {
const comment = await Comment.setStatus({
@@ -76,8 +82,14 @@ module.exports = {
removeTag: {
async post(
obj,
{ tag: { name, id, item_type } },
{ user, loaders: { Comments }, pubsub }
{
tag: { name, id, item_type },
},
{
user,
loaders: { Comments },
pubsub,
}
) {
if (name === 'FEATURED' && item_type === 'COMMENTS') {
const comment = await Comments.get.load(id);
@@ -10,7 +10,12 @@ import {
class FlagDetails extends Component {
render() {
const { comment: { actions }, more, root, comment } = this.props;
const {
comment: { actions },
more,
root,
comment,
} = this.props;
const flagActions =
actions && actions.filter(a => a.__typename === 'FlagAction');
@@ -5,7 +5,10 @@ import styles from './UserFlagDetails.css';
class UserFlagDetails extends Component {
render() {
const { comment: { actions }, viewUserDetail } = this.props;
const {
comment: { actions },
viewUserDetail,
} = this.props;
const flagActions =
actions && actions.filter(a => a.__typename === 'FlagAction');
@@ -15,7 +15,10 @@ const mapDispatchToProps = dispatch => ({
});
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withFragments({
comment: gql`
fragment CoralAdmin_UserFlagDetails_comment on Comment {
@@ -6,4 +6,7 @@ import GoogleButton from '../components/GoogleButton';
const mapDispatchToProps = dispatch =>
bindActionCreators({ onClick: loginWithGoogle }, dispatch);
export default connect(null, mapDispatchToProps)(GoogleButton);
export default connect(
null,
mapDispatchToProps
)(GoogleButton);
@@ -45,7 +45,10 @@ const withIgnoreUserActionFragments = withFragments({
});
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withIgnoreUserActionFragments,
excludeIf(({ root: { me }, comment }) => !me || me.id === comment.user.id)
);
@@ -65,7 +65,10 @@ const withIgnoreUserConfirmationFragments = withFragments({
});
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withIgnoreUserConfirmationFragments,
withIgnoreUser
);
@@ -37,6 +37,9 @@ const withIgnoredUserSectionFragments = withFragments({
`,
});
const enhance = compose(withIgnoredUserSectionFragments, withStopIgnoringUser);
const enhance = compose(
withIgnoredUserSectionFragments,
withStopIgnoringUser
);
export default enhance(IgnoredUserSectionContainer);
@@ -142,7 +142,9 @@ class AddEmailAddressDialog extends React.Component {
render() {
const { errors, formData, showErrors, step } = this.state;
const { root: { settings } } = this.props;
const {
root: { settings },
} = this.props;
return (
<Dialog className={styles.dialog} open={true}>
@@ -135,7 +135,11 @@ class ChangePassword extends React.Component {
};
onForgotPassword = async () => {
const { root: { me: { email } } } = this.props;
const {
root: {
me: { email },
},
} = this.props;
try {
await this.props.forgotPassword(email);
@@ -114,7 +114,11 @@ class Profile extends React.Component {
isSaveEnabled = () => {
const { formData } = this.state;
const { root: { me: { username, email } } } = this.props;
const {
root: {
me: { username, email },
},
} = this.props;
const formHasErrors = !!Object.keys(this.state.errors).length;
const validUsername =
formData.newUsername && formData.newUsername !== username;
@@ -166,7 +170,13 @@ class Profile extends React.Component {
render() {
const {
root: { me: { username, email, state: { status } } },
root: {
me: {
username,
email,
state: { status },
},
},
notify,
} = this.props;
const { editing, formData, showDialog } = this.state;
@@ -36,7 +36,10 @@ const withData = withFragments({
});
export default compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withAttachLocalAuth,
withData,
excludeIf(
@@ -21,7 +21,10 @@ const withData = withFragments({
});
export default compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withChangePassword,
withForgotPassword,
withData
@@ -32,7 +32,10 @@ const withData = withFragments({
});
export default compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withSetUsername,
withUpdateEmailAddress,
withData
@@ -18,7 +18,10 @@ async function updateUserEmailAddress(ctx, email, confirmPassword) {
const {
user,
loaders: { Settings },
connectors: { models: { User }, services: { Mailer, I18n, Users } },
connectors: {
models: { User },
services: { Mailer, I18n, Users },
},
} = ctx;
// Ensure that the user has a local profile associated with their account.
@@ -27,7 +30,7 @@ async function updateUserEmailAddress(ctx, email, confirmPassword) {
}
// Ensure that the password provided matches what we have on file.
if (!await user.verifyPassword(confirmPassword)) {
if (!(await user.verifyPassword(confirmPassword))) {
throw new ErrIncorrectPassword();
}
@@ -81,7 +84,13 @@ async function updateUserEmailAddress(ctx, email, confirmPassword) {
// attachUserLocalAuth will attach a new local profile to an existing user.
async function attachUserLocalAuth(ctx, email, password) {
const { user, connectors: { models: { User }, services: { Users } } } = ctx;
const {
user,
connectors: {
models: { User },
services: { Users },
},
} = ctx;
// Ensure that the current user doesn't already have a local account
// associated with them.
@@ -15,7 +15,10 @@ class BanUserActionContainer extends React.Component {
};
render() {
const { root: { me }, comment } = this.props;
const {
root: { me },
comment,
} = this.props;
return me.id !== comment.user.id ? (
<BanUserAction onBanUser={this.onBanUser} comment={this.props.comment} />
) : null;
@@ -30,6 +33,11 @@ const mapDispatchToProps = dispatch =>
dispatch
);
const enhance = compose(connect(null, mapDispatchToProps));
const enhance = compose(
connect(
null,
mapDispatchToProps
)
);
export default enhance(BanUserActionContainer);
@@ -70,7 +70,10 @@ const mapDispatchToProps = dispatch =>
);
const enhance = compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withSetCommentStatus,
withBanUser
);
@@ -68,7 +68,10 @@ const mapDispatchToProps = dispatch =>
);
const enhance = compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withFragments({
root: gql`
fragment TalkModerationActions_root on RootQuery {
@@ -73,7 +73,11 @@ const withSettingsToggle = settingsName => {
mutations: {
UpdateNotificationSettings: ({
variables: { input },
state: { auth: { user: { id } } },
state: {
auth: {
user: { id },
},
},
}) => ({
update: proxy => {
if (input[settingsName] === undefined) {
@@ -13,7 +13,11 @@ export default {
mutations: {
UpdateNotificationSettings: ({
variables: { input },
state: { auth: { user: { id } } },
state: {
auth: {
user: { id },
},
},
}) => ({
optimisticResponse: {
updateNotificationSettings: {
@@ -116,7 +116,12 @@ class NotificationManager {
try {
// Pull out some useful tools.
const {
connectors: { models: { User }, services: { I18n: { t } } },
connectors: {
models: { User },
services: {
I18n: { t },
},
},
} = ctx;
const organizationName = await getOrganizationName(ctx);
@@ -6,7 +6,10 @@ const { map, reduce } = require('lodash');
module.exports = connectors => {
const {
graph: { subscriptions: { getBroker }, Context },
graph: {
subscriptions: { getBroker },
Context,
},
services: { Mailer, Plugins },
} = connectors;
@@ -37,7 +37,11 @@ const queueNotifications = async (ctx, userID, notifications) => {
);
// Pull out some useful tools.
const { connectors: { models: { User } } } = ctx;
const {
connectors: {
models: { User },
},
} = ctx;
ctx.log.info(
{ notifications: notifications.length, userID },
@@ -67,7 +71,13 @@ const sendNotificationsBatch = async (ctx, notifications) => {
map(
notifications,
async ({ handler, notification: { userID, context } }) => {
const { connectors: { services: { I18n: { t } } } } = ctx;
const {
connectors: {
services: {
I18n: { t },
},
},
} = ctx;
const { category } = handler;
// Compose the subject for the email.
@@ -181,7 +191,9 @@ const USER_CONFIRMATION_QUERY = `
// returns undefined.
const filterVerifiedNotification = ctx => async notification => {
// Grab the user that we're supposed to be sending the notification to.
const { notification: { userID } } = notification;
const {
notification: { userID },
} = notification;
// Check their confirmed status. This should have already been hit by the
// loaders, so we shouldn't make any more database requests.
@@ -15,7 +15,12 @@ function reduceSettings(newSettings, newValue, key) {
* Update the user notification settings.
*/
async function updateNotificationSettings(ctx, settings) {
const { connectors: { models: { User } }, user } = ctx;
const {
connectors: {
models: { User },
},
user,
} = ctx;
// Generate the settings set object, and just exit if we haven't changed
// anything.
@@ -29,7 +34,9 @@ async function updateNotificationSettings(ctx, settings) {
}
module.exports = ctx => {
const { connectors: { errors: ErrNotAuthorized } } = ctx;
const {
connectors: { errors: ErrNotAuthorized },
} = ctx;
let mutators = {
User: {
@@ -16,7 +16,13 @@ module.exports = {
digestFrequency: settings => get(settings, 'digestFrequency', 'NONE'),
},
RootMutation: {
async updateNotificationSettings(obj, { input }, { mutators: { User } }) {
async updateNotificationSettings(
obj,
{ input },
{
mutators: { User },
}
) {
await User.updateNotificationSettings(input);
},
},
@@ -12,7 +12,10 @@ module.exports = router => {
*/
const verifyToken = (req, res, next) => {
const {
connectors: { secrets: { jwt }, config: { JWT_ISSUER, JWT_AUDIENCE } },
connectors: {
secrets: { jwt },
config: { JWT_ISSUER, JWT_AUDIENCE },
},
} = req.context;
const { token: tokenString = '' } = req.body;
if (!tokenString) {
@@ -50,7 +53,11 @@ module.exports = router => {
'/api/v1/account/unsubscribe-notifications',
verifyToken,
async (req, res, next) => {
const { connectors: { models: { User } } } = req.context;
const {
connectors: {
models: { User },
},
} = req.context;
const { user: userID } = req.token;
try {
@@ -1,6 +1,8 @@
const getOrganizationName = async ctx => {
// Grab some useful tools.
const { loaders: { Settings } } = ctx;
const {
loaders: { Settings },
} = ctx;
// Get the settings.
const { organizationName = null } = await Settings.select('organizationName');
@@ -16,7 +18,13 @@ const getOrganizationName = async ctx => {
* @param {Mixed} context the notification context
*/
const getNotificationBody = async (ctx, handler, context) => {
const { connectors: { services: { I18n: { t } } } } = ctx;
const {
connectors: {
services: {
I18n: { t },
},
},
} = ctx;
const { category, hydrate = () => [] } = handler;
// Get the body replacement variables for the translation key.
@@ -23,4 +23,7 @@ const mapDispatchToProps = dispatch =>
dispatch
);
export default connect(mapStateToProps, mapDispatchToProps)(OffTopicFilter);
export default connect(
mapStateToProps,
mapDispatchToProps
)(OffTopicFilter);
@@ -20,7 +20,9 @@ class AccountDeletionRequestedSign extends React.Component {
};
render() {
const { me: { scheduledDeletionDate } } = this.props.root;
const {
me: { scheduledDeletionDate },
} = this.props.root;
const deletionScheduledFor = moment(scheduledDeletionDate).format(
'MMM Do YYYY, h:mm a'
@@ -36,7 +36,11 @@ class DownloadCommentHistory extends Component {
};
render() {
const { root: { me: { lastAccountDownload } } } = this.props;
const {
root: {
me: { lastAccountDownload },
},
} = this.props;
const now = new Date();
const lastAccountDownloadDate =
@@ -18,7 +18,10 @@ const withData = withFragments({
});
export default compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withCancelAccountDeletion,
withData,
excludeIf(({ root: { me } }) => !me || !me.scheduledDeletionDate)
@@ -21,7 +21,10 @@ const withData = withFragments({
});
export default compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withRequestAccountDeletion,
withCancelAccountDeletion,
withData
@@ -28,7 +28,10 @@ class DownloadCommentHistoryContainer extends Component {
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
const enhance = compose(
connect(null, mapDispatchToProps),
connect(
null,
mapDispatchToProps
),
withFragments({
root: gql`
fragment TalkDownloadCommentHistory_DownloadCommentHistorySection_root on RootQuery {
@@ -32,7 +32,9 @@ module.exports = connectors => {
try {
// Grab some settings.
const { loaders: { Settings } } = ctx;
const {
loaders: { Settings },
} = ctx;
const {
organizationName,
organizationContactEmail,
@@ -16,7 +16,12 @@ const {
// generateDownloadLinks will generate a signed set of links for a given user to
// download an archive of their data.
async function generateDownloadLinks(ctx, userID) {
const { connectors: { url: { BASE_URL }, secrets } } = ctx;
const {
connectors: {
url: { BASE_URL },
secrets,
},
} = ctx;
// Generate a token for the download link.
const token = await secrets.jwt.sign(
@@ -42,7 +47,10 @@ async function sendDownloadLink(ctx) {
const {
user,
loaders: { Settings },
connectors: { services: { Users, I18n, Limit }, models: { User } },
connectors: {
services: { Users, I18n, Limit },
models: { User },
},
} = ctx;
// downloadLinkLimiter can be used to limit downloads for the user's data to
@@ -107,7 +115,10 @@ async function sendDownloadLink(ctx) {
async function requestDeletion({
user,
loaders: { Settings },
connectors: { models: { User }, services: { Users, I18n } },
connectors: {
models: { User },
services: { Users, I18n },
},
}) {
// Ensure the user doesn't already have a deletion scheduled.
if (get(user, 'metadata.scheduledDeletionDate')) {
@@ -153,7 +164,10 @@ async function requestDeletion({
async function cancelDeletion({
user,
loaders: { Settings },
connectors: { models: { User }, services: { I18n, Users } },
connectors: {
models: { User },
services: { I18n, Users },
},
}) {
// Ensure the user has a deletion scheduled.
const scheduledDeletionDate = get(
@@ -8,7 +8,11 @@ const stringify = require('csv-stringify');
const { ErrDownloadToken } = require('./errors');
async function verifyDownloadToken(
{ connectors: { services: { Users } } },
{
connectors: {
services: { Users },
},
},
token
) {
const jwt = await Users.verifyToken(token, {
@@ -139,7 +143,12 @@ module.exports = router => {
return;
}
const { connectors: { graph: { Context }, errors } } = req.context;
const {
connectors: {
graph: { Context },
errors,
},
} = req.context;
try {
// Pull the userID and the date that the token was issued out of the
@@ -12,7 +12,9 @@ module.exports = {
createComment: {
async post(root, args, context, info, result) {
debug(`Posting notification to Slack webhook: ${SLACK_WEBHOOK_URL}`);
const { comment: { body: text, created_at: createdAt } } = result;
const {
comment: { body: text, created_at: createdAt },
} = result;
const username = context.user.username;
process.nextTick(async () => {
const response = await fetch(SLACK_WEBHOOK_URL, {
@@ -5,4 +5,7 @@ import CheckToxicityHook from '../components/CheckToxicityHook';
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
export default connect(null, mapDispatchToProps)(CheckToxicityHook);
export default connect(
null,
mapDispatchToProps
)(CheckToxicityHook);
@@ -29,7 +29,10 @@ const withViewingOptionsFragments = withFragments({
});
const enhance = compose(
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
withViewingOptionsFragments,
mapProps(({ root, asset, ...rest }) => ({
slotPassthrough: {