From 33f5aa154457fb62099e56716ca5ae45feb98730 Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Fri, 14 May 2021 17:50:36 -0400
Subject: linted

---
 src/components/comments/MentionInputControlled.tsx | 97 +++++++++++-----------
 1 file changed, 50 insertions(+), 47 deletions(-)

(limited to 'src/components/comments/MentionInputControlled.tsx')

diff --git a/src/components/comments/MentionInputControlled.tsx b/src/components/comments/MentionInputControlled.tsx
index 6abcb566..2fd2b41d 100644
--- a/src/components/comments/MentionInputControlled.tsx
+++ b/src/components/comments/MentionInputControlled.tsx
@@ -6,7 +6,6 @@ import {
   TextInputSelectionChangeEventData,
   View,
 } from 'react-native';
-
 import {
   MentionInputProps,
   MentionPartType,
@@ -43,16 +42,16 @@ const MentionInputControlled: FC<MentionInputProps> = ({
 
   const validRegex = () => {
     if (partTypes.length === 0) {
-      return /.*\@[^ ]*$/;
+      return /.*@[^ ]*$/;
     } else {
-      return new RegExp(`.*\@${keywordByTrigger[partTypes[0].trigger]}.*$`);
+      return new RegExp(`.*@${keywordByTrigger[partTypes[0].trigger]}.*$`);
     }
   };
 
-  const {plainText, parts} = useMemo(() => parseValue(value, partTypes), [
-    value,
-    partTypes,
-  ]);
+  const {plainText, parts} = useMemo(
+    () => parseValue(value, partTypes),
+    [value, partTypes],
+  );
 
   const handleSelectionChange = (
     event: NativeSyntheticEvent<TextInputSelectionChangeEventData>,
@@ -91,36 +90,35 @@ const MentionInputControlled: FC<MentionInputProps> = ({
    * - Get updated value
    * - Trigger onChange callback with new value
    */
-  const onSuggestionPress = (mentionType: MentionPartType) => (
-    suggestion: Suggestion,
-  ) => {
-    const newValue = generateValueWithAddedSuggestion(
-      parts,
-      mentionType,
-      plainText,
-      selection,
-      suggestion,
-    );
-
-    if (!newValue) {
-      return;
-    }
+  const onSuggestionPress =
+    (mentionType: MentionPartType) => (suggestion: Suggestion) => {
+      const newValue = generateValueWithAddedSuggestion(
+        parts,
+        mentionType,
+        plainText,
+        selection,
+        suggestion,
+      );
+
+      if (!newValue) {
+        return;
+      }
 
-    onChange(newValue);
+      onChange(newValue);
 
-    /**
-     * Move cursor to the end of just added mention starting from trigger string and including:
-     * - Length of trigger string
-     * - Length of mention name
-     * - Length of space after mention (1)
-     *
-     * Not working now due to the RN bug
-     */
-    // const newCursorPosition = currentPart.position.start + triggerPartIndex + trigger.length +
-    // suggestion.name.length + 1;
+      /**
+       * Move cursor to the end of just added mention starting from trigger string and including:
+       * - Length of trigger string
+       * - Length of mention name
+       * - Length of space after mention (1)
+       *
+       * Not working now due to the RN bug
+       */
+      // const newCursorPosition = currentPart.position.start + triggerPartIndex + trigger.length +
+      // suggestion.name.length + 1;
 
-    // textInput.current?.setNativeProps({selection: {start: newCursorPosition, end: newCursorPosition}});
-  };
+      // textInput.current?.setNativeProps({selection: {start: newCursorPosition, end: newCursorPosition}});
+    };
 
   const handleTextInputRef = (ref: TextInput) => {
     textInput.current = ref as TextInput;
@@ -129,7 +127,8 @@ const MentionInputControlled: FC<MentionInputProps> = ({
       if (typeof propInputRef === 'function') {
         propInputRef(ref);
       } else {
-        (propInputRef as MutableRefObject<TextInput>).current = ref as TextInput;
+        (propInputRef as MutableRefObject<TextInput>).current =
+          ref as TextInput;
       }
     }
   };
@@ -151,12 +150,14 @@ const MentionInputControlled: FC<MentionInputProps> = ({
   return (
     <View style={containerStyle}>
       {validateInput(keyboardText)
-        ? (partTypes.filter(
-            (one) =>
-              isMentionPartType(one) &&
-              one.renderSuggestions != null &&
-              !one.isBottomMentionSuggestionsRender,
-          ) as MentionPartType[]).map(renderMentionSuggestions)
+        ? (
+            partTypes.filter(
+              (one) =>
+                isMentionPartType(one) &&
+                one.renderSuggestions != null &&
+                !one.isBottomMentionSuggestionsRender,
+            ) as MentionPartType[]
+          ).map(renderMentionSuggestions)
         : null}
 
       <TextInput
@@ -181,12 +182,14 @@ const MentionInputControlled: FC<MentionInputProps> = ({
       </TextInput>
 
       {validateInput(keyboardText)
-        ? (partTypes.filter(
-            (one) =>
-              isMentionPartType(one) &&
-              one.renderSuggestions != null &&
-              one.isBottomMentionSuggestionsRender,
-          ) as MentionPartType[]).map(renderMentionSuggestions)
+        ? (
+            partTypes.filter(
+              (one) =>
+                isMentionPartType(one) &&
+                one.renderSuggestions != null &&
+                one.isBottomMentionSuggestionsRender,
+            ) as MentionPartType[]
+          ).map(renderMentionSuggestions)
         : null}
     </View>
   );
-- 
cgit v1.2.3-70-g09d2

