fix: clean up component to fix lint warnings preventing frontend build

This commit is contained in:
Jordan Knott
2021-09-04 14:07:54 -05:00
parent 3bfce1825c
commit a188c4b0ca
32 changed files with 291 additions and 339 deletions

View File

@ -13,6 +13,7 @@ import {
Smile,
} from 'shared/icons';
import { toArray } from 'react-emoji-render';
import { useCurrentUser } from 'App/context';
import DOMPurify from 'dompurify';
import TaskAssignee from 'shared/components/TaskAssignee';
import useOnOutsideClick from 'shared/hooks/onOutsideClick';
@ -80,11 +81,8 @@ import {
ActivityItemHeaderTitleName,
ActivityItemComment,
} from './Styles';
import { useCurrentUser } from 'App/context';
type TaskDetailsProps = {};
const TaskDetailsLoading: React.FC<TaskDetailsProps> = () => {
const TaskDetailsLoading: React.FC = () => {
const { user } = useCurrentUser();
return (
<Container>

View File

@ -1,4 +1,5 @@
import React, { useState, useRef } from 'react';
import { useCurrentUser } from 'App/context';
import {
Plus,
User,
@ -81,9 +82,8 @@ import {
} from './Styles';
import Checklist, { ChecklistItem, ChecklistItems } from '../Checklist';
import onDragEnd from './onDragEnd';
import { plugin as em } from './remark';
import plugin from './remark';
import ActivityMessage from './ActivityMessage';
import { useCurrentUser } from 'App/context';
const parseEmojis = (value: string) => {
const emojisArray = toArray(value);
@ -136,7 +136,7 @@ const StreamComment: React.FC<StreamCommentProps> = ({
onCreateComment={onUpdateComment}
/>
) : (
<ReactMarkdown skipHtml plugins={[em]}>
<ReactMarkdown skipHtml plugins={[plugin]}>
{DOMPurify.sanitize(comment.message, { FORBID_TAGS: ['style', 'img'] })}
</ReactMarkdown>
)}

View File

@ -1,4 +1,4 @@
import visit from 'unist-util-visit';
import { visit } from 'unist-util-visit';
import emoji from 'node-emoji';
import { emoticon } from 'emoticon';
import { Emoji } from 'emoji-mart';
@ -15,17 +15,17 @@ const DEFAULT_SETTINGS = {
};
function plugin(options) {
const settings = Object.assign({}, DEFAULT_SETTINGS, options);
const settings = { ...DEFAULT_SETTINGS, ...options };
const pad = !!settings.padSpaceAfter;
const emoticonEnable = !!settings.emoticon;
function getEmojiByShortCode(match) {
// find emoji by shortcode - full match or with-out last char as it could be from text e.g. :-),
const iconFull = emoticon.find(e => e.emoticons.includes(match)); // full match
const iconPart = emoticon.find(e => e.emoticons.includes(match.slice(0, -1))); // second search pattern
const iconFull = emoticon.find((e) => e.emoticons.includes(match)); // full match
const iconPart = emoticon.find((e) => e.emoticons.includes(match.slice(0, -1))); // second search pattern
const trimmedChar = iconPart ? match.slice(-1) : '';
const addPad = pad ? ' ' : '';
let icon = iconFull ? iconFull.emoji + addPad : iconPart && iconPart.emoji + addPad + trimmedChar;
const icon = iconFull ? iconFull.emoji + addPad : iconPart && iconPart.emoji + addPad + trimmedChar;
return icon || match;
}
@ -33,7 +33,7 @@ function plugin(options) {
console.log(match);
const got = emoji.get(match);
if (pad && got !== match) {
return got + ' ';
return `${got} `;
}
console.log(got);
@ -41,7 +41,7 @@ function plugin(options) {
}
function transformer(tree) {
visit(tree, 'paragraph', function(node) {
visit(tree, 'paragraph', function (node) {
console.log(tree);
// node.value = node.value.replace(RE_EMOJI, getEmoji);
// jnode.type = 'html';
@ -65,4 +65,4 @@ function plugin(options) {
return transformer;
}
export { plugin };
export default plugin;