Fix ESLint warnings and and enable max warnings 0 to fail builds (#2101)
This commit is contained in:
@@ -44,21 +44,25 @@ export const SearchBar: React.FC<SearchBarProps> = ({
|
||||
|
||||
// Create debounced search function
|
||||
const debouncedSearch = useCallback(
|
||||
debounce((term: string, caseSensitive: boolean) => {
|
||||
onSearch(term, caseSensitive);
|
||||
}, 150),
|
||||
[]
|
||||
(term: string, isCaseSensitive: boolean) => {
|
||||
debounce((searchTerm: string, caseSensitive: boolean) => {
|
||||
onSearch(searchTerm, caseSensitive);
|
||||
}, 150)(term, isCaseSensitive);
|
||||
},
|
||||
[onSearch]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
inputRef.current?.focus();
|
||||
|
||||
// Cleanup debounced function
|
||||
return () => {
|
||||
debouncedSearch.cancel();
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Cleanup debounced function on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
debouncedSearch.cancel?.();
|
||||
};
|
||||
}, [debouncedSearch]);
|
||||
|
||||
const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.target.value;
|
||||
setDisplayTerm(value); // Update display immediately
|
||||
@@ -93,7 +97,7 @@ export const SearchBar: React.FC<SearchBarProps> = ({
|
||||
|
||||
const handleClose = () => {
|
||||
setIsExiting(true);
|
||||
debouncedSearch.cancel(); // Cancel any pending searches
|
||||
debouncedSearch.cancel?.(); // Cancel any pending searches
|
||||
setTimeout(() => {
|
||||
onClose();
|
||||
}, 150); // Match animation duration
|
||||
|
||||
@@ -36,20 +36,25 @@ export const SearchView: React.FC<PropsWithChildren<SearchViewProps>> = ({
|
||||
|
||||
// Create debounced highlight function
|
||||
const debouncedHighlight = useCallback(
|
||||
debounce((term: string, caseSensitive: boolean, highlighter: SearchHighlighter) => {
|
||||
const highlights = highlighter.highlight(term, caseSensitive);
|
||||
const count = highlights.length;
|
||||
(term: string, caseSensitive: boolean, highlighter: SearchHighlighter) => {
|
||||
debounce(
|
||||
(searchTerm: string, isCaseSensitive: boolean, searchHighlighter: SearchHighlighter) => {
|
||||
const highlights = searchHighlighter.highlight(searchTerm, isCaseSensitive);
|
||||
const count = highlights.length;
|
||||
|
||||
if (count > 0) {
|
||||
setSearchResults({
|
||||
currentIndex: 1,
|
||||
count,
|
||||
});
|
||||
highlighter.setCurrentMatch(0, true); // Explicitly scroll when setting initial match
|
||||
} else {
|
||||
setSearchResults(null);
|
||||
}
|
||||
}, 150),
|
||||
if (count > 0) {
|
||||
setSearchResults({
|
||||
currentIndex: 1,
|
||||
count,
|
||||
});
|
||||
searchHighlighter.setCurrentMatch(0, true); // Explicitly scroll when setting initial match
|
||||
} else {
|
||||
setSearchResults(null);
|
||||
}
|
||||
},
|
||||
150
|
||||
)(term, caseSensitive, highlighter);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -60,9 +65,9 @@ export const SearchView: React.FC<PropsWithChildren<SearchViewProps>> = ({
|
||||
highlighterRef.current.destroy();
|
||||
highlighterRef.current = null;
|
||||
}
|
||||
debouncedHighlight.cancel();
|
||||
debouncedHighlight.cancel?.();
|
||||
};
|
||||
}, []);
|
||||
}, [debouncedHighlight]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
@@ -162,7 +167,7 @@ export const SearchView: React.FC<PropsWithChildren<SearchViewProps>> = ({
|
||||
highlighterRef.current.clearHighlights();
|
||||
}
|
||||
// Cancel any pending highlight operations
|
||||
debouncedHighlight.cancel();
|
||||
debouncedHighlight.cancel?.();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user