From e98dc1c5da5126ebdf2d34412e5ed7248b29747a Mon Sep 17 00:00:00 2001 From: Gigi Date: Sat, 4 Oct 2025 22:13:31 +0100 Subject: [PATCH] fix: resolve all linting and type errors - Remove unused applyHighlightsToText import from ContentPanel - Replace while(true) with proper condition in findHighlightMatches - Remove unused match parameter from replaceTextWithMark function All ESLint and TypeScript checks now pass with no errors. --- src/components/ContentPanel.tsx | 2 +- src/utils/highlightMatching.tsx | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index de56b41a..b2cf566f 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -4,7 +4,7 @@ import remarkGfm from 'remark-gfm' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faSpinner, faHighlighter } from '@fortawesome/free-solid-svg-icons' import { Highlight } from '../types/highlights' -import { applyHighlightsToText, applyHighlightsToHTML } from '../utils/highlightMatching' +import { applyHighlightsToHTML } from '../utils/highlightMatching' interface ContentPanelProps { loading: boolean diff --git a/src/utils/highlightMatching.tsx b/src/utils/highlightMatching.tsx index 57dab913..53db750b 100644 --- a/src/utils/highlightMatching.tsx +++ b/src/utils/highlightMatching.tsx @@ -25,10 +25,8 @@ export function findHighlightMatches( let startIndex = 0 // Find all occurrences of this highlight in the content - while (true) { - const index = content.indexOf(searchText, startIndex) - if (index === -1) break - + let index = content.indexOf(searchText, startIndex) + while (index !== -1) { matches.push({ highlight, startIndex: index, @@ -36,6 +34,7 @@ export function findHighlightMatches( }) startIndex = index + searchText.length + index = content.indexOf(searchText, startIndex) } } @@ -110,7 +109,7 @@ function createMarkElement(highlight: Highlight, matchText: string): HTMLElement } // Helper to replace text node with mark element -function replaceTextWithMark(textNode: Text, before: string, match: string, after: string, mark: HTMLElement) { +function replaceTextWithMark(textNode: Text, before: string, after: string, mark: HTMLElement) { const parent = textNode.parentNode if (!parent) return @@ -157,7 +156,7 @@ function tryMarkInTextNodes( const after = text.substring(actualIndex + searchText.length) const mark = createMarkElement(highlight, match) - replaceTextWithMark(textNode, before, match, after, mark) + replaceTextWithMark(textNode, before, after, mark) return true }