mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 01:10:05 +08:00
lint fixes
This commit is contained in:
@@ -37,6 +37,10 @@
|
||||
"object-curly-spacing": [1],
|
||||
"space-infix-ops": ["error"],
|
||||
"space-in-parens": ["error", "never"],
|
||||
"space-unary-ops": ["error", {
|
||||
"words": true,
|
||||
"nonwords": false
|
||||
}],
|
||||
"no-const-assign": [2],
|
||||
"no-duplicate-imports": [2],
|
||||
"prefer-template": [1],
|
||||
|
||||
@@ -427,16 +427,16 @@ export default Comment;
|
||||
// return whether the comment is editable
|
||||
function commentIsStillEditable (comment) {
|
||||
const editing = comment && comment.editing;
|
||||
if (! editing) {return false;}
|
||||
if (!editing) {return false;}
|
||||
const editableUntil = getEditableUntilDate(comment);
|
||||
const editWindowExpired = (editableUntil - new Date) < 0;
|
||||
return ! editWindowExpired;
|
||||
return !editWindowExpired;
|
||||
}
|
||||
|
||||
// return number of milliseconds before edit window expires
|
||||
function editWindowRemainingMs (comment) {
|
||||
const editableUntil = getEditableUntilDate(comment);
|
||||
if (! editableUntil) {return;}
|
||||
if (!editableUntil) {return;}
|
||||
const now = new Date();
|
||||
const editWindowRemainingMs = (editableUntil - now);
|
||||
return editWindowRemainingMs;
|
||||
|
||||
@@ -113,7 +113,7 @@ export class EditableCommentContent extends React.Component {
|
||||
|
||||
// should be disabled if user hasn't actually changed their
|
||||
// original comment
|
||||
return (comment.body !== originalBody) && ! editWindowExpired;
|
||||
return (comment.body !== originalBody) && !editWindowExpired;
|
||||
}}
|
||||
saveComment={this.editComment}
|
||||
bodyLabel={lang.t('editComment.bodyInputLabel')}
|
||||
|
||||
@@ -72,7 +72,7 @@ class Toggleable extends React.Component {
|
||||
};
|
||||
}
|
||||
toggle() {
|
||||
this.setState({isOpen: ! this.state.isOpen});
|
||||
this.setState({isOpen: !this.state.isOpen});
|
||||
}
|
||||
close() {
|
||||
this.setState({isOpen: false});
|
||||
|
||||
@@ -124,7 +124,7 @@ export default compose(
|
||||
* producing a new queryStream result where asset.comments reflects the edit
|
||||
*/
|
||||
function reduceEditCommentActionsToUpdateStreamQuery(previousResult, action) {
|
||||
if (! (action.type === 'APOLLO_MUTATION_RESULT' && action.operationName === 'editComment')) {
|
||||
if (!(action.type === 'APOLLO_MUTATION_RESULT' && action.operationName === 'editComment')) {
|
||||
return previousResult;
|
||||
}
|
||||
const resultHasErrors = (result) => {
|
||||
@@ -151,7 +151,7 @@ function reduceEditCommentActionsToUpdateStreamQuery(previousResult, action) {
|
||||
return editedComment;
|
||||
};
|
||||
const commentIsStillVisible = (comment) => {
|
||||
return ! ((id === comment.id) && (['PREMOD', 'REJECTED'].includes(status)));
|
||||
return !((id === comment.id) && (['PREMOD', 'REJECTED'].includes(status)));
|
||||
};
|
||||
const resultReflectingEdit = update(previousResult, {
|
||||
asset: {
|
||||
|
||||
@@ -29,7 +29,7 @@ export const BestIndicator = ({children = <Icon name='star'/>}) => (
|
||||
* Component that only renders children if the provided user prop can modify best tags
|
||||
*/
|
||||
export const IfUserCanModifyBest = ({user, children}) => {
|
||||
if (! (user && canModifyBestTag(user))) {return null;}
|
||||
if (!(user && canModifyBestTag(user))) {return null;}
|
||||
return children;
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@ export class BestButton extends Component {
|
||||
async onClickAddBest(e) {
|
||||
e.preventDefault();
|
||||
const {addBest} = this.props;
|
||||
if (! addBest) {
|
||||
if (!addBest) {
|
||||
console.warn('BestButton#onClickAddBest called even though there is no addBest prop. doing nothing');
|
||||
return;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export class BestButton extends Component {
|
||||
async onClickRemoveBest(e) {
|
||||
e.preventDefault();
|
||||
const {removeBest} = this.props;
|
||||
if (! removeBest) {
|
||||
if (!removeBest) {
|
||||
console.warn('BestButton#onClickAddBest called even though there is no removeBest prop. doing nothing');
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ export class BestButton extends Component {
|
||||
render() {
|
||||
const {isBest, addBest, removeBest} = this.props;
|
||||
const {isSaving} = this.state;
|
||||
const disabled = isSaving || ! (isBest ? removeBest : addBest);
|
||||
const disabled = isSaving || !(isBest ? removeBest : addBest);
|
||||
return (
|
||||
<button onClick={isBest ? this.onClickRemoveBest : this.onClickAddBest}
|
||||
disabled={disabled}
|
||||
|
||||
@@ -86,7 +86,7 @@ export class CommentForm extends React.Component {
|
||||
const body = this.state.body;
|
||||
const length = body.length;
|
||||
const isNotValidLength = (length) => !length || (maxCharCount && length > maxCharCount);
|
||||
const disablePostComment = (charCountEnable && isNotValidLength(length)) || ! saveCommentEnabled({body});
|
||||
const disablePostComment = (charCountEnable && isNotValidLength(length)) || !saveCommentEnabled({body});
|
||||
|
||||
return <div>
|
||||
<div className={`${name}-container`}>
|
||||
|
||||
@@ -90,7 +90,7 @@ const RootQuery = {
|
||||
|
||||
// get currentUser again since context.user was out of date when running test/graph/mutations/ignoreUser
|
||||
const currentUser = (await Users.getByQuery({ids: [user.id], limit: 1}))[0];
|
||||
if (! (currentUser && Array.isArray(currentUser.ignoresUsers) && currentUser.ignoresUsers.length)) {
|
||||
if (!(currentUser && Array.isArray(currentUser.ignoresUsers) && currentUser.ignoresUsers.length)) {
|
||||
return [];
|
||||
}
|
||||
return await Users.getByQuery({ids: currentUser.ignoresUsers});
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ UserSchema.method('can', function(...actions) {
|
||||
|
||||
// {add,remove}CommentTag - requires admin and/or moderator role
|
||||
const userCanModifyTags = user => ['ADMIN', 'MODERATOR'].some(r => user.hasRoles(r));
|
||||
if (actions.some(a => ['mutation:removeCommentTag', 'mutation:addCommentTag'].includes(a)) && ! userCanModifyTags(this)) {
|
||||
if (actions.some(a => ['mutation:removeCommentTag', 'mutation:addCommentTag'].includes(a)) && !userCanModifyTags(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user