mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
e468105143
commit
b1ff34879a
470 files changed
+8447
-7443
No files matched your search
@@ -1,5 +1,5 @@
|
||||
// Custom react hooks for common usage
|
||||
|
||||
export * from "./useStorage"
|
||||
export * from "./useOnUnmount"
|
||||
export * from "./useInterval"
|
||||
export * from "./useStorage";
|
||||
export * from "./useOnUnmount";
|
||||
export * from "./useInterval";
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useRef, useEffect } from "react";
|
||||
|
||||
export function useInterval(callback: () => void, delay: number) {
|
||||
export function useInterval(callback: () => void, delay: number): void {
|
||||
const savedCallback = useRef<() => void>();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -8,11 +8,11 @@ export function useInterval(callback: () => void, delay: number) {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
function tick() {
|
||||
function tick(): void {
|
||||
savedCallback.current();
|
||||
}
|
||||
|
||||
const id = setInterval(tick, delay);
|
||||
return () => clearInterval(id);
|
||||
return (): void => clearInterval(id);
|
||||
}, [delay]);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
export function useOnUnmount(callback: () => void) {
|
||||
useEffect(() => callback, [])
|
||||
export function useOnUnmount(callback: () => void): void {
|
||||
useEffect(() => callback, []);
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useState } from "react";
|
||||
import { createStorage, IStorageHelperOptions } from "../utils";
|
||||
import { StorageHelper, StorageHelperOptions } from "../utils";
|
||||
|
||||
export function useStorage<T>(key: string, initialValue?: T, options?: IStorageHelperOptions) {
|
||||
const storage = createStorage(key, initialValue, options);
|
||||
export function useStorage<T>(key: string, initialValue?: T, options?: StorageHelperOptions): [T, (value: T) => void] {
|
||||
const storage = new StorageHelper(key, initialValue, options);
|
||||
const [storageValue, setStorageValue] = useState(storage.get());
|
||||
const setValue = (value: T) => {
|
||||
const setValue = (value: T): void => {
|
||||
setStorageValue(value);
|
||||
storage.set(value);
|
||||
};
|
||||
return [storageValue, setValue] as [T, (value: T) => void];
|
||||
return [storageValue, setValue];
|
||||
}
|
||||
Reference in new issue
Block a user