mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
eslint
This commit is contained in:
parent
9a8e5efd1a
commit
988a069d57
4 changed files with 23 additions and 24 deletions
|
@ -50,10 +50,10 @@ module.exports = {
|
||||||
'max-len': ["warn", { "code": 100 }],
|
'max-len': ["warn", { "code": 100 }],
|
||||||
"template-curly-spacing": "off",
|
"template-curly-spacing": "off",
|
||||||
"comma-dangle": ["warn", {
|
"comma-dangle": ["warn", {
|
||||||
"arrays": "never",
|
"arrays": "always-multiline",
|
||||||
"objects": "always",
|
"objects": "always-multiline",
|
||||||
"imports": "never",
|
"imports": "always-multiline",
|
||||||
"exports": "never",
|
"exports": "always-multiline",
|
||||||
"functions": "never"
|
"functions": "never"
|
||||||
}],
|
}],
|
||||||
indent: "off"
|
indent: "off"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, {
|
import React, {
|
||||||
FC, ReactChildren, useCallback, ChangeEventHandler, DragEventHandler
|
FC, useCallback, ChangeEventHandler, DragEventHandler
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { SortableContainer, SortableElement } from 'react-sortable-hoc';
|
import { SortableContainer, SortableElement } from 'react-sortable-hoc';
|
||||||
import * as styles from './styles.scss';
|
import * as styles from './styles.scss';
|
||||||
|
@ -15,7 +15,7 @@ interface IProps {
|
||||||
onDrop: DragEventHandler<HTMLFormElement>;
|
onDrop: DragEventHandler<HTMLFormElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SortableItem = SortableElement(({ children }) => (
|
const SortableItem = SortableElement(({ children, }) => (
|
||||||
<div className={styles.item}>{children}</div>
|
<div className={styles.item}>{children}</div>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const SortableList = SortableContainer(
|
||||||
({
|
({
|
||||||
items,
|
items,
|
||||||
locked,
|
locked,
|
||||||
onDrop
|
onDrop,
|
||||||
}: {
|
}: {
|
||||||
items: IFile[];
|
items: IFile[];
|
||||||
locked: IUploadStatus[];
|
locked: IUploadStatus[];
|
||||||
|
@ -46,9 +46,9 @@ const SortableList = SortableContainer(
|
||||||
);
|
);
|
||||||
|
|
||||||
const ImageGrid: FC<IProps> = ({
|
const ImageGrid: FC<IProps> = ({
|
||||||
items, locked, onFileMove, onUpload, onDrop
|
items, locked, onFileMove, onUpload, onDrop,
|
||||||
}) => {
|
}) => {
|
||||||
const onMove = useCallback(({ oldIndex, newIndex }) => onFileMove(oldIndex, newIndex), [
|
const onMove = useCallback(({ oldIndex, newIndex, }) => onFileMove(oldIndex, newIndex), [
|
||||||
onFileMove
|
onFileMove
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ const ImageGrid: FC<IProps> = ({
|
||||||
locked={locked}
|
locked={locked}
|
||||||
onUpload={onUpload}
|
onUpload={onUpload}
|
||||||
onDrop={onDrop}
|
onDrop={onDrop}
|
||||||
pressDelay={100}
|
pressDelay={window.innerWidth < 768 ? 200 : 0}
|
||||||
helperClass={styles.helper}
|
helperClass={styles.helper}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import { createStore, applyMiddleware, combineReducers, compose, Store } from 'redux';
|
||||||
createStore, applyMiddleware, combineReducers, compose, Store
|
|
||||||
} from 'redux';
|
|
||||||
|
|
||||||
import { persistStore, persistReducer } from 'redux-persist';
|
import { persistStore, persistReducer } from 'redux-persist';
|
||||||
import storage from 'redux-persist/lib/storage';
|
import storage from 'redux-persist/lib/storage';
|
||||||
|
@ -25,7 +23,7 @@ import modalReducer, { IModalState } from '~/redux/modal/reducer';
|
||||||
const authPersistConfig: PersistConfig = {
|
const authPersistConfig: PersistConfig = {
|
||||||
key: 'auth',
|
key: 'auth',
|
||||||
whitelist: ['token', 'user'],
|
whitelist: ['token', 'user'],
|
||||||
storage
|
storage,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IState {
|
export interface IState {
|
||||||
|
@ -39,9 +37,10 @@ export interface IState {
|
||||||
export const sagaMiddleware = createSagaMiddleware();
|
export const sagaMiddleware = createSagaMiddleware();
|
||||||
export const history = createBrowserHistory();
|
export const history = createBrowserHistory();
|
||||||
|
|
||||||
const composeEnhancers = typeof window === 'object' && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
const composeEnhancers =
|
||||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
typeof window === 'object' && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||||
: compose;
|
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||||
|
: compose;
|
||||||
|
|
||||||
export const store = createStore(
|
export const store = createStore(
|
||||||
combineReducers<IState>({
|
combineReducers<IState>({
|
||||||
|
|
|
@ -9,35 +9,35 @@ import { IUploadState } from './reducer';
|
||||||
|
|
||||||
const addStatus = (
|
const addStatus = (
|
||||||
state: IUploadState,
|
state: IUploadState,
|
||||||
{ temp_id, status }: ReturnType<typeof uploadAddStatus>
|
{ temp_id, status, }: ReturnType<typeof uploadAddStatus>
|
||||||
): IUploadState => assocPath(
|
): IUploadState => assocPath(
|
||||||
['statuses'],
|
['statuses'],
|
||||||
{ ...state.statuses, [temp_id]: { ...EMPTY_UPLOAD_STATUS, ...status } },
|
{ ...state.statuses, [temp_id]: { ...EMPTY_UPLOAD_STATUS, ...status, }, },
|
||||||
state
|
state
|
||||||
);
|
);
|
||||||
|
|
||||||
const dropStatus = (
|
const dropStatus = (
|
||||||
state: IUploadState,
|
state: IUploadState,
|
||||||
{ temp_id }: ReturnType<typeof uploadDropStatus>
|
{ temp_id, }: ReturnType<typeof uploadDropStatus>
|
||||||
): IUploadState => assocPath(['statuses'], omit([temp_id], state.statuses), state);
|
): IUploadState => assocPath(['statuses'], omit([temp_id], state.statuses), state);
|
||||||
|
|
||||||
const setStatus = (
|
const setStatus = (
|
||||||
state: IUploadState,
|
state: IUploadState,
|
||||||
{ temp_id, status }: ReturnType<typeof uploadSetStatus>
|
{ temp_id, status, }: ReturnType<typeof uploadSetStatus>
|
||||||
): IUploadState => assocPath(
|
): IUploadState => assocPath(
|
||||||
['statuses'],
|
['statuses'],
|
||||||
{
|
{
|
||||||
...state.statuses,
|
...state.statuses,
|
||||||
[temp_id]: { ...(state.statuses[temp_id] || EMPTY_UPLOAD_STATUS), ...status }
|
[temp_id]: { ...(state.statuses[temp_id] || EMPTY_UPLOAD_STATUS), ...status, },
|
||||||
},
|
},
|
||||||
state
|
state
|
||||||
);
|
);
|
||||||
|
|
||||||
const addFile = (state: IUploadState, { file }: ReturnType<typeof uploadAddFile>): IUploadState => assocPath(['files'], { ...state.files, [file.id]: file }, state);
|
const addFile = (state: IUploadState, { file, }: ReturnType<typeof uploadAddFile>): IUploadState => assocPath(['files'], { ...state.files, [file.id]: file, }, state);
|
||||||
|
|
||||||
export const UPLOAD_HANDLERS = {
|
export const UPLOAD_HANDLERS = {
|
||||||
[UPLOAD_ACTIONS.ADD_STATUS]: addStatus,
|
[UPLOAD_ACTIONS.ADD_STATUS]: addStatus,
|
||||||
[UPLOAD_ACTIONS.DROP_STATUS]: dropStatus,
|
[UPLOAD_ACTIONS.DROP_STATUS]: dropStatus,
|
||||||
[UPLOAD_ACTIONS.SET_STATUS]: setStatus,
|
[UPLOAD_ACTIONS.SET_STATUS]: setStatus,
|
||||||
[UPLOAD_ACTIONS.ADD_FILE]: addFile
|
[UPLOAD_ACTIONS.ADD_FILE]: addFile,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue