refactor: extract signals filter builder, add ESLint 10 config, fix low-hanging issues
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import uPlot from 'uplot';
|
||||
import { useCallback, useEffect, useRef, type DependencyList } from 'react';
|
||||
|
||||
import type uPlot from 'uplot';
|
||||
|
||||
export type BuildFn = (
|
||||
el: HTMLDivElement,
|
||||
w: number,
|
||||
h: number,
|
||||
legendRef: React.RefObject<HTMLDivElement>,
|
||||
legendRef: React.RefObject<HTMLDivElement | null>,
|
||||
) => uPlot | null;
|
||||
|
||||
/** Converts a data index to the pixel x position uPlot expects for setCursor */
|
||||
@@ -24,14 +25,13 @@ function idxToPixel(plot: uPlot, idx: number): number {
|
||||
*/
|
||||
export function usePlot(
|
||||
build: BuildFn,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
deps: any[],
|
||||
deps: DependencyList,
|
||||
): {
|
||||
containerRef: React.RefObject<HTMLDivElement | null>;
|
||||
legendRef: React.RefObject<HTMLDivElement>;
|
||||
legendRef: React.RefObject<HTMLDivElement | null>;
|
||||
} {
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
const legendRef = useRef<HTMLDivElement>(null!);
|
||||
const legendRef = useRef<HTMLDivElement>(null);
|
||||
const plotRef = useRef<uPlot | null>(null);
|
||||
const lastIdxRef = useRef<number>(0);
|
||||
|
||||
@@ -64,7 +64,8 @@ export function usePlot(
|
||||
});
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
// deps is intentionally dynamic — passed by parent to allow external rebuild triggers
|
||||
// eslint-disable-next-line react-x/exhaustive-deps
|
||||
}, deps);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user