From 5e9ec071dc4ee016f75255c4f93e60d17a6a470d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Feb 2023 11:37:49 +0100 Subject: [PATCH] Remove default exports --- src/api/services/provideServices.ts | 4 +--- src/app/services/provideServices.ts | 4 +--- src/common/services/provideServices.ts | 4 +--- src/container/index.ts | 22 +++++++++---------- src/container/store.ts | 4 ++-- src/domains/services/provideServices.ts | 4 +--- src/mercure/services/provideServices.ts | 4 +--- src/reducers/index.ts | 2 +- src/servers/ManageServers.tsx | 2 +- src/servers/services/ServersExporter.ts | 2 +- src/servers/services/provideServices.ts | 6 ++--- src/settings/services/provideServices.ts | 4 +--- src/short-urls/services/provideServices.ts | 4 +--- src/tags/services/provideServices.ts | 4 +--- src/utils/services/provideServices.ts | 4 +--- src/visits/services/provideServices.ts | 4 +--- test/servers/ManageServers.test.tsx | 2 +- test/servers/services/ServersExporter.test.ts | 2 +- vite.config.ts | 3 ++- 19 files changed, 32 insertions(+), 53 deletions(-) diff --git a/src/api/services/provideServices.ts b/src/api/services/provideServices.ts index b541006c..a89e111b 100644 --- a/src/api/services/provideServices.ts +++ b/src/api/services/provideServices.ts @@ -1,8 +1,6 @@ import type Bottle from 'bottlejs'; import { buildShlinkApiClient } from './ShlinkApiClientBuilder'; -const provideServices = (bottle: Bottle) => { +export const provideServices = (bottle: Bottle) => { bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient'); }; - -export default provideServices; diff --git a/src/app/services/provideServices.ts b/src/app/services/provideServices.ts index 884e2a56..a73d7c83 100644 --- a/src/app/services/provideServices.ts +++ b/src/app/services/provideServices.ts @@ -3,7 +3,7 @@ import type { ConnectDecorator } from '../../container/types'; import { App } from '../App'; import { appUpdateAvailable, resetAppUpdate } from '../reducers/appUpdates'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory( 'App', @@ -23,5 +23,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('appUpdateAvailable', () => appUpdateAvailable); bottle.serviceFactory('resetAppUpdate', () => resetAppUpdate); }; - -export default provideServices; diff --git a/src/common/services/provideServices.ts b/src/common/services/provideServices.ts index a687eaae..23439654 100644 --- a/src/common/services/provideServices.ts +++ b/src/common/services/provideServices.ts @@ -13,7 +13,7 @@ import { HttpClient } from './HttpClient'; import { ImageDownloader } from './ImageDownloader'; import { ReportExporter } from './ReportExporter'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Services bottle.constant('window', window); bottle.constant('console', console); @@ -62,5 +62,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('sidebarPresent', () => sidebarPresent); bottle.serviceFactory('sidebarNotPresent', () => sidebarNotPresent); }; - -export default provideServices; diff --git a/src/container/index.ts b/src/container/index.ts index a0b79398..207b5565 100644 --- a/src/container/index.ts +++ b/src/container/index.ts @@ -2,17 +2,17 @@ import type { IContainer } from 'bottlejs'; import Bottle from 'bottlejs'; import { pick } from 'ramda'; import { connect as reduxConnect } from 'react-redux'; -import provideApiServices from '../api/services/provideServices'; -import provideAppServices from '../app/services/provideServices'; -import provideCommonServices from '../common/services/provideServices'; -import provideDomainsServices from '../domains/services/provideServices'; -import provideMercureServices from '../mercure/services/provideServices'; -import provideServersServices from '../servers/services/provideServices'; -import provideSettingsServices from '../settings/services/provideServices'; -import provideShortUrlsServices from '../short-urls/services/provideServices'; -import provideTagsServices from '../tags/services/provideServices'; -import provideUtilsServices from '../utils/services/provideServices'; -import provideVisitsServices from '../visits/services/provideServices'; +import { provideServices as provideApiServices } from '../api/services/provideServices'; +import { provideServices as provideAppServices } from '../app/services/provideServices'; +import { provideServices as provideCommonServices } from '../common/services/provideServices'; +import { provideServices as provideDomainsServices } from '../domains/services/provideServices'; +import { provideServices as provideMercureServices } from '../mercure/services/provideServices'; +import { provideServices as provideServersServices } from '../servers/services/provideServices'; +import { provideServices as provideSettingsServices } from '../settings/services/provideServices'; +import { provideServices as provideShortUrlsServices } from '../short-urls/services/provideServices'; +import { provideServices as provideTagsServices } from '../tags/services/provideServices'; +import { provideServices as provideUtilsServices } from '../utils/services/provideServices'; +import { provideServices as provideVisitsServices } from '../visits/services/provideServices'; import type { ConnectDecorator } from './types'; type LazyActionMap = Record; diff --git a/src/container/store.ts b/src/container/store.ts index 25c53f0f..4b799ff0 100644 --- a/src/container/store.ts +++ b/src/container/store.ts @@ -2,7 +2,7 @@ import { configureStore } from '@reduxjs/toolkit'; import type { IContainer } from 'bottlejs'; import type { RLSOptions } from 'redux-localstorage-simple'; import { load, save } from 'redux-localstorage-simple'; -import reducer from '../reducers'; +import { initReducers } from '../reducers'; import { migrateDeprecatedSettings } from '../settings/helpers'; import type { ShlinkState } from './types'; @@ -17,7 +17,7 @@ const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as Shl export const setUpStore = (container: IContainer) => configureStore({ devTools: !isProduction, - reducer: reducer(container), + reducer: initReducers(container), preloadedState, middleware: (defaultMiddlewaresIncludingReduxThunk) => defaultMiddlewaresIncludingReduxThunk({ immutableCheck: false, serializableCheck: false }) // State is too big for these diff --git a/src/domains/services/provideServices.ts b/src/domains/services/provideServices.ts index 0a0299d7..f8a2988c 100644 --- a/src/domains/services/provideServices.ts +++ b/src/domains/services/provideServices.ts @@ -6,7 +6,7 @@ import { ManageDomains } from '../ManageDomains'; import { editDomainRedirects } from '../reducers/domainRedirects'; import { domainsListReducerCreator } from '../reducers/domainsList'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory('DomainSelector', () => DomainSelector); bottle.decorator('DomainSelector', connect(['domainsList'], ['listDomains'])); @@ -32,5 +32,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('editDomainRedirects', editDomainRedirects, 'buildShlinkApiClient'); bottle.serviceFactory('checkDomainHealth', prop('checkDomainHealth'), 'domainsListReducerCreator'); }; - -export default provideServices; diff --git a/src/mercure/services/provideServices.ts b/src/mercure/services/provideServices.ts index f665dc31..0b6b4121 100644 --- a/src/mercure/services/provideServices.ts +++ b/src/mercure/services/provideServices.ts @@ -2,7 +2,7 @@ import type Bottle from 'bottlejs'; import { prop } from 'ramda'; import { mercureInfoReducerCreator } from '../reducers/mercureInfo'; -const provideServices = (bottle: Bottle) => { +export const provideServices = (bottle: Bottle) => { // Reducer bottle.serviceFactory('mercureInfoReducerCreator', mercureInfoReducerCreator, 'buildShlinkApiClient'); bottle.serviceFactory('mercureInfoReducer', prop('reducer'), 'mercureInfoReducerCreator'); @@ -10,5 +10,3 @@ const provideServices = (bottle: Bottle) => { // Actions bottle.serviceFactory('loadMercureInfo', prop('loadMercureInfo'), 'mercureInfoReducerCreator'); }; - -export default provideServices; diff --git a/src/reducers/index.ts b/src/reducers/index.ts index be3cd0d6..d2d9ba82 100644 --- a/src/reducers/index.ts +++ b/src/reducers/index.ts @@ -6,7 +6,7 @@ import type { ShlinkState } from '../container/types'; import { serversReducer } from '../servers/reducers/servers'; import { settingsReducer } from '../settings/reducers/settings'; -export default (container: IContainer) => combineReducers({ +export const initReducers = (container: IContainer) => combineReducers({ servers: serversReducer, selectedServer: container.selectedServerReducer, shortUrlsList: container.shortUrlsListReducer, diff --git a/src/servers/ManageServers.tsx b/src/servers/ManageServers.tsx index 3afabfcd..378f157a 100644 --- a/src/servers/ManageServers.tsx +++ b/src/servers/ManageServers.tsx @@ -12,7 +12,7 @@ import { SimpleCard } from '../utils/SimpleCard'; import type { ServersMap } from './data'; import type { ImportServersBtnProps } from './helpers/ImportServersBtn'; import type { ManageServersRowProps } from './ManageServersRow'; -import type ServersExporter from './services/ServersExporter'; +import type { ServersExporter } from './services/ServersExporter'; interface ManageServersProps { servers: ServersMap; diff --git a/src/servers/services/ServersExporter.ts b/src/servers/services/ServersExporter.ts index 5d64de66..c003869b 100644 --- a/src/servers/services/ServersExporter.ts +++ b/src/servers/services/ServersExporter.ts @@ -7,7 +7,7 @@ import { serverWithIdToServerData } from '../data'; const SERVERS_FILENAME = 'shlink-servers.csv'; -export default class ServersExporter { +export class ServersExporter { public constructor( private readonly storage: LocalStorage, private readonly window: Window, diff --git a/src/servers/services/provideServices.ts b/src/servers/services/provideServices.ts index 8535a85b..a7831580 100644 --- a/src/servers/services/provideServices.ts +++ b/src/servers/services/provideServices.ts @@ -21,10 +21,10 @@ import { } from '../reducers/selectedServer'; import { createServers, deleteServer, editServer, setAutoConnect } from '../reducers/servers'; import { ServersDropdown } from '../ServersDropdown'; -import ServersExporter from './ServersExporter'; +import { ServersExporter } from './ServersExporter'; import { ServersImporter } from './ServersImporter'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory( 'ManageServers', @@ -89,5 +89,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('selectedServerReducerCreator', selectedServerReducerCreator, 'selectServer'); bottle.serviceFactory('selectedServerReducer', prop('reducer'), 'selectedServerReducerCreator'); }; - -export default provideServices; diff --git a/src/settings/services/provideServices.ts b/src/settings/services/provideServices.ts index 7448a2f9..8f9dc9e4 100644 --- a/src/settings/services/provideServices.ts +++ b/src/settings/services/provideServices.ts @@ -18,7 +18,7 @@ import { TagsSettings } from '../TagsSettings'; import { UserInterfaceSettings } from '../UserInterfaceSettings'; import { VisitsSettings } from '../VisitsSettings'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory( 'Settings', @@ -63,5 +63,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('setVisitsSettings', () => setVisitsSettings); bottle.serviceFactory('setTagsSettings', () => setTagsSettings); }; - -export default provideServices; diff --git a/src/short-urls/services/provideServices.ts b/src/short-urls/services/provideServices.ts index db03ad28..1e5f79c8 100644 --- a/src/short-urls/services/provideServices.ts +++ b/src/short-urls/services/provideServices.ts @@ -19,7 +19,7 @@ import { ShortUrlsFilteringBar } from '../ShortUrlsFilteringBar'; import { ShortUrlsList } from '../ShortUrlsList'; import { ShortUrlsTable } from '../ShortUrlsTable'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsTable', 'ShortUrlsFilteringBar'); bottle.decorator('ShortUrlsList', connect( @@ -98,5 +98,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('editShortUrl', editShortUrl, 'buildShlinkApiClient'); }; - -export default provideServices; diff --git a/src/tags/services/provideServices.ts b/src/tags/services/provideServices.ts index 7b228478..8fbbe9cb 100644 --- a/src/tags/services/provideServices.ts +++ b/src/tags/services/provideServices.ts @@ -12,7 +12,7 @@ import { TagsList } from '../TagsList'; import { TagsTable } from '../TagsTable'; import { TagsTableRow } from '../TagsTableRow'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory('TagsSelector', TagsSelector, 'ColorGenerator'); bottle.decorator('TagsSelector', connect(['tagsList', 'settings'], ['listTags'])); @@ -57,5 +57,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('editTag', editTag, 'buildShlinkApiClient', 'ColorGenerator'); bottle.serviceFactory('tagEdited', () => tagEdited); }; - -export default provideServices; diff --git a/src/utils/services/provideServices.ts b/src/utils/services/provideServices.ts index 4fd1f46c..7a16b11a 100644 --- a/src/utils/services/provideServices.ts +++ b/src/utils/services/provideServices.ts @@ -4,7 +4,7 @@ import { useTimeoutToggle } from '../helpers/hooks'; import { ColorGenerator } from './ColorGenerator'; import { LocalStorage } from './LocalStorage'; -const provideServices = (bottle: Bottle) => { +export const provideServices = (bottle: Bottle) => { bottle.constant('localStorage', window.localStorage); bottle.service('Storage', LocalStorage, 'localStorage'); bottle.service('ColorGenerator', ColorGenerator, 'Storage'); @@ -16,5 +16,3 @@ const provideServices = (bottle: Bottle) => { bottle.constant('clearTimeout', window.clearTimeout); bottle.serviceFactory('useTimeoutToggle', useTimeoutToggle, 'setTimeout', 'clearTimeout'); }; - -export default provideServices; diff --git a/src/visits/services/provideServices.ts b/src/visits/services/provideServices.ts index beaf6de5..0319bfc4 100644 --- a/src/visits/services/provideServices.ts +++ b/src/visits/services/provideServices.ts @@ -16,7 +16,7 @@ import { ShortUrlVisits } from '../ShortUrlVisits'; import { TagVisits } from '../TagVisits'; import * as visitsParser from './VisitsParser'; -const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { +export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { // Components bottle.serviceFactory('MapModal', () => MapModal); @@ -91,5 +91,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { bottle.serviceFactory('tagVisitsReducerCreator', tagVisitsReducerCreator, 'getTagVisits'); bottle.serviceFactory('tagVisitsReducer', prop('reducer'), 'tagVisitsReducerCreator'); }; - -export default provideServices; diff --git a/test/servers/ManageServers.test.tsx b/test/servers/ManageServers.test.tsx index 763dc889..b3c97e8f 100644 --- a/test/servers/ManageServers.test.tsx +++ b/test/servers/ManageServers.test.tsx @@ -3,7 +3,7 @@ import { MemoryRouter } from 'react-router-dom'; import { Mock } from 'ts-mockery'; import type { ServersMap, ServerWithId } from '../../src/servers/data'; import { ManageServers as createManageServers } from '../../src/servers/ManageServers'; -import type ServersExporter from '../../src/servers/services/ServersExporter'; +import type { ServersExporter } from '../../src/servers/services/ServersExporter'; import { renderWithEvents } from '../__helpers__/setUpTest'; describe('', () => { diff --git a/test/servers/services/ServersExporter.test.ts b/test/servers/services/ServersExporter.test.ts index cab4b056..796ca5d9 100644 --- a/test/servers/services/ServersExporter.test.ts +++ b/test/servers/services/ServersExporter.test.ts @@ -1,5 +1,5 @@ import { Mock } from 'ts-mockery'; -import ServersExporter from '../../../src/servers/services/ServersExporter'; +import { ServersExporter } from '../../../src/servers/services/ServersExporter'; import type { LocalStorage } from '../../../src/utils/services/LocalStorage'; import { appendChild, removeChild, windowMock } from '../../__mocks__/Window.mock'; diff --git a/vite.config.ts b/vite.config.ts index 9d6f04c7..36f0d8e5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,12 @@ -import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite'; import { VitePWA } from 'vite-plugin-pwa'; import { manifest } from './manifest'; import pack from './package.json'; const homepage = pack.homepage?.trim(); +/* eslint-disable-next-line no-restricted-exports */ export default defineConfig({ plugins: [react(), VitePWA({ mode: process.env.NODE_ENV === 'development' ? 'development' : 'production',