mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
eslint fix
This commit is contained in:
parent
dfaac877fb
commit
fa4d51360b
81 changed files with 741 additions and 972 deletions
|
@ -1,10 +1,10 @@
|
|||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
import { push } from 'connected-react-router';
|
||||
import { API } from '~/constants/api';
|
||||
import { store } from '~/redux/store';
|
||||
import { push } from 'connected-react-router';
|
||||
import { IResultWithStatus } from '~/redux/types';
|
||||
|
||||
export const authMiddleware = r => {
|
||||
export const authMiddleware = (r) => {
|
||||
store.dispatch(push('/login'));
|
||||
return r;
|
||||
};
|
||||
|
@ -23,18 +23,15 @@ export const HTTP_RESPONSES = {
|
|||
TOO_MANY_REQUESTS: 429,
|
||||
};
|
||||
|
||||
export const resultMiddleware = <T extends {}>({
|
||||
export const resultMiddleware = (<)T extends {}>({
|
||||
status,
|
||||
data,
|
||||
}: {
|
||||
status: number;
|
||||
data: T;
|
||||
}): { status: number; data: T } => {
|
||||
return data && { status, data };
|
||||
};
|
||||
}): { status: number; data: T } => data && { status, data };
|
||||
|
||||
export const errorMiddleware = <T extends any>(debug): IResultWithStatus<T> =>
|
||||
debug && debug.response
|
||||
export const errorMiddleware = <T extends any>(debug): IResultWithStatus<T> => debug && debug.response
|
||||
? debug.response
|
||||
: {
|
||||
status: HTTP_RESPONSES.CONNECTION_REFUSED,
|
||||
|
|
|
@ -26,7 +26,6 @@ export const describeArc = (
|
|||
startAngle: number = 0,
|
||||
endAngle: number = 360,
|
||||
): string => {
|
||||
|
||||
const start = polarToCartesian(x, y, radius, endAngle);
|
||||
const end = polarToCartesian(x, y, radius, startAngle);
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@ import insert from 'ramda/es/insert';
|
|||
import nth from 'ramda/es/nth';
|
||||
import remove from 'ramda/es/remove';
|
||||
|
||||
export const moveArrItem = curry((at, to, list) => insert(to, nth(at, list), remove(at, 1, list)))
|
||||
export const moveArrItem = curry((at, to, list) => insert(to, nth(at, list), remove(at, 1, list)));
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
useCallback, useEffect, useRef, useState
|
||||
} from 'react';
|
||||
|
||||
export const useCloseOnEscape = (onRequestClose: () => void, ignore_inputs = false) => {
|
||||
const onEscape = useCallback(
|
||||
event => {
|
||||
(event) => {
|
||||
if (event.key !== 'Escape') return;
|
||||
if (
|
||||
ignore_inputs &&
|
||||
(event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA')
|
||||
)
|
||||
return;
|
||||
ignore_inputs
|
||||
&& (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA')
|
||||
) return;
|
||||
|
||||
onRequestClose();
|
||||
},
|
||||
[onRequestClose],
|
||||
[ignore_inputs, onRequestClose],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -30,5 +32,5 @@ export const useDelayedReady = (setReady: (val: boolean) => void, delay: number
|
|||
return () => {
|
||||
if (timer) clearTimeout(timer);
|
||||
};
|
||||
}, []);
|
||||
}, [delay, setReady]);
|
||||
};
|
||||
|
|
|
@ -14,6 +14,6 @@ type Handlers<State, Types extends string, Actions extends Action<Types>> = {
|
|||
export const createReducer = (
|
||||
initialState,
|
||||
handlers,
|
||||
) => (state = initialState, action) => handlers.hasOwnProperty(action.type)
|
||||
) => (state = initialState, action) => (handlers.hasOwnProperty(action.type)
|
||||
? handlers[action.type](state, action)
|
||||
: state;
|
||||
: state);
|
||||
|
|
|
@ -13,7 +13,7 @@ export function createUploader<T extends {}, R extends {}>(
|
|||
): [(args: T) => (args: T & { onProgress: (current: number, total: number) => void }) => any, EventChannel<any>] {
|
||||
let emit;
|
||||
|
||||
const chan = eventChannel(emitter => {
|
||||
const chan = eventChannel((emitter) => {
|
||||
emit = emitter;
|
||||
return () => null;
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ export function createUploader<T extends {}, R extends {}>(
|
|||
return [wrappedCallback, chan];
|
||||
}
|
||||
|
||||
export const uploadGetThumb = async file => {
|
||||
export const uploadGetThumb = async (file) => {
|
||||
if (!file.type || !VALIDATORS.IS_IMAGE_MIME(file.type)) return '';
|
||||
|
||||
return await new Promise((resolve, reject) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue