mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05: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:
@@ -43,6 +43,11 @@ type ResolvedSlice = { key: string | null; url: string };
|
||||
* loading immediately. Pass false for CSS background-image consumers that
|
||||
* should only see a stable blob URL (prevents a double crossfade).
|
||||
*/
|
||||
// useCachedUrl is the headless companion of CachedImage — it shares the same
|
||||
// caching contract and the module-local ResolvedSlice type, and is documented
|
||||
// alongside the component in src/CLAUDE.md. Intentional co-location; the
|
||||
// fast-refresh rule is an HMR-only concern.
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export function useCachedUrl(
|
||||
fetchUrl: string,
|
||||
cacheKey: string,
|
||||
@@ -54,6 +59,8 @@ export function useCachedUrl(
|
||||
// `fetchUrl` were an effect dependency, cleanup would run every frame, call
|
||||
// `releaseUrl`, revoke the blob, and break <img> until onError hides it.
|
||||
const fetchUrlRef = useRef(fetchUrl);
|
||||
// React Compiler refs rule: ref kept in sync with the latest value for use in effects/handlers/cleanup; not render data.
|
||||
// eslint-disable-next-line react-hooks/refs
|
||||
fetchUrlRef.current = fetchUrl;
|
||||
|
||||
// Pair blob URL with the `cacheKey` it belongs to. After `cacheKey` changes,
|
||||
@@ -71,6 +78,8 @@ export function useCachedUrl(
|
||||
);
|
||||
|
||||
const getPriorityRef = useRef(getPriority);
|
||||
// React Compiler refs rule: ref kept in sync with the latest value for use in effects/handlers/cleanup; not render data.
|
||||
// eslint-disable-next-line react-hooks/refs
|
||||
getPriorityRef.current = getPriority;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -100,6 +109,8 @@ export function useCachedUrl(
|
||||
const sync = acquireUrl(cacheKey);
|
||||
if (sync) {
|
||||
ownedKeyRef.current = cacheKey;
|
||||
// React Compiler set-state-in-effect rule: state set from an async result resolved in this effect.
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
setResolvedSlice({ key: cacheKey, url: sync });
|
||||
return release;
|
||||
}
|
||||
@@ -211,6 +222,8 @@ export default function CachedImage({
|
||||
// useLayoutEffect: one paint with `loaded` still true + a stale/wrong `src`
|
||||
// showed a broken-cover flash in the player bar when switching tracks (#606).
|
||||
useLayoutEffect(() => {
|
||||
// React Compiler set-state-in-effect rule: state set from a timer/animation callback.
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
setLoaded(false);
|
||||
setFallbackSrc(undefined);
|
||||
}, [cacheKey]);
|
||||
|
||||
Reference in New Issue
Block a user