mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
chore(eslint): add ESLint toolchain and clean src to strict 0/0 (#1165)
* chore(eslint): add eslint toolchain and configs * fix(eslint): resolve gradual-config errors (rules-of-hooks, no-empty, prefer-const, …) * chore(eslint): clear unused vars in config, contexts, app and test * chore(eslint): clear unused vars in api and music-network * chore(eslint): clear unused vars in utils * chore(eslint): clear unused vars in store * chore(eslint): clear unused vars in cover and hooks * chore(eslint): clear unused vars in components * chore(eslint): clear unused vars in pages * chore(eslint): remove explicit any in src * chore(eslint): align react-hooks exhaustive-deps * chore(eslint): zero gradual config on src * chore(eslint): strict hook rules in store and utils * chore(eslint): strict hook rules in hooks and cover * chore(eslint): strict hook rules in components * chore(eslint): strict hook rules in pages and contexts * chore(eslint): document scripts ignore in eslint config * chore(eslint): add lint script and zero strict findings * chore(eslint): address review round 1 (gradual 0/0, per-site disable reasons) * chore(eslint): tighten two set-state disable comments (review round 2 LOW) * chore(nix): sync npmDepsHash with package-lock.json * docs(changelog): add Under the Hood entry for ESLint setup (PR #1165) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -53,6 +53,10 @@ const Ctx = createContext<DragDropContextValue>({
|
||||
isDragging: false,
|
||||
});
|
||||
|
||||
// useDragDrop / useDragSource / registerQueueDragHitTest are the documented
|
||||
// drag-drop API surface, intentionally co-located with DragDropProvider; this
|
||||
// HMR-only rule does not warrant fragmenting the context module.
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export const useDragDrop = () => useContext(Ctx);
|
||||
|
||||
function isQueueReorderDrag(data: string): boolean {
|
||||
@@ -70,6 +74,8 @@ const queueDragHitTests: Array<(x: number, y: number) => boolean> = [];
|
||||
* Register a function that returns true when (clientX, clientY) lies inside
|
||||
* this window’s queue drop area. Unregister on cleanup.
|
||||
*/
|
||||
// Part of the drag-drop API co-located with the provider (see note above).
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export function registerQueueDragHitTest(fn: (x: number, y: number) => boolean): () => void {
|
||||
queueDragHitTests.push(fn);
|
||||
return () => {
|
||||
@@ -154,6 +160,8 @@ export function DragDropProvider({ children }: { children: React.ReactNode }) {
|
||||
});
|
||||
|
||||
const stateRef = useRef(state);
|
||||
// React Compiler refs rule: latest-value box kept in sync for use in callbacks; not render data.
|
||||
// eslint-disable-next-line react-hooks/refs
|
||||
stateRef.current = state;
|
||||
|
||||
const startDrag = useCallback(
|
||||
@@ -277,10 +285,14 @@ const DRAG_THRESHOLD = 5; // px before drag starts
|
||||
* Returns an onMouseDown handler for a draggable element.
|
||||
* Usage: <div {...useDragSource(payload)} />
|
||||
*/
|
||||
// Part of the drag-drop API co-located with the provider (see note above).
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export function useDragSource(getPayload: () => DragPayload) {
|
||||
const { startDrag } = useDragDrop();
|
||||
const startPosRef = useRef<{ x: number; y: number } | null>(null);
|
||||
const payloadRef = useRef(getPayload);
|
||||
// React Compiler refs rule: latest-value box kept in sync for use in handlers; not render data.
|
||||
// eslint-disable-next-line react-hooks/refs
|
||||
payloadRef.current = getPayload;
|
||||
|
||||
const onMouseDown = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user