cleanup Lens repo with tighter linting

Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian Malton committed 2020-07-09 17:00:23 -04:00
1 parent e468105143
commit b1ff34879a
470 files changed
+8447 -7443

No files matched your search

+3 -3
View File
@@ -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";
+3 -3
View File
@@ -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]);
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { useEffect } from "react";
export function useOnUnmount(callback: () => void) {
useEffect(() => callback, [])
export function useOnUnmount(callback: () => void): void {
useEffect(() => callback, []);
}
+5 -5
View File
@@ -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];
}