Skip to content

Commit

Permalink
chore: fix lintig
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi committed Jun 30, 2023
1 parent fe83195 commit 3802f3c
Show file tree
Hide file tree
Showing 34 changed files with 46 additions and 37 deletions.
35 changes: 5 additions & 30 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ module.exports = {

overrides: [
{
files: ['*.js'],
extends: ['@react-hookz/eslint-config/base.cjs'],
},
{
files: ['*.jsx'],
extends: ['@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/react.cjs'],
},
{
files: ['*.ts'],
files: ['*.js', '*.jsx'],
parserOptions: {
project: './tsconfig.eslint.json',
},
extends: ['@react-hookz/eslint-config/typescript.cjs'],
extends: ['@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/react.cjs'],
},
{
files: ['*.tsx'],
files: ['*.ts', '*.tsx'],
parserOptions: {
project: './tsconfig.eslint.json',
},
Expand All @@ -32,32 +24,15 @@ module.exports = {
],
},
{
files: ['**/__tests__/**/*.js'],
extends: ['@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/jest.cjs'],
},
{
files: ['**/__tests__/**/*.jsx'],
files: ['**/__tests__/**/*.js', '**/__tests__/**/*.jsx'],
extends: [
'@react-hookz/eslint-config/base.cjs',
'@react-hookz/eslint-config/react.cjs',
'@react-hookz/eslint-config/jest.cjs',
],
},
{
files: ['**/__tests__/**/*.ts'],
parserOptions: {
project: './tsconfig.eslint.json',
},
extends: [
'@react-hookz/eslint-config/typescript-unsafe.cjs',
'@react-hookz/eslint-config/jest.cjs',
],
},
{
files: ['**/__tests__/**/*.tsx'],
parserOptions: {
project: './tsconfig.eslint.json',
},
files: ['**/__tests__/**/*.ts', '**/__tests__/**/*.tsx'],
extends: [
'@react-hookz/eslint-config/typescript-unsafe.cjs',
'@react-hookz/eslint-config/react.cjs',
Expand Down
2 changes: 1 addition & 1 deletion src/useAsync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function useAsync<Result, Args extends unknown[] = unknown[]>(
},
execute: (...params: Args) => methods.current.execute(...params),
}),

// eslint-disable-next-line react-hooks/exhaustive-deps
[]
),
{ promise: promiseRef.current, lastArgs: argsRef.current },
Expand Down
1 change: 1 addition & 0 deletions src/useAsyncAbortable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function useAsyncAbortable<Result, Args extends unknown[] = unknown[]>(
...asyncActions,
...actions,
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
{ ...asyncMeta, abortController: abortController.current },
];
Expand Down
1 change: 1 addition & 0 deletions src/useClickOutside/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ export function useClickOutside<T extends HTMLElement>(
off(document, name, handler, { passive: true });
});
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [...events]);
}
1 change: 1 addition & 0 deletions src/useControlledRerenderState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function useControlledRerenderState<S>(
rr();
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
];
}
3 changes: 3 additions & 0 deletions src/useCookieValue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,17 @@ export function useCookieValue(

useCallback((value: string) => {
methods.current.set(value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),

useCallback(() => {
methods.current.remove();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),

useCallback(() => {
methods.current.fetch();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
];
}
1 change: 1 addition & 0 deletions src/useCustomCompareMemo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export const useCustomCompareMemo = <T, Deps extends DependencyList>(
dependencies.current = deps;
}

// eslint-disable-next-line react-hooks/exhaustive-deps
return useMemo<T>(factory, dependencies.current);
};
1 change: 1 addition & 0 deletions src/useDebouncedCallback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ export function useDebouncedCallback<Fn extends (...args: any[]) => any>(
});

return wrapped;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [delay, maxWait, ...deps]);
}
1 change: 1 addition & 0 deletions src/useDebouncedEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export function useDebouncedEffect(
delay: number,
maxWait = 0
): void {
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(useDebouncedCallback(callback, deps, delay, maxWait), deps);
}
2 changes: 2 additions & 0 deletions src/useEventListener/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function useEventListener<T extends EventTarget>(
}
},

// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

Expand All @@ -56,5 +57,6 @@ export function useEventListener<T extends EventTarget>(
return () => {
off(tgt, params[0], eventListener, ...restParams);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [target, params[0]]);
}
1 change: 1 addition & 0 deletions src/useFunctionalState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export function useFunctionalState<S>(
const [state, setState] = useState(initialState);
const stateRef = useSyncedRef(state);

// eslint-disable-next-line react-hooks/exhaustive-deps
return [useCallback(() => stateRef.current, []), setState];
}
1 change: 1 addition & 0 deletions src/useHookableRef/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ export function useHookableRef<T>(
v = onSetRef.current === undefined ? val : onSetRef.current(val as T);
},
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}
1 change: 1 addition & 0 deletions src/useIntersectionObserver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export function useIntersectionObserver<T extends Element>(
subscribed = false;
observerEntry.unobserve(tgt, handler);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [target, r, rootMargin, ...threshold]);

return state;
Expand Down
1 change: 1 addition & 0 deletions src/useIntervalEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export function useIntervalEffect(callback: () => void, ms?: number): void {
return () => {
clearInterval(id);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ms]);
}
1 change: 1 addition & 0 deletions src/useKeyboardEvent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function useKeyboardEvent<T extends EventTarget>(
cbRef.current.call(this, ev);
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

useEventListener(target, event, handler, eventOptions);
Expand Down
2 changes: 2 additions & 0 deletions src/useLifecycleLogger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function useLifecycleLogger(componentName: string, deps?: DependencyList)
if (mountedRef.current) {
console.log(`${componentName} updated`, deps && [...deps]);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

useEffect(() => {
Expand All @@ -23,5 +24,6 @@ export function useLifecycleLogger(componentName: string, deps?: DependencyList)
mountedRef.current = false;
console.log(`${componentName} unmounted`);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}
1 change: 1 addition & 0 deletions src/useMediatedState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function useMediatedState<State, RawState = State>(
} else {
setState(value as unknown as State);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
];
}
1 change: 1 addition & 0 deletions src/useMountEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import { useEffect } from 'react';
export function useMountEffect(effect: CallableFunction): void {
useEffect(() => {
effect();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}
1 change: 1 addition & 0 deletions src/usePermission/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function usePermission(descriptor: PermissionDescriptor): UsePermissionSt
unmount.current();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [descriptor.name]);

return state;
Expand Down
2 changes: 1 addition & 1 deletion src/useQueue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function useQueue<T>(initialValue: T[] = []): QueueMethods<T> {
return listRef.current;
},
}),

// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
}
1 change: 1 addition & 0 deletions src/useRafCallback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function useRafCallback<T extends (...args: any[]) => any>(
});

return wrapped;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),

cancel,
Expand Down
2 changes: 1 addition & 1 deletion src/useRafEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function useRafEffect(callback: (...args: any[]) => void, deps: Dependenc

return cancelRaf;
},

// eslint-disable-next-line react-hooks/exhaustive-deps
deps
);
}
1 change: 1 addition & 0 deletions src/useRafState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function useRafState<S = undefined>(): [
export function useRafState<S>(
initialState?: S | (() => S)
): [S | undefined, Dispatch<SetStateAction<S>>] {
// eslint-disable-next-line react/hook-use-state
const [state, innerSetState] = useState<S | undefined>(initialState);

const [setState, cancelRaf] = useRafCallback(innerSetState);
Expand Down
1 change: 1 addition & 0 deletions src/useRerender/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const stateChanger = (state: number) => (state + 1) % Number.MAX_SAFE_INTEGER;
* Return callback function that re-renders component.
*/
export function useRerender(): () => void {
// eslint-disable-next-line react/hook-use-state
const [, setState] = useState(0);

return useCallback(() => {
Expand Down
1 change: 1 addition & 0 deletions src/useResizeObserver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@ export function useResizeObserver<T extends Element>(
subscribed = false;
ro.unsubscribe(tgt, handler);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tgt, ro]);
}
5 changes: 3 additions & 2 deletions src/useStorageValue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export function useStorageValue<
if (!optionsRef.current.initializeWithValue) {
stateActions.current.fetch();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useIsomorphicLayoutEffect(() => {
Expand Down Expand Up @@ -253,7 +254,7 @@ export function useStorageValue<
actions.current.fetch();
},
}),

// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

Expand All @@ -262,7 +263,7 @@ export function useStorageValue<
value: state as UseStorageValueValue<Type, Default, Initialize>,
...staticActions,
}),

// eslint-disable-next-line react-hooks/exhaustive-deps
[state]
);
}
Expand Down
1 change: 1 addition & 0 deletions src/useThrottledCallback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ export function useThrottledCallback<Fn extends (...args: any[]) => any>(
});

return wrapped;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [delay, noTrailing, ...deps]);
}
1 change: 1 addition & 0 deletions src/useThrottledEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export function useThrottledEffect(
delay: number,
noTrailing = false
): void {
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(useThrottledCallback(callback, deps, delay, noTrailing), deps);
}
2 changes: 2 additions & 0 deletions src/useTimeoutEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ export function useTimeoutEffect(
timeoutIdRef.current = setTimeout(() => {
cbRef.current();
}, msRef.current);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
reset();
return cancel;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ms]);

return [cancel, reset];
Expand Down
1 change: 1 addition & 0 deletions src/useToggle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function useToggle(

return Boolean(resolveHookState(nextState, prevState));
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
];
}
2 changes: 1 addition & 1 deletion src/useUnmountEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useUnmountEffect(effect: CallableFunction): void {
() => () => {
effectRef.current();
},

// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
}
1 change: 1 addition & 0 deletions src/useUpdateEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import { noop } from '../util/const';
export function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void {
const isFirstMount = useFirstMountState();

// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(isFirstMount ? noop : effect, deps);
}
2 changes: 2 additions & 0 deletions src/useValidator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export function useValidator<V extends ValidityState>(

useEffect(() => {
validatorRef.current();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

return [
validity,
useCallback(() => {
validatorRef.current();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
];
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"DOM"
],
"jsx": "react",
"allowSyntheticDefaultImports": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true
},
Expand Down

0 comments on commit 3802f3c

Please sign in to comment.