[ESLint] Prefer named exports (#427)

This commit is contained in:
schroda
2023-10-28 00:32:02 +02:00
committed by GitHub
parent 68e7b4b16d
commit 5a5b12a9e1
118 changed files with 319 additions and 470 deletions

View File

@@ -6,6 +6,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
export default function cloneObject<T extends object>(obj: T) {
export function cloneObject<T extends object>(obj: T) {
return JSON.parse(JSON.stringify(obj)) as T;
}

View File

@@ -6,7 +6,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
function getItem<T>(key: string, defaultValue: T): T {
export function getItem<T>(key: string, defaultValue: T): T {
const item = window.localStorage.getItem(key);
if (item !== null) {
@@ -17,8 +17,6 @@ function getItem<T>(key: string, defaultValue: T): T {
return defaultValue;
}
function setItem<T>(key: string, value: T): void {
export function setItem<T>(key: string, value: T): void {
window.localStorage.setItem(key, JSON.stringify(value));
}
export default { getItem, setItem };

View File

@@ -18,7 +18,7 @@ import {
TChapter,
TManga,
} from '@/typings';
import requestManager from '@/lib/requests/RequestManager.ts';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { MetaType } from '@/lib/graphql/generated/graphql.ts';
const APP_METADATA_KEY_PREFIX = 'webUI_';

View File

@@ -7,7 +7,7 @@
*/
import { Metadata, IReaderSettings, MetadataKeyValuePair, GqlMetaHolder, TManga } from '@/typings';
import requestManager from '@/lib/requests/RequestManager.ts';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import {
convertFromGqlMeta,
getMetadataFrom,

View File

@@ -7,7 +7,7 @@
*/
import { Metadata, ISearchSettings } from '@/typings';
import requestManager from '@/lib/requests/RequestManager.ts';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { convertFromGqlMeta, getMetadataFrom } from '@/util/metadata';
export const getDefaultSettings = (): ISearchSettings => ({

View File

@@ -9,7 +9,6 @@
import { useEffect, useState } from 'react';
import { NavigationType, useLocation, useNavigationType } from 'react-router-dom';
// eslint-disable-next-line import/prefer-default-export
export const useHistory = () => {
const location = useLocation();
const navigationType = useNavigationType();

View File

@@ -7,9 +7,9 @@
*/
import { useState, Dispatch, SetStateAction, useReducer, Reducer, useCallback } from 'react';
import storage from '@/util/localStorage';
import * as storage from '@/util/localStorage';
export default function useLocalStorage<T>(key: string, defaultValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>] {
export function useLocalStorage<T>(key: string, defaultValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>] {
const initialState = defaultValue instanceof Function ? defaultValue() : defaultValue;
const [storedValue, setStoredValue] = useState<T>(storage.getItem(key, initialState));