Skip to content

Commit

Permalink
chore: make eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jun 5, 2024
1 parent c0e3816 commit 4670e29
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/request-idle-callback/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable ssr-friendly/no-dom-globals-in-module-scope -- polyfilllg */
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- polyfill */

/** @see https://foxact.skk.moe/request-idle-callback */
Expand Down
11 changes: 7 additions & 4 deletions src/use-composition-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ export type UseCompositionInputCallback = (value: string) => void;
export type UseCompositionInputReturnKey = 'onChange' | 'onCompositionStart' | 'onCompositionEnd';
export type UseCompositionInputReturn = Pick<JSX.IntrinsicElements['input'], UseCompositionInputReturnKey>;

const getInitialRef = () => ({
/** is"C"ompositioning */ c: false,
/** is"E"mitted */ e: false
});

/** @see https://foxact.skk.moe/use-composition-input */
export const useCompositionInput = (cb: UseCompositionInputCallback): UseCompositionInputReturn => {
const internalState = useSingleton(() => ({
/** is"C"ompositioning */ c: false,
/** is"E"mitted */ e: false
}));
const internalState = useSingleton(getInitialRef);

const onChange = useCallback((e: React.ChangeEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => {
if ('value' in e.target) {
const userInputValue = e.target.value;

if (!internalState.current.c) {
cb(userInputValue);
// eslint-disable-next-line react-compiler/react-compiler -- internalState is ref
internalState.current.e = true;
} else {
internalState.current.e = false;
Expand Down
6 changes: 3 additions & 3 deletions src/use-next-link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ const useNextLink = (

const [isPending, startTransition] = useTransition();

const [setIntersectionRef, isVisible, resetVisible] = useIntersection({
const [setIntersectionRef, isVisible, resetVisible] = useIntersection(useMemo(() => ({
rootMargin: '200px'
});
}), []));

const resolvedHref = useMemo(() => (typeof hrefProp === 'string' ? hrefProp : formatUrl(hrefProp)), [hrefProp]);
const [previousResolvedHref, setPreviousResolvedHref] = useState<string>(resolvedHref);
Expand Down Expand Up @@ -161,7 +161,7 @@ const useNextLink = (
if (typeof ref === 'function') {
ref(el);
} else if (ref && el) {
// We are acting on React behalf to assign the passed-in ref
// eslint-disable-next-line react-compiler/react-compiler -- We are acting on React behalf to assign the passed-in ref
(ref as React.MutableRefObject<HTMLAnchorElement>).current = el;
}
}, [ref, setIntersectionRef]),
Expand Down
1 change: 1 addition & 0 deletions src/use-react-router-enable-concurrent-navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const useReactRouterEnableConcurrentNavigation = () => {
const originalNavigatorPush = navigator.push.bind(navigator);
const originalNavigatorReplace = navigator.replace.bind(navigator);

// eslint-disable-next-line react-compiler/react-compiler -- mutate context global
navigator.go = (...args) => startTransition(() => originalNavigatorGo.apply(navigator, args));
navigator.push = (...args) => startTransition(() => originalNavigatorPush.apply(navigator, args));
navigator.replace = (...args) => startTransition(() => originalNavigatorReplace.apply(navigator, args));
Expand Down
1 change: 1 addition & 0 deletions src/use-url-hash-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function useUrlHashState<T>(
return;
}

// eslint-disable-next-line react-compiler/react-compiler -- sync external state
location.hash = newHash;
}, [defaultValue, deserialized, key, serializer]);

Expand Down

0 comments on commit 4670e29

Please sign in to comment.