From d16cc1f2c59818e53f28b4d6b4d27250331f15d7 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 2 Jul 2022 05:13:38 +0530 Subject: Use default exports instead of named exports --- src/I18n.tsx | 2 +- src/api/apiBase.ts | 4 +--- src/api/server/ServerApi.ts | 2 +- src/components/auth/Welcome.js | 2 +- src/components/ui/AppLoader/index.tsx | 2 +- src/components/ui/Link.js | 2 +- src/containers/auth/SetupAssistantScreen.tsx | 2 +- src/electron/windowUtils.ts | 2 +- src/enforce-macos-app-location.ts | 2 +- src/features/communityRecipes/store.ts | 2 +- src/features/todos/store.js | 2 +- src/features/utils/FeatureStore.js | 2 +- src/features/workspaces/actions.ts | 6 ++---- src/features/workspaces/components/WorkspaceDrawer.js | 2 +- src/features/workspaces/store.js | 4 ++-- src/helpers/array-helpers.ts | 11 ++++++----- src/helpers/async-helpers.ts | 2 +- src/helpers/routing-helpers.ts | 5 +++-- src/i18n/translations.ts | 2 +- src/index.ts | 4 ++-- src/lib/Menu.js | 2 +- src/stores/AppStore.ts | 4 ++-- src/stores/RecipesStore.ts | 2 +- src/stores/ServicesStore.ts | 2 +- src/themes/IStyleTypes.ts | 2 +- src/themes/default/index.ts | 2 +- src/webview/badge.ts | 2 +- src/webview/dialogTitle.ts | 2 +- src/webview/recipe.js | 6 +++--- src/webview/sessionHandler.ts | 2 +- test/features/utils/FeatureStore.test.js | 2 +- test/helpers/array-helpers.test.ts | 2 +- 32 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/I18n.tsx b/src/I18n.tsx index b486758c3..5f725eebc 100644 --- a/src/I18n.tsx +++ b/src/I18n.tsx @@ -2,7 +2,7 @@ import { Component, ReactNode } from 'react'; import { inject, observer } from 'mobx-react'; import { IntlProvider } from 'react-intl'; -import { generatedTranslations } from './i18n/translations'; +import generatedTranslations from './i18n/translations'; import UserStore from './stores/UserStore'; import AppStore from './stores/AppStore'; diff --git a/src/api/apiBase.ts b/src/api/apiBase.ts index d7cc9b810..c6e3c0ed8 100644 --- a/src/api/apiBase.ts +++ b/src/api/apiBase.ts @@ -13,7 +13,7 @@ import { import { fixUrl } from '../helpers/url-helpers'; // Note: This cannot be used from the internal-server since we are not running within the context of a browser window -const apiBase = (withVersion = true) => { +export default function apiBase(withVersion = true) { if ( !(window as any).ferdium || !(window as any).ferdium.stores.settings || @@ -33,8 +33,6 @@ const apiBase = (withVersion = true) => { return fixUrl(withVersion ? `${url}/${API_VERSION}` : url); }; -export default apiBase; - export function serverBase() { const serverType = (window as any).ferdium.stores.settings.all.app.server; diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index 935d7de3d..a636f3e0d 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts @@ -19,7 +19,7 @@ import RecipePreviewModel from '../../models/RecipePreview'; import RecipeModel from '../../models/Recipe'; import UserModel from '../../models/User'; -import { sleep } from '../../helpers/async-helpers'; +import sleep from '../../helpers/async-helpers'; import { SERVER_NOT_LOADED } from '../../config'; import { userDataRecipesPath, userDataPath } from '../../environment-remote'; diff --git a/src/components/auth/Welcome.js b/src/components/auth/Welcome.js index 18b506eba..830501ac3 100644 --- a/src/components/auth/Welcome.js +++ b/src/components/auth/Welcome.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import { observer, PropTypes as MobxPropTypes, inject } from 'mobx-react'; import { defineMessages, injectIntl } from 'react-intl'; import serverlessLogin from '../../helpers/serverless-helpers'; -import { shuffleArray } from '../../helpers/array-helpers'; +import shuffleArray from '../../helpers/array-helpers'; import { serverName } from '../../api/apiBase'; import Link from '../ui/Link'; diff --git a/src/components/ui/AppLoader/index.tsx b/src/components/ui/AppLoader/index.tsx index e80371e47..caa7e381d 100644 --- a/src/components/ui/AppLoader/index.tsx +++ b/src/components/ui/AppLoader/index.tsx @@ -3,7 +3,7 @@ import classnames from 'classnames'; import injectStyle from 'react-jss'; import FullscreenLoader from '../FullscreenLoader'; -import { shuffleArray } from '../../../helpers/array-helpers'; +import shuffleArray from '../../../helpers/array-helpers'; import styles from './styles'; diff --git a/src/components/ui/Link.js b/src/components/ui/Link.js index 05d511a81..5ab19bf74 100644 --- a/src/components/ui/Link.js +++ b/src/components/ui/Link.js @@ -5,7 +5,7 @@ import { RouterStore } from 'mobx-react-router'; import classnames from 'classnames'; import { oneOrManyChildElements } from '../../prop-types'; -import { matchRoute } from '../../helpers/routing-helpers'; +import matchRoute from '../../helpers/routing-helpers'; import { openExternalUrl } from '../../helpers/url-helpers'; // Should this file be converted into the coding style similar to './toggle/index.tsx'? diff --git a/src/containers/auth/SetupAssistantScreen.tsx b/src/containers/auth/SetupAssistantScreen.tsx index f7a353f26..b286d7cac 100644 --- a/src/containers/auth/SetupAssistantScreen.tsx +++ b/src/containers/auth/SetupAssistantScreen.tsx @@ -3,7 +3,7 @@ import { Component, ReactElement } from 'react'; import { inject, observer } from 'mobx-react'; import { StoresProps } from 'src/@types/ferdium-components.types'; -import { sleep } from '../../helpers/async-helpers'; +import sleep from '../../helpers/async-helpers'; import SetupAssistant from '../../components/auth/SetupAssistant'; class SetupAssistantScreen extends Component { diff --git a/src/electron/windowUtils.ts b/src/electron/windowUtils.ts index 9c9fd1b77..3621beb2f 100644 --- a/src/electron/windowUtils.ts +++ b/src/electron/windowUtils.ts @@ -1,6 +1,6 @@ import { screen } from 'electron'; -export function isPositionValid(position: { x: number; y: number }): boolean { +export default function isPositionValid(position: { x: number; y: number }): boolean { const displays = screen.getAllDisplays(); const { x, y } = position; return displays.some( diff --git a/src/enforce-macos-app-location.ts b/src/enforce-macos-app-location.ts index 3661d08a5..222127acf 100644 --- a/src/enforce-macos-app-location.ts +++ b/src/enforce-macos-app-location.ts @@ -4,7 +4,7 @@ import { isMac } from './environment'; import { isDevMode } from './environment-remote'; import { api } from './electron-util'; -export function enforceMacOSAppLocation(): void { +export default function enforceMacOSAppLocation(): void { if (isDevMode || !isMac || api.app.isInApplicationsFolder()) { return; } diff --git a/src/features/communityRecipes/store.ts b/src/features/communityRecipes/store.ts index 73eaae8b4..34e6cd92c 100644 --- a/src/features/communityRecipes/store.ts +++ b/src/features/communityRecipes/store.ts @@ -1,5 +1,5 @@ import { computed } from 'mobx'; -import { FeatureStore } from '../utils/FeatureStore'; +import FeatureStore from '../utils/FeatureStore'; const debug = require('../../preload-safe-debug')('Ferdium:feature:communityRecipes:store'); diff --git a/src/features/todos/store.js b/src/features/todos/store.js index b5228191c..1a3d6c1e7 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js @@ -12,7 +12,7 @@ import { DEFAULT_IS_TODO_FEATURE_ENABLED_BY_USER, } from '../../config'; import { isValidExternalURL } from '../../helpers/url-helpers'; -import { FeatureStore } from '../utils/FeatureStore'; +import FeatureStore from '../utils/FeatureStore'; import { createReactions } from '../../stores/lib/Reaction'; import { createActionBindings } from '../utils/ActionBinding'; import { IPC, TODOS_ROUTES } from './constants'; diff --git a/src/features/utils/FeatureStore.js b/src/features/utils/FeatureStore.js index afe726294..eada332d7 100644 --- a/src/features/utils/FeatureStore.js +++ b/src/features/utils/FeatureStore.js @@ -1,4 +1,4 @@ -export class FeatureStore { +export default class FeatureStore { _actions = []; _reactions = []; diff --git a/src/features/workspaces/actions.ts b/src/features/workspaces/actions.ts index 5e7e6e721..b7f8b6b90 100644 --- a/src/features/workspaces/actions.ts +++ b/src/features/workspaces/actions.ts @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import Workspace from './models/Workspace'; import { createActionsFromDefinitions } from '../../actions/lib/actions'; -export const workspaceActions = createActionsFromDefinitions( +export default createActionsFromDefinitions( { edit: { workspace: PropTypes.instanceOf(Workspace).isRequired, @@ -24,7 +24,5 @@ export const workspaceActions = createActionsFromDefinitions( openWorkspaceSettings: {}, toggleKeepAllWorkspacesLoadedSetting: {}, }, - PropTypes.checkPropTypes, + PropTypes.checkPropTypes ); - -export default workspaceActions; diff --git a/src/features/workspaces/components/WorkspaceDrawer.js b/src/features/workspaces/components/WorkspaceDrawer.js index d56945296..3454fdbe9 100644 --- a/src/features/workspaces/components/WorkspaceDrawer.js +++ b/src/features/workspaces/components/WorkspaceDrawer.js @@ -10,7 +10,7 @@ import { mdiPlusBox, mdiCog } from '@mdi/js'; import { H1 } from '../../../components/ui/headline'; import Icon from '../../../components/ui/icon'; import WorkspaceDrawerItem from './WorkspaceDrawerItem'; -import { workspaceActions } from '../actions'; +import workspaceActions from '../actions'; import { workspaceStore } from '../index'; import { getUserWorkspacesRequest, diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index 20d32df67..4fdb3dd15 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js @@ -1,8 +1,8 @@ import { computed, observable, action } from 'mobx'; import localStorage from 'mobx-localstorage'; import { matchRoute } from '../../helpers/routing-helpers'; -import { workspaceActions } from './actions'; -import { FeatureStore } from '../utils/FeatureStore'; +import workspaceActions from './actions'; +import FeatureStore from '../utils/FeatureStore'; import { createWorkspaceRequest, deleteWorkspaceRequest, diff --git a/src/helpers/array-helpers.ts b/src/helpers/array-helpers.ts index 45ff932ba..5d28af433 100644 --- a/src/helpers/array-helpers.ts +++ b/src/helpers/array-helpers.ts @@ -1,5 +1,6 @@ -export const shuffleArray = (arr: any[]): any[] => - arr - .map(a => [Math.random(), a]) - .sort((a, b) => a[0] - b[0]) - .map(a => a[1]); +export default function shuffleArray(arr: any[]): any[] { + return arr + .map(a => [ Math.random(), a ]) + .sort((a, b) => a[ 0 ] - b[ 0 ]) + .map(a => a[ 1 ]) +}; diff --git a/src/helpers/async-helpers.ts b/src/helpers/async-helpers.ts index 6556a0141..de20ea080 100644 --- a/src/helpers/async-helpers.ts +++ b/src/helpers/async-helpers.ts @@ -1,4 +1,4 @@ -export function sleep(ms: number = 0): Promise { +export default function sleep(ms: number = 0): Promise { // eslint-disable-next-line no-promise-executor-return return new Promise(r => setTimeout(r, ms)); } diff --git a/src/helpers/routing-helpers.ts b/src/helpers/routing-helpers.ts index 46895aa6b..0b9a83df6 100644 --- a/src/helpers/routing-helpers.ts +++ b/src/helpers/routing-helpers.ts @@ -1,4 +1,5 @@ import RouteParser from 'route-parser'; -export const matchRoute = (pattern: string, path: string) => - new RouteParser(pattern).match(path); +export default function matchRoute(pattern: string, path: string) { + return new RouteParser(pattern).match(path); +} diff --git a/src/i18n/translations.ts b/src/i18n/translations.ts index 9b23497e1..99c6e1e80 100644 --- a/src/i18n/translations.ts +++ b/src/i18n/translations.ts @@ -1,7 +1,7 @@ /* eslint-disable global-require */ import { APP_LOCALES } from './languages'; -export const generatedTranslations = () => { +export default function generatedTranslations() { const translations = []; for (const key of Object.keys(APP_LOCALES)) { try { diff --git a/src/index.ts b/src/index.ts index 786b95a69..7ca364a2e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,7 +17,7 @@ import minimist from 'minimist'; import ms from 'ms'; import { EventEmitter } from 'events'; import { enableWebContents, initializeRemote } from './electron-util'; -import { enforceMacOSAppLocation } from './enforce-macos-app-location'; +import enforceMacOSAppLocation from './enforce-macos-app-location'; initializeRemote(); @@ -37,7 +37,7 @@ import Tray from './lib/Tray'; import DBus from './lib/DBus'; import Settings from './electron/Settings'; import handleDeepLink from './electron/deepLinking'; -import { isPositionValid } from './electron/windowUtils'; +import isPositionValid from './electron/windowUtils'; // @ts-expect-error Cannot find module './package.json' or its corresponding type declarations. import { appId } from './package.json'; import './electron/exception'; diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 7b048d3fa..49041e43e 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js @@ -35,7 +35,7 @@ import { } from '../environment'; import { ferdiumVersion } from '../environment-remote'; import { todoActions } from '../features/todos/actions'; -import { workspaceActions } from '../features/workspaces/actions'; +import workspaceActions from '../features/workspaces/actions'; import { workspaceStore } from '../features/workspaces/index'; import apiBase, { serverBase } from '../api/apiBase'; import { openExternalUrl } from '../helpers/url-helpers'; diff --git a/src/stores/AppStore.ts b/src/stores/AppStore.ts index 8c8454116..b2adb0f02 100644 --- a/src/stores/AppStore.ts +++ b/src/stores/AppStore.ts @@ -27,7 +27,7 @@ import { userDataPath, ferdiumLocale, } from '../environment-remote'; -import { generatedTranslations } from '../i18n/translations'; +import generatedTranslations from '../i18n/translations'; import { getLocale } from '../helpers/i18n-helpers'; import { @@ -35,7 +35,7 @@ import { removeServicePartitionDirectory, } from '../helpers/service-helpers'; import { openExternalUrl } from '../helpers/url-helpers'; -import { sleep } from '../helpers/async-helpers'; +import sleep from '../helpers/async-helpers'; const debug = require('../preload-safe-debug')('Ferdium:AppStore'); diff --git a/src/stores/RecipesStore.ts b/src/stores/RecipesStore.ts index 00a2bb737..6bd4ab382 100644 --- a/src/stores/RecipesStore.ts +++ b/src/stores/RecipesStore.ts @@ -8,7 +8,7 @@ import { Actions } from 'src/actions/lib/actions'; import Recipe from 'src/models/Recipe'; import CachedRequest from './lib/CachedRequest'; import Request from './lib/Request'; -import { matchRoute } from '../helpers/routing-helpers'; +import matchRoute from '../helpers/routing-helpers'; import { asarRecipesPath } from '../helpers/asar-helpers'; import TypedStore from './lib/TypedStore'; diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts index 0164d092a..e690b3791 100644 --- a/src/stores/ServicesStore.ts +++ b/src/stores/ServicesStore.ts @@ -10,7 +10,7 @@ import { ApiInterface } from 'src/api'; import { Actions } from 'src/actions/lib/actions'; import Request from './lib/Request'; import CachedRequest from './lib/CachedRequest'; -import { matchRoute } from '../helpers/routing-helpers'; +import matchRoute from '../helpers/routing-helpers'; import { isInTimeframe } from '../helpers/schedule-helpers'; import { getRecipeDirectory, diff --git a/src/themes/IStyleTypes.ts b/src/themes/IStyleTypes.ts index 48f52daf2..cf8bdea33 100644 --- a/src/themes/IStyleTypes.ts +++ b/src/themes/IStyleTypes.ts @@ -1,4 +1,4 @@ -export interface IStyleTypes { +export default interface IStyleTypes { [index: string]: { accent: string; contrast: string; diff --git a/src/themes/default/index.ts b/src/themes/default/index.ts index 9e442f60e..2e18e1307 100644 --- a/src/themes/default/index.ts +++ b/src/themes/default/index.ts @@ -2,7 +2,7 @@ import color from 'color'; import { cloneDeep } from 'lodash'; import * as legacyStyles from '../legacy'; -import type { IStyleTypes } from '../IStyleTypes'; +import type IStyleTypes from '../IStyleTypes'; export default (brandPrimary: string) => { if (!brandPrimary) { diff --git a/src/webview/badge.ts b/src/webview/badge.ts index 898f8cdcf..afecd22d4 100644 --- a/src/webview/badge.ts +++ b/src/webview/badge.ts @@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron'; const debug = require('../preload-safe-debug')('Ferdium:Plugin:BadgeHandler'); -export class BadgeHandler { +export default class BadgeHandler { // TODO: Need to extract this into a utility class and reuse outside of the recipes safeParseInt(text: string | number | undefined | null) { if (text === undefined || text === null) { diff --git a/src/webview/dialogTitle.ts b/src/webview/dialogTitle.ts index 12e007e26..67b4e5b6b 100644 --- a/src/webview/dialogTitle.ts +++ b/src/webview/dialogTitle.ts @@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron'; const debug = require('../preload-safe-debug')('Ferdium:Plugin:DialogTitleHandler'); -export class DialogTitleHandler { +export default class DialogTitleHandler { titleCache: { title: string }; constructor() { diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 9d5a97767..3c8a5326f 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -23,9 +23,9 @@ import customDarkModeCss from './darkmode/custom'; import RecipeWebview from './lib/RecipeWebview'; import Userscript from './lib/Userscript'; -import { BadgeHandler } from './badge'; -import { DialogTitleHandler } from './dialogTitle'; -import { SessionHandler } from './sessionHandler'; +import BadgeHandler from './badge'; +import DialogTitleHandler from './dialogTitle'; +import SessionHandler from './sessionHandler'; import contextMenu from './contextMenu'; import { darkModeStyleExists, diff --git a/src/webview/sessionHandler.ts b/src/webview/sessionHandler.ts index 00eacdf50..8949f5d2d 100644 --- a/src/webview/sessionHandler.ts +++ b/src/webview/sessionHandler.ts @@ -1,6 +1,6 @@ const debug = require('../preload-safe-debug')('Ferdium:Plugin:SessionHandler'); -export class SessionHandler { +export default class SessionHandler { async releaseServiceWorkers() { try { const registrations = diff --git a/test/features/utils/FeatureStore.test.js b/test/features/utils/FeatureStore.test.js index d8d85bec1..3ef8116d9 100644 --- a/test/features/utils/FeatureStore.test.js +++ b/test/features/utils/FeatureStore.test.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import { observable } from 'mobx'; -import { FeatureStore } from '../../../src/features/utils/FeatureStore'; +import FeatureStore from '../../../src/features/utils/FeatureStore'; import { createActionsFromDefinitions } from '../../../src/actions/lib/actions'; import { createActionBindings } from '../../../src/features/utils/ActionBinding'; import { createReactions } from '../../../src/stores/lib/Reaction'; diff --git a/test/helpers/array-helpers.test.ts b/test/helpers/array-helpers.test.ts index cbb7822e9..ee94bac80 100644 --- a/test/helpers/array-helpers.test.ts +++ b/test/helpers/array-helpers.test.ts @@ -1,4 +1,4 @@ -import { shuffleArray } from '../../src/helpers/array-helpers'; +import shuffleArray from '../../src/helpers/array-helpers'; describe('array_helpers', () => { it('isValidExternalURL', () => { -- cgit v1.2.3-54-g00ecf