From 1edcf22af850519116ec20a9469eb292b5f13160 Mon Sep 17 00:00:00 2001 From: Nicola Molinari Date: Tue, 28 Apr 2020 13:47:57 +0200 Subject: [PATCH] refactor: use TS "import type" (#1443) * refactor(actions-global): use import type for TS type imports * refactor(sentry): use import type for TS type imports * refactor(sdk): use import type for TS type imports * refactor(react-notifications): use import type for TS type imports * refactor(notifications): use import type for TS type imports * refactor(l10n): use import type for TS type imports * refactor(i18n): use import type for TS type imports * refactor(browser-history): use import type for TS type imports * refactor(application-shell-connectors): use import type for TS type imports * refactor(application-shell): use import type for TS type imports * refactor(application-components): use import type for TS type imports --- packages/actions-global/README.md | 2 +- .../src/actions/handle-action-error.spec.ts | 3 +- .../src/actions/handle-action-error.ts | 11 ++++--- .../actions/show-api-error-notification.ts | 6 +++- .../src/actions/show-notification.ts | 9 +++--- .../show-unexpected-error-notification.ts | 9 +++--- .../src/hooks/use-on-action-error.spec.tsx | 3 +- .../src/hooks/use-on-action-error.ts | 4 ++- .../hooks/use-show-api-error-notification.ts | 3 +- .../src/hooks/use-show-notification.ts | 5 +-- .../use-show-unexpected-error-notification.ts | 3 +- packages/actions-global/src/index.ts | 2 +- packages/actions-global/src/types.ts | 4 +-- .../dialogs/internals/dialog-footer.tsx | 4 ++- .../dialogs/internals/dialog-header.tsx | 2 +- .../maintenance-page-layout.spec.tsx | 4 ++- .../application-context.spec.tsx | 3 +- .../application-context.tsx | 11 ++++--- .../components/application-context/index.ts | 2 +- .../application-context/normalizers.spec.ts | 3 +- .../application-context/normalizers.ts | 2 +- .../project-extension-image-regex.spec.tsx | 16 ++++------ .../project-extension-image-regex.tsx | 9 +++--- .../application-shell-connectors/src/index.ts | 2 +- .../src/test-utils/test-utils.ts | 5 +-- .../utils/get-mc-api-url/get-mc-api-url.ts | 2 +- .../src/apollo-links/error-link.ts | 8 +++-- .../src/apollo-links/header-link.ts | 2 +- .../src/components/app-bar/app-bar.tsx | 5 +-- .../application-shell-provider.tsx | 15 ++++----- .../application-shell/application-shell.tsx | 26 +++++++-------- .../authenticated/am-i-logged-in.tsx | 9 +++--- .../authenticated/authenticated.spec.tsx | 4 ++- .../configure-intl-provider.tsx | 4 ++- .../error-boundary/error-boundary.tsx | 4 ++- .../fetch-project/fetch-project.tsx | 17 +++++----- .../src/components/fetch-user/fetch-user.tsx | 17 +++++----- .../components/gtm-booter/gtm-booter.spec.tsx | 6 ++-- .../gtm-user-tracker/gtm-user-tracker.tsx | 3 +- .../handle-apollo-errors.tsx | 3 +- .../inject-reducers/inject-reducers.tsx | 5 +-- .../src/components/navbar/navbar.tsx | 32 ++++++++----------- .../navbar/use-navbar-state-manager.ts | 16 ++++++---- .../project-container/project-container.tsx | 12 +++---- .../project-switcher/project-switcher.tsx | 13 ++++---- .../butler-command/butler-command.tsx | 6 ++-- .../components/quick-access/butler/butler.tsx | 18 ++++++----- .../quick-access/create-commands.ts | 8 +++-- .../quick-access/history-entries.ts | 2 +- .../components/quick-access/quick-access.tsx | 6 ++-- .../components/quick-access/sub-commands.ts | 16 ++++++---- .../src/components/quick-access/types.ts | 6 ++-- .../src/components/quick-access/utils.ts | 4 +-- .../src/components/redirector/redirector.tsx | 5 +-- .../requests-in-flight-loader/reducer.spec.ts | 11 ++++--- .../requests-in-flight-loader/reducer.ts | 9 +++--- .../requests-in-flight-loader.tsx | 3 +- .../requests-in-flight-loader/types.ts | 2 +- .../setup-flop-flip-provider.tsx | 5 +-- .../user-settings-menu/user-settings-menu.tsx | 17 +++++----- .../src/components/version-tracker/actions.ts | 4 ++- .../application-shell/src/configure-apollo.ts | 5 +-- .../application-shell/src/configure-store.ts | 15 +++------ .../use-all-menu-feature-toggles.ts | 9 +++--- .../use-applications-menu.spec.tsx | 14 ++++---- .../use-applications-menu.ts | 10 +++--- .../src/middleware/hide-notifications.ts | 13 ++++---- .../src/middleware/logger.ts | 3 +- .../src/test-utils/test-utils.spec.tsx | 8 ++--- .../src/test-utils/test-utils.tsx | 23 ++++++------- .../src/track-performance.ts | 4 ++- packages/application-shell/src/utils/gtm.ts | 3 +- .../utils/select-user-id/select-user-id.ts | 5 +-- packages/browser-history/src/index.ts | 2 +- .../async-locale-data.spec.tsx | 8 ++--- packages/i18n/src/index.ts | 2 +- packages/l10n/src/country-information.ts | 3 +- packages/l10n/src/currency-information.ts | 3 +- packages/l10n/src/language-information.ts | 3 +- packages/l10n/src/time-zone-information.ts | 3 +- packages/l10n/src/utils.ts | 2 +- packages/notifications/src/action-creators.ts | 3 +- packages/notifications/src/middleware.ts | 5 +-- .../notifications/src/notifications.spec.ts | 3 +- packages/notifications/src/reducer.ts | 3 +- packages/notifications/src/types.ts | 3 +- .../map-notification-to-component/index.ts | 2 +- .../map-notification-to-component.tsx | 5 +-- .../api-error-message/api-error-message.tsx | 6 ++-- .../api-error/api-error.tsx | 7 ++-- .../notification-kinds/generic/generic.tsx | 5 +-- .../unexpected-error/unexpected-error.tsx | 7 ++-- .../notification/notification.spec.tsx | 7 ++-- .../notification/notification.styles.ts | 7 ++-- .../components/notification/notification.tsx | 7 ++-- .../notifications-list.spec.tsx | 4 ++- .../notifications-list.styles.ts | 7 ++-- .../notifications-list/notifications-list.tsx | 15 +++++---- .../notifications-list/selectors.ts | 9 +++--- .../components/notifications-list/types.ts | 2 +- .../src/components/notifier/notifier.spec.tsx | 21 ++++-------- .../src/components/notifier/notifier.tsx | 7 ++-- packages/react-notifications/src/index.ts | 2 +- packages/sdk/src/actions/actions.ts | 2 +- .../src/components/sdk-get/sdk-get.spec.tsx | 9 ++++-- .../sdk/src/components/sdk-get/sdk-get.tsx | 7 ++-- packages/sdk/src/hooks/use-async-dispatch.ts | 5 +-- packages/sdk/src/middleware/client.ts | 7 ++-- .../sdk/src/middleware/middleware.spec.ts | 5 +-- packages/sdk/src/middleware/middleware.ts | 15 +++++---- .../sdk/src/test-utils/test-utils.spec.ts | 3 +- packages/sdk/src/test-utils/test-utils.ts | 7 ++-- packages/sdk/src/types.ts | 2 +- packages/sdk/src/utils/utils.spec.ts | 4 ++- packages/sdk/src/utils/utils.ts | 3 +- .../sentry-user-logout-tracker.tsx | 3 +- .../sentry-user-tracker.spec.tsx | 3 +- .../sentry-user-tracker.tsx | 3 +- packages/sentry/src/sentry.ts | 3 +- 119 files changed, 448 insertions(+), 360 deletions(-) diff --git a/packages/actions-global/README.md b/packages/actions-global/README.md index 3c6627b691..7ef231e1e3 100644 --- a/packages/actions-global/README.md +++ b/packages/actions-global/README.md @@ -4,7 +4,7 @@ Latest release (latest dist-tag) Latest release (next dist-tag) Minified + GZipped size GitHub license

-Global redux actions for a MC application. +Global redux actions for a Custom Application. ## Install diff --git a/packages/actions-global/src/actions/handle-action-error.spec.ts b/packages/actions-global/src/actions/handle-action-error.spec.ts index 61cd1d07d5..5368191d70 100644 --- a/packages/actions-global/src/actions/handle-action-error.spec.ts +++ b/packages/actions-global/src/actions/handle-action-error.spec.ts @@ -1,4 +1,5 @@ -import { TStatusCode } from '@commercetools-frontend/constants'; +import type { TStatusCode } from '@commercetools-frontend/constants'; + import handleActionError from './handle-action-error'; let dispatch: jest.Mock; diff --git a/packages/actions-global/src/actions/handle-action-error.ts b/packages/actions-global/src/actions/handle-action-error.ts index 2e52eb64c9..3ee8758935 100644 --- a/packages/actions-global/src/actions/handle-action-error.ts +++ b/packages/actions-global/src/actions/handle-action-error.ts @@ -1,11 +1,14 @@ -import { ThunkDispatch } from 'redux-thunk'; -import { - STATUS_CODES, - LOGOUT_REASONS, +import type { ThunkDispatch } from 'redux-thunk'; +import type { TAppNotificationApiError, TStatusCode, ApplicationWindow, } from '@commercetools-frontend/constants'; + +import { + STATUS_CODES, + LOGOUT_REASONS, +} from '@commercetools-frontend/constants'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import browserHistory from '@commercetools-frontend/browser-history'; import showApiErrorNotification from './show-api-error-notification'; diff --git a/packages/actions-global/src/actions/show-api-error-notification.ts b/packages/actions-global/src/actions/show-api-error-notification.ts index 0401137468..4ba1fe95ef 100644 --- a/packages/actions-global/src/actions/show-api-error-notification.ts +++ b/packages/actions-global/src/actions/show-api-error-notification.ts @@ -1,5 +1,9 @@ +import type { + TApiErrorNotification, + TApiErrorNotificationOptions, +} from '../types'; + import { DOMAINS } from '@commercetools-frontend/constants'; -import { TApiErrorNotification, TApiErrorNotificationOptions } from '../types'; import showNotification from './show-notification'; export default function showApiErrorNotification({ diff --git a/packages/actions-global/src/actions/show-notification.ts b/packages/actions-global/src/actions/show-notification.ts index d5932203ba..d3b54227a7 100644 --- a/packages/actions-global/src/actions/show-notification.ts +++ b/packages/actions-global/src/actions/show-notification.ts @@ -1,13 +1,12 @@ +import type { TNotificationMetaOptions } from '@commercetools-frontend/notifications'; +import type { TShowNotification } from '../types'; + import isNumber from 'lodash/isNumber'; -import { - addNotification, - TNotificationMetaOptions, -} from '@commercetools-frontend/notifications'; +import { addNotification } from '@commercetools-frontend/notifications'; import { NOTIFICATION_DOMAINS, NOTIFICATION_KINDS_SIDE, } from '@commercetools-frontend/constants'; -import { TShowNotification } from '../types'; export default function showNotification< Notification extends TShowNotification diff --git a/packages/actions-global/src/actions/show-unexpected-error-notification.ts b/packages/actions-global/src/actions/show-unexpected-error-notification.ts index 12b081268f..b6a99f7fb2 100644 --- a/packages/actions-global/src/actions/show-unexpected-error-notification.ts +++ b/packages/actions-global/src/actions/show-unexpected-error-notification.ts @@ -1,8 +1,7 @@ -import { - DOMAINS, - TAppNotificationValuesUnexpectedError, -} from '@commercetools-frontend/constants'; -import { TUnexpectedErrorNotification } from '../types'; +import type { TAppNotificationValuesUnexpectedError } from '@commercetools-frontend/constants'; +import type { TUnexpectedErrorNotification } from '../types'; + +import { DOMAINS } from '@commercetools-frontend/constants'; import showNotification from './show-notification'; export default function showUnexpectedErrorNotification({ diff --git a/packages/actions-global/src/hooks/use-on-action-error.spec.tsx b/packages/actions-global/src/hooks/use-on-action-error.spec.tsx index b8dea1b573..5f2de451bd 100644 --- a/packages/actions-global/src/hooks/use-on-action-error.spec.tsx +++ b/packages/actions-global/src/hooks/use-on-action-error.spec.tsx @@ -1,5 +1,6 @@ +import type { Action } from 'redux'; + import React from 'react'; -import { Action } from 'redux'; import { Provider } from 'react-redux'; import { renderHook } from '@testing-library/react-hooks'; import useOnActionError from './use-on-action-error'; diff --git a/packages/actions-global/src/hooks/use-on-action-error.ts b/packages/actions-global/src/hooks/use-on-action-error.ts index 0ea32d4d45..6f6f7c927e 100644 --- a/packages/actions-global/src/hooks/use-on-action-error.ts +++ b/packages/actions-global/src/hooks/use-on-action-error.ts @@ -1,6 +1,8 @@ +import type { ActionError } from '../actions/handle-action-error'; + import React from 'react'; import { useDispatch } from 'react-redux'; -import handleActionError, { ActionError } from '../actions/handle-action-error'; +import handleActionError from '../actions/handle-action-error'; export default function useOnActionError() { const dispatch = useDispatch(); diff --git a/packages/actions-global/src/hooks/use-show-api-error-notification.ts b/packages/actions-global/src/hooks/use-show-api-error-notification.ts index f587b1551c..414941aff6 100644 --- a/packages/actions-global/src/hooks/use-show-api-error-notification.ts +++ b/packages/actions-global/src/hooks/use-show-api-error-notification.ts @@ -1,7 +1,8 @@ +import type { TApiErrorNotificationOptions } from '../types'; + import React from 'react'; import { useDispatch } from 'react-redux'; import { showApiErrorNotification } from '../actions'; -import { TApiErrorNotificationOptions } from '../types'; // Returns a function that dispatches an API error notification. // Example: diff --git a/packages/actions-global/src/hooks/use-show-notification.ts b/packages/actions-global/src/hooks/use-show-notification.ts index e044398da9..91ec26bf3e 100644 --- a/packages/actions-global/src/hooks/use-show-notification.ts +++ b/packages/actions-global/src/hooks/use-show-notification.ts @@ -1,8 +1,9 @@ +import type { TNotificationMetaOptions } from '@commercetools-frontend/notifications'; +import type { TShowNotification } from '../types'; + import React from 'react'; import { useDispatch } from 'react-redux'; -import { TNotificationMetaOptions } from '@commercetools-frontend/notifications'; import { showNotification } from '../actions'; -import { TShowNotification } from '../types'; // Returns a function that dispatches a notification, pre-configured to // a speficic notification. diff --git a/packages/actions-global/src/hooks/use-show-unexpected-error-notification.ts b/packages/actions-global/src/hooks/use-show-unexpected-error-notification.ts index dff736a8cf..ea95c496a3 100644 --- a/packages/actions-global/src/hooks/use-show-unexpected-error-notification.ts +++ b/packages/actions-global/src/hooks/use-show-unexpected-error-notification.ts @@ -1,6 +1,7 @@ +import type { TAppNotificationValuesUnexpectedError } from '@commercetools-frontend/constants'; + import React from 'react'; import { useDispatch } from 'react-redux'; -import { TAppNotificationValuesUnexpectedError } from '@commercetools-frontend/constants'; import { showUnexpectedErrorNotification } from '../actions'; // Returns a function that dispatches an unexpected error notification. diff --git a/packages/actions-global/src/index.ts b/packages/actions-global/src/index.ts index ab4fef1aff..1c8f69397d 100644 --- a/packages/actions-global/src/index.ts +++ b/packages/actions-global/src/index.ts @@ -1,5 +1,5 @@ export { default as version } from './version'; -import { DispatchActionError } from './actions/handle-action-error'; +import type { DispatchActionError } from './actions/handle-action-error'; export type TDispatchActionError = DispatchActionError; diff --git a/packages/actions-global/src/types.ts b/packages/actions-global/src/types.ts index 57e1602357..976d3c340d 100644 --- a/packages/actions-global/src/types.ts +++ b/packages/actions-global/src/types.ts @@ -1,5 +1,5 @@ -import { TNotification } from '@commercetools-frontend/notifications'; -import { +import type { TNotification } from '@commercetools-frontend/notifications'; +import type { TAppNotification, TAppNotificationDomain, TAppNotificationKind, diff --git a/packages/application-components/src/components/dialogs/internals/dialog-footer.tsx b/packages/application-components/src/components/dialogs/internals/dialog-footer.tsx index 6840cd06b5..a11522e3c2 100644 --- a/packages/application-components/src/components/dialogs/internals/dialog-footer.tsx +++ b/packages/application-components/src/components/dialogs/internals/dialog-footer.tsx @@ -1,5 +1,7 @@ +import type { IntlShape } from 'react-intl'; + import React from 'react'; -import { useIntl, IntlShape } from 'react-intl'; +import { useIntl } from 'react-intl'; import SecondaryButton from '@commercetools-uikit/secondary-button'; import PrimaryButton from '@commercetools-uikit/primary-button'; import Spacings from '@commercetools-uikit/spacings'; diff --git a/packages/application-components/src/components/dialogs/internals/dialog-header.tsx b/packages/application-components/src/components/dialogs/internals/dialog-header.tsx index 23bc1a7cf5..1ae7b2495b 100644 --- a/packages/application-components/src/components/dialogs/internals/dialog-header.tsx +++ b/packages/application-components/src/components/dialogs/internals/dialog-header.tsx @@ -1,9 +1,9 @@ import React from 'react'; +import { css } from '@emotion/core'; import { CloseIcon } from '@commercetools-uikit/icons'; import SecondaryIconButton from '@commercetools-uikit/secondary-icon-button'; import Text from '@commercetools-uikit/text'; import Spacings from '@commercetools-uikit/spacings'; -import { css } from '@emotion/core'; type Props = { title: string; diff --git a/packages/application-components/src/components/maintenance-page-layout/maintenance-page-layout.spec.tsx b/packages/application-components/src/components/maintenance-page-layout/maintenance-page-layout.spec.tsx index a441bf46d0..bed64b78ed 100644 --- a/packages/application-components/src/components/maintenance-page-layout/maintenance-page-layout.spec.tsx +++ b/packages/application-components/src/components/maintenance-page-layout/maintenance-page-layout.spec.tsx @@ -1,6 +1,8 @@ +import type { Props } from './maintenance-page-layout'; + import React from 'react'; import { renderComponent } from '../../../test-utils'; -import MaintenancePageLayout, { Props } from './maintenance-page-layout'; +import MaintenancePageLayout from './maintenance-page-layout'; const createTestProps = (props: Partial = {}) => ({ imageSrc: '/assets/foo.svg', diff --git a/packages/application-shell-connectors/src/components/application-context/application-context.spec.tsx b/packages/application-shell-connectors/src/components/application-context/application-context.spec.tsx index c12342ce16..8768943b88 100644 --- a/packages/application-shell-connectors/src/components/application-context/application-context.spec.tsx +++ b/packages/application-shell-connectors/src/components/application-context/application-context.spec.tsx @@ -1,3 +1,5 @@ +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import React from 'react'; import { render } from '@testing-library/react'; import { @@ -9,7 +11,6 @@ import { mapProjectToApplicationContextProject, mapEnvironmentToApplicationContextEnvironment, } from './application-context'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; type AdditionalEnvironmentProps = { foo: string }; diff --git a/packages/application-shell-connectors/src/components/application-context/application-context.tsx b/packages/application-shell-connectors/src/components/application-context/application-context.tsx index ebb5971b48..171458da00 100644 --- a/packages/application-shell-connectors/src/components/application-context/application-context.tsx +++ b/packages/application-shell-connectors/src/components/application-context/application-context.tsx @@ -1,11 +1,12 @@ -import React from 'react'; -import moment from 'moment-timezone'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; -import getDisplayName from '../../utils/get-display-name'; -import { +import type { ApplicationWindow } from '@commercetools-frontend/constants'; +import type { TFetchLoggedInUserQuery, TFetchProjectQuery, } from '../../types/generated/mc'; + +import React from 'react'; +import moment from 'moment-timezone'; +import getDisplayName from '../../utils/get-display-name'; import { normalizeAllAppliedActionRights, normalizeAllAppliedMenuVisibilities, diff --git a/packages/application-shell-connectors/src/components/application-context/index.ts b/packages/application-shell-connectors/src/components/application-context/index.ts index 695d00949f..1e424b472a 100644 --- a/packages/application-shell-connectors/src/components/application-context/index.ts +++ b/packages/application-shell-connectors/src/components/application-context/index.ts @@ -1,4 +1,4 @@ -import { +import type { ProviderProps, TApplicationContext as ApplicationContext, } from './application-context'; diff --git a/packages/application-shell-connectors/src/components/application-context/normalizers.spec.ts b/packages/application-shell-connectors/src/components/application-context/normalizers.spec.ts index 147825826f..92e6070168 100644 --- a/packages/application-shell-connectors/src/components/application-context/normalizers.spec.ts +++ b/packages/application-shell-connectors/src/components/application-context/normalizers.spec.ts @@ -1,4 +1,5 @@ -import { TFetchProjectQuery } from '../../types/generated/mc'; +import type { TFetchProjectQuery } from '../../types/generated/mc'; + import { normalizeAllAppliedActionRights, normalizeAllAppliedMenuVisibilities, diff --git a/packages/application-shell-connectors/src/components/application-context/normalizers.ts b/packages/application-shell-connectors/src/components/application-context/normalizers.ts index 02b67b2386..d0f52fe55c 100644 --- a/packages/application-shell-connectors/src/components/application-context/normalizers.ts +++ b/packages/application-shell-connectors/src/components/application-context/normalizers.ts @@ -1,4 +1,4 @@ -import { +import type { Maybe, TFetchProjectQuery, TStoreDataFence, diff --git a/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.spec.tsx b/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.spec.tsx index 4ec931d437..2795d4c077 100644 --- a/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.spec.tsx +++ b/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.spec.tsx @@ -1,17 +1,13 @@ +import type { RenderResult } from '@testing-library/react'; +import type { MockedProviderProps } from '@apollo/react-testing'; +import type { TImageRegexContext } from './project-extension-image-regex'; + import React from 'react'; -import { - render, - RenderResult, - waitForElementToBeRemoved, -} from '@testing-library/react'; -import { - MockedProvider as ApolloMockProvider, - MockedProviderProps, -} from '@apollo/react-testing'; +import { render, waitForElementToBeRemoved } from '@testing-library/react'; +import { MockedProvider as ApolloMockProvider } from '@apollo/react-testing'; import { ProjectExtensionProviderForImageRegex, GetProjectExtensionImageRegex, - TImageRegexContext, } from './project-extension-image-regex'; import FetchProjectExtensionImageRegex from './fetch-project-extension-image-regex.settings.graphql'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; diff --git a/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.tsx b/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.tsx index 7369bc57a1..a96cc15961 100644 --- a/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.tsx +++ b/packages/application-shell-connectors/src/components/project-extension-image-regex/project-extension-image-regex.tsx @@ -1,11 +1,12 @@ +import type { + TFetchProjectExtensionImageRegexQuery, + TImageRegexOptions, +} from '../../types/generated/settings'; + import React from 'react'; import { useQuery } from 'react-apollo'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { - TFetchProjectExtensionImageRegexQuery, - TImageRegexOptions, -} from '../../types/generated/settings'; import getDisplayName from '../../utils/get-display-name'; import FetchProjectExtensionImageRegex from './fetch-project-extension-image-regex.settings.graphql'; diff --git a/packages/application-shell-connectors/src/index.ts b/packages/application-shell-connectors/src/index.ts index 6d2ce8f36a..b8985ef2f8 100644 --- a/packages/application-shell-connectors/src/index.ts +++ b/packages/application-shell-connectors/src/index.ts @@ -1,5 +1,5 @@ export { default as version } from './version'; -import { +import type { TProviderProps as ProviderProps, TApplicationContext as ApplicationContext, } from './components/application-context'; diff --git a/packages/application-shell-connectors/src/test-utils/test-utils.ts b/packages/application-shell-connectors/src/test-utils/test-utils.ts index b103241f80..f177ff9790 100644 --- a/packages/application-shell-connectors/src/test-utils/test-utils.ts +++ b/packages/application-shell-connectors/src/test-utils/test-utils.ts @@ -1,8 +1,9 @@ -import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; -import { +import type { Maybe, TFetchProjectExtensionImageRegexQuery, } from '../types/generated/settings'; + +import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; import { FetchProjectExtensionImageRegex } from '../components/project-extension-image-regex/fetch-project-extension-image-regex.settings.graphql'; export const createGraphqlResponseForProjectExtensionImageRegexQuery = ( diff --git a/packages/application-shell-connectors/src/utils/get-mc-api-url/get-mc-api-url.ts b/packages/application-shell-connectors/src/utils/get-mc-api-url/get-mc-api-url.ts index b52f5aae57..ca10899180 100644 --- a/packages/application-shell-connectors/src/utils/get-mc-api-url/get-mc-api-url.ts +++ b/packages/application-shell-connectors/src/utils/get-mc-api-url/get-mc-api-url.ts @@ -1,4 +1,4 @@ -import { ApplicationWindow } from '@commercetools-frontend/constants'; +import type { ApplicationWindow } from '@commercetools-frontend/constants'; /** * NOTE: diff --git a/packages/application-shell/src/apollo-links/error-link.ts b/packages/application-shell/src/apollo-links/error-link.ts index 84eb686fbb..38715c2398 100644 --- a/packages/application-shell/src/apollo-links/error-link.ts +++ b/packages/application-shell/src/apollo-links/error-link.ts @@ -1,6 +1,8 @@ -import { GraphQLError } from 'graphql'; -import { onError, ErrorResponse } from 'apollo-link-error'; -import { ServerError, ServerParseError } from 'apollo-link-http-common'; +import type { GraphQLError } from 'graphql'; +import type { ErrorResponse } from 'apollo-link-error'; +import type { ServerError, ServerParseError } from 'apollo-link-http-common'; + +import { onError } from 'apollo-link-error'; import { STATUS_CODES, LOGOUT_REASONS, diff --git a/packages/application-shell/src/apollo-links/header-link.ts b/packages/application-shell/src/apollo-links/header-link.ts index 572d8ce1fc..056057b5d2 100644 --- a/packages/application-shell/src/apollo-links/header-link.ts +++ b/packages/application-shell/src/apollo-links/header-link.ts @@ -1,7 +1,7 @@ +import type { NormalizedCacheObject } from 'apollo-cache-inmemory'; import type { TApolloContext } from '../utils/apollo-context'; import ApolloClient from 'apollo-client'; -import { NormalizedCacheObject } from 'apollo-cache-inmemory'; import { ApolloLink } from 'apollo-link'; import omitEmpty from 'omit-empty-es'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; diff --git a/packages/application-shell/src/components/app-bar/app-bar.tsx b/packages/application-shell/src/components/app-bar/app-bar.tsx index 562e2fcc5d..22c7a26eb0 100644 --- a/packages/application-shell/src/components/app-bar/app-bar.tsx +++ b/packages/application-shell/src/components/app-bar/app-bar.tsx @@ -1,3 +1,6 @@ +import type { TFetchLoggedInUserQuery } from '../../types/generated/mc'; +import type { TApplicationsMenu } from '../../types/generated/proxy'; + import React from 'react'; import { Link } from 'react-router-dom'; import { css } from '@emotion/core'; @@ -6,8 +9,6 @@ import { customProperties } from '@commercetools-uikit/design-system'; import LogoSVG from '@commercetools-frontend/assets/images/logo.svg'; import { CONTAINERS } from '../../constants'; import { getPreviousProjectKey } from '../../utils'; -import { TFetchLoggedInUserQuery } from '../../types/generated/mc'; -import { TApplicationsMenu } from '../../types/generated/proxy'; import UserSettingsMenu from '../user-settings-menu'; import ProjectSwitcher from '../project-switcher'; import BackToProject from '../back-to-project'; diff --git a/packages/application-shell/src/components/application-shell-provider/application-shell-provider.tsx b/packages/application-shell/src/components/application-shell-provider/application-shell-provider.tsx index e3d4bc3d7a..6be8ee0798 100644 --- a/packages/application-shell/src/components/application-shell-provider/application-shell-provider.tsx +++ b/packages/application-shell/src/components/application-shell-provider/application-shell-provider.tsx @@ -1,3 +1,7 @@ +import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import type { TAsyncLocaleDataProps } from '@commercetools-frontend/i18n'; +import type { TrackingWhitelist } from '../../utils/gtm'; + import './global-style-imports'; import '../../track-performance'; import React from 'react'; @@ -5,15 +9,8 @@ import { Router } from 'react-router-dom'; import { ApolloProvider } from 'react-apollo'; import { Provider as ReduxProvider } from 'react-redux'; import history from '@commercetools-frontend/browser-history'; -import { - ApplicationContextProvider, - TApplicationContext, -} from '@commercetools-frontend/application-shell-connectors'; -import { - AsyncLocaleData, - TAsyncLocaleDataProps, -} from '@commercetools-frontend/i18n'; -import { TrackingWhitelist } from '../../utils/gtm'; +import { ApplicationContextProvider } from '@commercetools-frontend/application-shell-connectors'; +import { AsyncLocaleData } from '@commercetools-frontend/i18n'; import internalReduxStore from '../../configure-store'; import apolloClient from '../../configure-apollo'; import ConfigureIntlProvider from '../configure-intl-provider'; diff --git a/packages/application-shell/src/components/application-shell/application-shell.tsx b/packages/application-shell/src/components/application-shell/application-shell.tsx index bd8c6afc17..ae7e2848f5 100644 --- a/packages/application-shell/src/components/application-shell/application-shell.tsx +++ b/packages/application-shell/src/components/application-shell/application-shell.tsx @@ -1,8 +1,14 @@ -import React, { SyntheticEvent } from 'react'; -import { Dispatch } from 'redux'; +import type { SyntheticEvent } from 'react'; +import type { Dispatch } from 'redux'; +import type { TFlags } from '@flopflip/types'; +import type { ApolloError } from 'apollo-client'; +import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import type { TAsyncLocaleDataProps } from '@commercetools-frontend/i18n'; +import type { TApplicationsMenu } from '../../types/generated/proxy'; +import type { TrackingWhitelist } from '../../utils/gtm'; + +import React from 'react'; import { Redirect, Route, Switch, useLocation } from 'react-router-dom'; -import { ApolloError } from 'apollo-client'; -import { TFlags } from '@flopflip/types'; import { Global, css } from '@emotion/core'; import styled from '@emotion/styled'; import { @@ -14,17 +20,9 @@ import { reportErrorToSentry, SentryUserTracker, } from '@commercetools-frontend/sentry'; -import { - ApplicationContextProvider, - TApplicationContext, -} from '@commercetools-frontend/application-shell-connectors'; +import { ApplicationContextProvider } from '@commercetools-frontend/application-shell-connectors'; import { NotificationsList } from '@commercetools-frontend/react-notifications'; -import { - AsyncLocaleData, - TAsyncLocaleDataProps, -} from '@commercetools-frontend/i18n'; -import { TApplicationsMenu } from '../../types/generated/proxy'; -import { TrackingWhitelist } from '../../utils/gtm'; +import { AsyncLocaleData } from '@commercetools-frontend/i18n'; import internalReduxStore from '../../configure-store'; import ProjectDataLocale from '../project-data-locale'; import PortalsContainer from '../portals-container'; diff --git a/packages/application-shell/src/components/authenticated/am-i-logged-in.tsx b/packages/application-shell/src/components/authenticated/am-i-logged-in.tsx index 36fbc79c55..0f23e35c5a 100644 --- a/packages/application-shell/src/components/authenticated/am-i-logged-in.tsx +++ b/packages/application-shell/src/components/authenticated/am-i-logged-in.tsx @@ -1,11 +1,12 @@ +import type { + TAmILoggedInQuery, + TAmILoggedInQueryVariables, +} from '../../types/generated/mc'; + import React from 'react'; import { useQuery } from 'react-apollo'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; import { STORAGE_KEYS } from '../../constants'; -import { - TAmILoggedInQuery, - TAmILoggedInQueryVariables, -} from '../../types/generated/mc'; import AmILoggedInQuery from './authenticated.mc.graphql'; type RenderFnArgs = { isAuthenticated: boolean }; diff --git a/packages/application-shell/src/components/authenticated/authenticated.spec.tsx b/packages/application-shell/src/components/authenticated/authenticated.spec.tsx index c94bd7c4eb..4cdbb4996c 100644 --- a/packages/application-shell/src/components/authenticated/authenticated.spec.tsx +++ b/packages/application-shell/src/components/authenticated/authenticated.spec.tsx @@ -1,3 +1,5 @@ +import type { TProps } from './authenticated'; + import { mocked } from 'ts-jest/utils'; import React from 'react'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; @@ -5,7 +7,7 @@ import { GraphQLError } from 'graphql'; import { renderApp, waitFor } from '../../test-utils'; import { STORAGE_KEYS } from '../../constants'; import AmILoggedInQuery from './authenticated.mc.graphql'; -import Authenticated, { TProps } from './authenticated'; +import Authenticated from './authenticated'; const createTestProps = (custom: Partial = {}) => ({ render: jest.fn(() =>
), diff --git a/packages/application-shell/src/components/configure-intl-provider/configure-intl-provider.tsx b/packages/application-shell/src/components/configure-intl-provider/configure-intl-provider.tsx index 875eeb61d3..391c026a82 100644 --- a/packages/application-shell/src/components/configure-intl-provider/configure-intl-provider.tsx +++ b/packages/application-shell/src/components/configure-intl-provider/configure-intl-provider.tsx @@ -1,5 +1,7 @@ +import type { IntlConfig } from 'react-intl'; + import React from 'react'; -import { IntlProvider, IntlConfig } from 'react-intl'; +import { IntlProvider } from 'react-intl'; interface ApplicationWindow extends Window { onAppLoaded: () => void; diff --git a/packages/application-shell/src/components/error-boundary/error-boundary.tsx b/packages/application-shell/src/components/error-boundary/error-boundary.tsx index be8b77b0f9..209429b682 100644 --- a/packages/application-shell/src/components/error-boundary/error-boundary.tsx +++ b/packages/application-shell/src/components/error-boundary/error-boundary.tsx @@ -1,4 +1,6 @@ -import React, { ErrorInfo } from 'react'; +import type { ErrorInfo } from 'react'; + +import React from 'react'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import ErrorApologizer from '../error-apologizer'; diff --git a/packages/application-shell/src/components/fetch-project/fetch-project.tsx b/packages/application-shell/src/components/fetch-project/fetch-project.tsx index 847b34030b..1866adbee2 100644 --- a/packages/application-shell/src/components/fetch-project/fetch-project.tsx +++ b/packages/application-shell/src/components/fetch-project/fetch-project.tsx @@ -1,15 +1,14 @@ -import React from 'react'; -import { ApolloError } from 'apollo-client'; -import { useQuery } from 'react-apollo'; -import { - GRAPHQL_TARGETS, - TGraphQLTargets, -} from '@commercetools-frontend/constants'; -import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { +import type { ApolloError } from 'apollo-client'; +import type { TGraphQLTargets } from '@commercetools-frontend/constants'; +import type { TFetchProjectQuery, TFetchProjectQueryVariables, } from '../../types/generated/mc'; + +import React from 'react'; +import { useQuery } from 'react-apollo'; +import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; +import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import ProjectQuery from './fetch-project.mc.graphql'; type RenderFnArgs = { diff --git a/packages/application-shell/src/components/fetch-user/fetch-user.tsx b/packages/application-shell/src/components/fetch-user/fetch-user.tsx index 9d93087564..84009697de 100644 --- a/packages/application-shell/src/components/fetch-user/fetch-user.tsx +++ b/packages/application-shell/src/components/fetch-user/fetch-user.tsx @@ -1,15 +1,14 @@ -import React from 'react'; -import { ApolloError } from 'apollo-client'; -import { useQuery } from 'react-apollo'; -import { - GRAPHQL_TARGETS, - TGraphQLTargets, -} from '@commercetools-frontend/constants'; -import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { +import type { ApolloError } from 'apollo-client'; +import type { TGraphQLTargets } from '@commercetools-frontend/constants'; +import type { TFetchLoggedInUserQuery, TFetchLoggedInUserQueryVariables, } from '../../types/generated/mc'; + +import React from 'react'; +import { useQuery } from 'react-apollo'; +import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; +import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import LoggedInUserQuery from './fetch-user.mc.graphql'; type RenderFnArgs = { diff --git a/packages/application-shell/src/components/gtm-booter/gtm-booter.spec.tsx b/packages/application-shell/src/components/gtm-booter/gtm-booter.spec.tsx index 62b55be8ad..3b76f88a7e 100644 --- a/packages/application-shell/src/components/gtm-booter/gtm-booter.spec.tsx +++ b/packages/application-shell/src/components/gtm-booter/gtm-booter.spec.tsx @@ -1,7 +1,9 @@ +import type { ApplicationWindow } from '@commercetools-frontend/constants'; +import type { Props } from './gtm-booter'; + import React from 'react'; import { render, waitFor, fireEvent } from '@testing-library/react'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; -import GtmBooter, { Props } from './gtm-booter'; +import GtmBooter from './gtm-booter'; declare let window: ApplicationWindow; diff --git a/packages/application-shell/src/components/gtm-user-tracker/gtm-user-tracker.tsx b/packages/application-shell/src/components/gtm-user-tracker/gtm-user-tracker.tsx index 9786294738..5385b0a792 100644 --- a/packages/application-shell/src/components/gtm-user-tracker/gtm-user-tracker.tsx +++ b/packages/application-shell/src/components/gtm-user-tracker/gtm-user-tracker.tsx @@ -1,5 +1,6 @@ +import type { TFetchLoggedInUserQuery } from '../../types/generated/mc'; + import React from 'react'; -import { TFetchLoggedInUserQuery } from '../../types/generated/mc'; import * as gtm from '../../utils/gtm'; type TFetchedUser = TFetchLoggedInUserQuery['user']; diff --git a/packages/application-shell/src/components/handle-apollo-errors/handle-apollo-errors.tsx b/packages/application-shell/src/components/handle-apollo-errors/handle-apollo-errors.tsx index 25b274d643..6ec13babea 100644 --- a/packages/application-shell/src/components/handle-apollo-errors/handle-apollo-errors.tsx +++ b/packages/application-shell/src/components/handle-apollo-errors/handle-apollo-errors.tsx @@ -1,6 +1,7 @@ +import type { QueryResult } from 'react-apollo'; + import React from 'react'; import { useDispatch } from 'react-redux'; -import { QueryResult } from 'react-apollo'; import { handleActionError } from '@commercetools-frontend/actions-global'; import getDisplayName from '../../utils/get-display-name'; diff --git a/packages/application-shell/src/components/inject-reducers/inject-reducers.tsx b/packages/application-shell/src/components/inject-reducers/inject-reducers.tsx index 858ade29b9..82f01049bc 100644 --- a/packages/application-shell/src/components/inject-reducers/inject-reducers.tsx +++ b/packages/application-shell/src/components/inject-reducers/inject-reducers.tsx @@ -1,7 +1,8 @@ +import type { ReducersMapObject } from 'redux'; +import type { TEnhancedStore } from '../../configure-store'; + import React from 'react'; -import { ReducersMapObject } from 'redux'; import { useStore } from 'react-redux'; -import { TEnhancedStore } from '../../configure-store'; type Props = { id: string; diff --git a/packages/application-shell/src/components/navbar/navbar.tsx b/packages/application-shell/src/components/navbar/navbar.tsx index bf09d7afd9..4ee784f393 100644 --- a/packages/application-shell/src/components/navbar/navbar.tsx +++ b/packages/application-shell/src/components/navbar/navbar.tsx @@ -1,11 +1,17 @@ -import React, { MouseEventHandler, SyntheticEvent } from 'react'; +import type { MouseEventHandler, SyntheticEvent } from 'react'; +import type { RouteComponentProps } from 'react-router-dom'; +import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import type { + TDataFence, + TActionRight, + TApplicationsMenu, + TLocalizedField, + TNavbarMenu, +} from '../../types/generated/proxy'; + +import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { - NavLink, - matchPath, - RouteComponentProps, - useLocation, -} from 'react-router-dom'; +import { NavLink, matchPath, useLocation } from 'react-router-dom'; import { ToggleFeature } from '@flopflip/react-broadcast'; import classnames from 'classnames'; import { @@ -33,18 +39,8 @@ import { NO_VALUE_FALLBACK, SUPPORT_PORTAL_URL, } from '@commercetools-frontend/constants'; -import { - useApplicationContext, - TApplicationContext, -} from '@commercetools-frontend/application-shell-connectors'; +import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import { RestrictedByPermissions } from '@commercetools-frontend/permissions'; -import { - TDataFence, - TActionRight, - TApplicationsMenu, - TLocalizedField, - TNavbarMenu, -} from '../../types/generated/proxy'; import { location } from '../../utils/location'; import { GtmContext } from '../gtm-booter'; import LoadingPlaceholder from '../loading-placeholder'; diff --git a/packages/application-shell/src/components/navbar/use-navbar-state-manager.ts b/packages/application-shell/src/components/navbar/use-navbar-state-manager.ts index 1a8f3edf34..6f021f71b7 100644 --- a/packages/application-shell/src/components/navbar/use-navbar-state-manager.ts +++ b/packages/application-shell/src/components/navbar/use-navbar-state-manager.ts @@ -1,16 +1,20 @@ +import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import type { + TApplicationsMenu, + TNavbarMenu, +} from '../../types/generated/proxy'; +import type { + TFetchProjectExtensionsNavbarQuery, + TFetchProjectExtensionsNavbarQueryVariables, +} from '../../types/generated/settings'; + import React from 'react'; import isNil from 'lodash/isNil'; import throttle from 'lodash/throttle'; import { useQuery } from 'react-apollo'; import { useFeatureToggle } from '@flopflip/react-broadcast'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; -import { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { TApplicationsMenu, TNavbarMenu } from '../../types/generated/proxy'; -import { - TFetchProjectExtensionsNavbarQuery, - TFetchProjectExtensionsNavbarQueryVariables, -} from '../../types/generated/settings'; import { PROJECT_EXTENSIONS } from '../../feature-toggles'; import { STORAGE_KEYS } from '../../constants'; import useApplicationsMenu from '../../hooks/use-applications-menu'; diff --git a/packages/application-shell/src/components/project-container/project-container.tsx b/packages/application-shell/src/components/project-container/project-container.tsx index 55d109d670..39ceb391c0 100644 --- a/packages/application-shell/src/components/project-container/project-container.tsx +++ b/packages/application-shell/src/components/project-container/project-container.tsx @@ -1,16 +1,16 @@ +import type { RouteComponentProps } from 'react-router-dom'; +import type { TProviderProps } from '@commercetools-frontend/application-shell-connectors'; +import type { TFetchLoggedInUserQuery } from '../../types/generated/mc'; + import React from 'react'; import ReactDOM from 'react-dom'; -import { Route, Switch, Redirect, RouteComponentProps } from 'react-router-dom'; +import { Route, Switch, Redirect } from 'react-router-dom'; import { useIntl } from 'react-intl'; import isNil from 'lodash/isNil'; -import { - ApplicationContextProvider, - TProviderProps, -} from '@commercetools-frontend/application-shell-connectors'; +import { ApplicationContextProvider } from '@commercetools-frontend/application-shell-connectors'; import { DOMAINS, LOGOUT_REASONS } from '@commercetools-frontend/constants'; import { Notifier } from '@commercetools-frontend/react-notifications'; import { CONTAINERS, STORAGE_KEYS, SUSPENSION_REASONS } from '../../constants'; -import { TFetchLoggedInUserQuery } from '../../types/generated/mc'; import ApplicationLoader from '../application-loader'; import LocaleSwitcher from '../locale-switcher'; import ProjectDataLocale from '../project-data-locale'; diff --git a/packages/application-shell/src/components/project-switcher/project-switcher.tsx b/packages/application-shell/src/components/project-switcher/project-switcher.tsx index 82e6b7ea73..9add930b8d 100644 --- a/packages/application-shell/src/components/project-switcher/project-switcher.tsx +++ b/packages/application-shell/src/components/project-switcher/project-switcher.tsx @@ -1,8 +1,14 @@ +import type { OptionProps, ValueContainerProps } from 'react-select'; +import type { + TProject, + TFetchUserProjectsQuery, + TFetchUserProjectsQueryVariables, +} from '../../types/generated/mc'; + import React from 'react'; import memoize from 'memoize-one'; import { useQuery } from 'react-apollo'; import { FormattedMessage, useIntl } from 'react-intl'; -import { OptionProps, ValueContainerProps } from 'react-select'; import { css } from '@emotion/core'; import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; @@ -10,11 +16,6 @@ import SelectInput from '@commercetools-uikit/select-input'; import { ErrorIcon } from '@commercetools-uikit/icons'; import { customProperties } from '@commercetools-uikit/design-system'; import { location } from '../../utils/location'; -import { - TProject, - TFetchUserProjectsQuery, - TFetchUserProjectsQueryVariables, -} from '../../types/generated/mc'; import ProjectsQuery from './project-switcher.mc.graphql'; import messages from './messages'; diff --git a/packages/application-shell/src/components/quick-access/butler-command/butler-command.tsx b/packages/application-shell/src/components/quick-access/butler-command/butler-command.tsx index ab2405f821..c7eac86fe8 100644 --- a/packages/application-shell/src/components/quick-access/butler-command/butler-command.tsx +++ b/packages/application-shell/src/components/quick-access/butler-command/butler-command.tsx @@ -1,9 +1,11 @@ -import React, { MouseEventHandler } from 'react'; +import type { MouseEventHandler } from 'react'; +import type { Command } from '../types'; + +import React from 'react'; import PropTypes from 'prop-types'; import { css } from '@emotion/core'; import { AngleThinRightIcon } from '@commercetools-uikit/icons'; import { customProperties } from '@commercetools-uikit/design-system'; -import { Command } from '../types'; type Props = { command: Command; diff --git a/packages/application-shell/src/components/quick-access/butler/butler.tsx b/packages/application-shell/src/components/quick-access/butler/butler.tsx index 3d1694cbc3..59c37e3d21 100644 --- a/packages/application-shell/src/components/quick-access/butler/butler.tsx +++ b/packages/application-shell/src/components/quick-access/butler/butler.tsx @@ -1,10 +1,19 @@ -import React, { +import type { KeyboardEventHandler, ChangeEventHandler, KeyboardEvent, MouseEventHandler, MouseEvent, } from 'react'; +import type { + Command, + SearchText, + SelectedResult, + Stack, + HistoryEntry, +} from '../types'; + +import React from 'react'; import Fuse from 'fuse.js'; import { FormattedMessage, useIntl } from 'react-intl'; import last from 'lodash/last'; @@ -15,13 +24,6 @@ import { customProperties } from '@commercetools-uikit/design-system'; import ButlerCommand from '../butler-command'; import ButlerContainer from '../butler-container'; import messages from '../messages'; -import { - Command, - SearchText, - SelectedResult, - Stack, - HistoryEntry, -} from '../types'; const isSelectAllCombo = (event: KeyboardEvent) => event.key === 'a' && diff --git a/packages/application-shell/src/components/quick-access/create-commands.ts b/packages/application-shell/src/components/quick-access/create-commands.ts index c9dd21cbd3..c6c3e4ad4e 100644 --- a/packages/application-shell/src/components/quick-access/create-commands.ts +++ b/packages/application-shell/src/components/quick-access/create-commands.ts @@ -1,15 +1,17 @@ -import { IntlShape } from 'react-intl'; +import type { IntlShape } from 'react-intl'; +import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import type { Command } from './types'; + import { oneLineTrim } from 'common-tags'; import { hasSomePermissions } from '@commercetools-frontend/permissions'; import { LOGOUT_REASONS, SUPPORT_PORTAL_URL, } from '@commercetools-frontend/constants'; -import { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import { permissions } from './constants'; import messages from './messages'; import { location } from '../../utils/location'; -import { actionTypes, Command } from './types'; +import { actionTypes } from './types'; function nonNullable(value: T | boolean): value is NonNullable { return value !== null && value !== undefined && typeof value !== 'boolean'; diff --git a/packages/application-shell/src/components/quick-access/history-entries.ts b/packages/application-shell/src/components/quick-access/history-entries.ts index fc85fd1201..2dce7e3014 100644 --- a/packages/application-shell/src/components/quick-access/history-entries.ts +++ b/packages/application-shell/src/components/quick-access/history-entries.ts @@ -1,4 +1,4 @@ -import { HistoryEntry } from './types'; +import type { HistoryEntry } from './types'; const STORAGE_KEY = 'quickAccessHistoryEntries'; diff --git a/packages/application-shell/src/components/quick-access/quick-access.tsx b/packages/application-shell/src/components/quick-access/quick-access.tsx index 4111b8b462..457669bf3f 100644 --- a/packages/application-shell/src/components/quick-access/quick-access.tsx +++ b/packages/application-shell/src/components/quick-access/quick-access.tsx @@ -1,3 +1,6 @@ +import type { TQuickAccessQuery } from '../../types/generated/ctp'; +import type { ExecGraphQlQuery, Command, HistoryEntry } from './types'; + import React from 'react'; import { useIntl } from 'react-intl'; import { useFeatureToggles } from '@flopflip/react-broadcast'; @@ -15,7 +18,6 @@ import { } from '@commercetools-frontend/constants'; import { hasSomePermissions } from '@commercetools-frontend/permissions'; import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; -import { TQuickAccessQuery } from '../../types/generated/ctp'; import { location } from '../../utils/location'; import Butler from './butler'; import QuickAccessQuery from './quick-access.ctp.graphql'; @@ -29,7 +31,7 @@ import messages from './messages'; import { permissions } from './constants'; import { saveHistoryEntries, loadHistoryEntries } from './history-entries'; import pimIndexerStates from './pim-indexer-states'; -import { actionTypes, ExecGraphQlQuery, Command, HistoryEntry } from './types'; +import { actionTypes } from './types'; const searchProductIdsAction = ( searchText: string, diff --git a/packages/application-shell/src/components/quick-access/sub-commands.ts b/packages/application-shell/src/components/quick-access/sub-commands.ts index cf583afc4d..ef0179d438 100644 --- a/packages/application-shell/src/components/quick-access/sub-commands.ts +++ b/packages/application-shell/src/components/quick-access/sub-commands.ts @@ -1,16 +1,18 @@ -import { IntlShape } from 'react-intl'; -import { oneLineTrim } from 'common-tags'; -import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; -import { hasSomePermissions } from '@commercetools-frontend/permissions'; -import { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; -import { +import type { IntlShape } from 'react-intl'; +import type { TApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import type { TProductVariant, TQuickAccessProductQuery, } from '../../types/generated/ctp'; +import type { Command, ExecGraphQlQuery } from './types'; + +import { oneLineTrim } from 'common-tags'; +import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; +import { hasSomePermissions } from '@commercetools-frontend/permissions'; import QuickAccessProductQuery from './quick-access-product.ctp.graphql'; import { permissions } from './constants'; import messages from './messages'; -import { actionTypes, Command, ExecGraphQlQuery } from './types'; +import { actionTypes } from './types'; type CreateProductVariantSubCommandsOptions = { intl: IntlShape; diff --git a/packages/application-shell/src/components/quick-access/types.ts b/packages/application-shell/src/components/quick-access/types.ts index 247f104609..1c116c6514 100644 --- a/packages/application-shell/src/components/quick-access/types.ts +++ b/packages/application-shell/src/components/quick-access/types.ts @@ -1,6 +1,6 @@ -import { DocumentNode } from 'graphql'; -import { ApolloQueryResult } from 'apollo-client'; -import { OperationVariables } from '@apollo/react-common'; +import type { DocumentNode } from 'graphql'; +import type { ApolloQueryResult } from 'apollo-client'; +import type { OperationVariables } from '@apollo/react-common'; export const actionTypes = { go: 'go', diff --git a/packages/application-shell/src/components/quick-access/utils.ts b/packages/application-shell/src/components/quick-access/utils.ts index 912685d15c..58dcf48f09 100644 --- a/packages/application-shell/src/components/quick-access/utils.ts +++ b/packages/application-shell/src/components/quick-access/utils.ts @@ -1,5 +1,5 @@ -import { TLocalizedString } from '../../types/generated/ctp'; -import { Command, ExecGraphQlQuery } from './types'; +import type { TLocalizedString } from '../../types/generated/ctp'; +import type { Command, ExecGraphQlQuery } from './types'; export const sanitize = (param: string) => param diff --git a/packages/application-shell/src/components/redirector/redirector.tsx b/packages/application-shell/src/components/redirector/redirector.tsx index 8f9b7c1065..1641e7abcc 100644 --- a/packages/application-shell/src/components/redirector/redirector.tsx +++ b/packages/application-shell/src/components/redirector/redirector.tsx @@ -1,7 +1,8 @@ +import type { RouteComponentProps } from 'react-router-dom'; +import type { TEnhancedLocation } from '@commercetools-frontend/browser-history'; + import React from 'react'; import { encode } from 'qss'; -import { RouteComponentProps } from 'react-router-dom'; -import { TEnhancedLocation } from '@commercetools-frontend/browser-history'; import { LOGOUT_REASONS } from '@commercetools-frontend/constants'; import { location } from '../../utils/location'; diff --git a/packages/application-shell/src/components/requests-in-flight-loader/reducer.spec.ts b/packages/application-shell/src/components/requests-in-flight-loader/reducer.spec.ts index d2d37b779f..b7ed1fd735 100644 --- a/packages/application-shell/src/components/requests-in-flight-loader/reducer.spec.ts +++ b/packages/application-shell/src/components/requests-in-flight-loader/reducer.spec.ts @@ -1,12 +1,13 @@ -import { Action } from 'redux'; -import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { SHOW_LOADING, HIDE_LOADING } from '@commercetools-frontend/constants'; -import reducer from './reducer'; -import { +import type { Action } from 'redux'; +import type { TShowRequestInFlightAction, THideRequestInFlightAction, } from './types'; +import { reportErrorToSentry } from '@commercetools-frontend/sentry'; +import { SHOW_LOADING, HIDE_LOADING } from '@commercetools-frontend/constants'; +import reducer from './reducer'; + jest.mock('@commercetools-frontend/sentry'); describe('initial state', () => { diff --git a/packages/application-shell/src/components/requests-in-flight-loader/reducer.ts b/packages/application-shell/src/components/requests-in-flight-loader/reducer.ts index 1aec1f3c0f..a6911abc82 100644 --- a/packages/application-shell/src/components/requests-in-flight-loader/reducer.ts +++ b/packages/application-shell/src/components/requests-in-flight-loader/reducer.ts @@ -1,12 +1,13 @@ -import { Action } from 'redux'; -import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { SHOW_LOADING, HIDE_LOADING } from '@commercetools-frontend/constants'; -import { +import type { Action } from 'redux'; +import type { TRequestsInFlightState, TShowRequestInFlightAction, THideRequestInFlightAction, } from './types'; +import { reportErrorToSentry } from '@commercetools-frontend/sentry'; +import { SHOW_LOADING, HIDE_LOADING } from '@commercetools-frontend/constants'; + const isShowRequestInFlightAction = ( action: Action ): action is TShowRequestInFlightAction => action.type === SHOW_LOADING; diff --git a/packages/application-shell/src/components/requests-in-flight-loader/requests-in-flight-loader.tsx b/packages/application-shell/src/components/requests-in-flight-loader/requests-in-flight-loader.tsx index da345850ea..d2336cb87f 100644 --- a/packages/application-shell/src/components/requests-in-flight-loader/requests-in-flight-loader.tsx +++ b/packages/application-shell/src/components/requests-in-flight-loader/requests-in-flight-loader.tsx @@ -1,3 +1,5 @@ +import type { TRequestsInFlightState } from './types'; + import React from 'react'; import ReactDOM from 'react-dom'; import { FormattedMessage } from 'react-intl'; @@ -5,7 +7,6 @@ import { useSelector } from 'react-redux'; import LoadingSpinner from '@commercetools-uikit/loading-spinner'; import { REQUESTS_IN_FLIGHT_LOADER_DOM_ID } from './constants'; import messages from './messages'; -import { TRequestsInFlightState } from './types'; const getPortalContainer = () => process.env.NODE_ENV === 'test' diff --git a/packages/application-shell/src/components/requests-in-flight-loader/types.ts b/packages/application-shell/src/components/requests-in-flight-loader/types.ts index cd0d2b4c15..3812258a73 100644 --- a/packages/application-shell/src/components/requests-in-flight-loader/types.ts +++ b/packages/application-shell/src/components/requests-in-flight-loader/types.ts @@ -1,4 +1,4 @@ -import { Action } from 'redux'; +import type { Action } from 'redux'; import { SHOW_LOADING, HIDE_LOADING } from '@commercetools-frontend/constants'; export type TRequestsInFlightState = string[]; diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx index 2a222d8abb..4a1d221453 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx +++ b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx @@ -1,8 +1,9 @@ +import type { TFlags } from '@flopflip/types'; +import type { TFetchLoggedInUserQuery } from '../../types/generated/mc'; + import React from 'react'; import ldAdapter from '@flopflip/launchdarkly-adapter'; import { ConfigureFlopFlip } from '@flopflip/react-broadcast'; -import { TFlags } from '@flopflip/types'; -import { TFetchLoggedInUserQuery } from '../../types/generated/mc'; import useAllMenuFeatureToggles from '../../hooks/use-all-menu-feature-toggles'; import { FLAGS } from '../../feature-toggles'; diff --git a/packages/application-shell/src/components/user-settings-menu/user-settings-menu.tsx b/packages/application-shell/src/components/user-settings-menu/user-settings-menu.tsx index 7794183bd8..899fe9cc29 100644 --- a/packages/application-shell/src/components/user-settings-menu/user-settings-menu.tsx +++ b/packages/application-shell/src/components/user-settings-menu/user-settings-menu.tsx @@ -1,12 +1,16 @@ +import type { ControllerStateAndHelpers, DownshiftProps } from 'downshift'; +import type { TUser } from '../../types/generated/mc'; +import type { + TApplicationsMenu, + TFetchApplicationsMenuQuery, +} from '../../types/generated/proxy'; + import React from 'react'; import { Link } from 'react-router-dom'; import { FormattedMessage } from 'react-intl'; import { css } from '@emotion/core'; import styled from '@emotion/styled'; -import Downshift, { - ControllerStateAndHelpers, - DownshiftProps, -} from 'downshift'; +import Downshift from 'downshift'; import { ToggleFeature } from '@flopflip/react-broadcast'; import Avatar from '@commercetools-uikit/avatar'; import Spacings from '@commercetools-uikit/spacings'; @@ -21,11 +25,6 @@ import { import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import useApplicationsMenu from '../../hooks/use-applications-menu'; -import { TUser } from '../../types/generated/mc'; -import { - TApplicationsMenu, - TFetchApplicationsMenuQuery, -} from '../../types/generated/proxy'; import messages from './messages'; type Props = Pick< diff --git a/packages/application-shell/src/components/version-tracker/actions.ts b/packages/application-shell/src/components/version-tracker/actions.ts index 8c2c435162..7d37bcc3b7 100644 --- a/packages/application-shell/src/components/version-tracker/actions.ts +++ b/packages/application-shell/src/components/version-tracker/actions.ts @@ -1,4 +1,6 @@ -import { actions as sdkActions, Json } from '@commercetools-frontend/sdk'; +import type { Json } from '@commercetools-frontend/sdk'; + +import { actions as sdkActions } from '@commercetools-frontend/sdk'; import { MC_API_PROXY_TARGETS } from '@commercetools-frontend/constants'; // eslint-disable-next-line import/prefer-default-export diff --git a/packages/application-shell/src/configure-apollo.ts b/packages/application-shell/src/configure-apollo.ts index dfb7b45bd6..8955db659e 100644 --- a/packages/application-shell/src/configure-apollo.ts +++ b/packages/application-shell/src/configure-apollo.ts @@ -1,3 +1,6 @@ +import type { IdGetterObj } from 'apollo-cache-inmemory'; +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import ApolloClient from 'apollo-client'; import { version as apolloVersion } from 'apollo-client/version'; import { ApolloLink } from 'apollo-link'; @@ -6,9 +9,7 @@ import { createHttpLink } from 'apollo-link-http'; import { InMemoryCache, IntrospectionFragmentMatcher, - IdGetterObj, } from 'apollo-cache-inmemory'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; import createHttpUserAgent from '@commercetools/http-user-agent'; import { errorLink, headerLink, tokenRetryLink } from './apollo-links'; import { getMcApiUrl } from './utils'; diff --git a/packages/application-shell/src/configure-store.ts b/packages/application-shell/src/configure-store.ts index 6750f644ee..dcd2003ef1 100644 --- a/packages/application-shell/src/configure-store.ts +++ b/packages/application-shell/src/configure-store.ts @@ -1,24 +1,19 @@ -import { - createStore, - compose, - applyMiddleware, - combineReducers, +import type { ReducersMapObject, Store, Middleware, StoreEnhancer, } from 'redux'; +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + +import { createStore, compose, applyMiddleware, combineReducers } from 'redux'; import thunk from 'redux-thunk'; import { middleware as notificationsMiddleware, reducer as notificationsReducer, } from '@commercetools-frontend/notifications'; import { createMiddleware as createSdkMiddleware } from '@commercetools-frontend/sdk'; -import { - SHOW_LOADING, - HIDE_LOADING, - ApplicationWindow, -} from '@commercetools-frontend/constants'; +import { SHOW_LOADING, HIDE_LOADING } from '@commercetools-frontend/constants'; import hideNotificationsMiddleware from './middleware/hide-notifications'; import loggerMiddleware from './middleware/logger'; import { requestsInFlightReducer } from './components/requests-in-flight-loader'; diff --git a/packages/application-shell/src/hooks/use-all-menu-feature-toggles/use-all-menu-feature-toggles.ts b/packages/application-shell/src/hooks/use-all-menu-feature-toggles/use-all-menu-feature-toggles.ts index 7911a07358..dbf83edb55 100644 --- a/packages/application-shell/src/hooks/use-all-menu-feature-toggles/use-all-menu-feature-toggles.ts +++ b/packages/application-shell/src/hooks/use-all-menu-feature-toggles/use-all-menu-feature-toggles.ts @@ -1,10 +1,11 @@ -import { useQuery } from 'react-apollo'; -import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; -import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { +import type { TFetchAllMenuFeatureTogglesQuery, TFetchAllMenuFeatureTogglesQueryVariables, } from '../../types/generated/proxy'; + +import { useQuery } from 'react-apollo'; +import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; +import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import { FetchAllMenuFeatureToggles } from './fetch-all-menu-feature-toggles.proxy.graphql'; const defaultApiUrl = window.location.origin; diff --git a/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.spec.tsx b/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.spec.tsx index f573814396..9f0c5dd14c 100644 --- a/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.spec.tsx +++ b/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.spec.tsx @@ -1,15 +1,17 @@ +import type { TFetchApplicationsMenuQuery } from '../../types/generated/proxy'; +import type { + MenuKey, + Config, + MenuLoaderResult, +} from './use-applications-menu'; + import { mocked } from 'ts-jest/utils'; import React from 'react'; import upperFirst from 'lodash/upperFirst'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import { renderApp, waitFor } from '../../test-utils'; -import { TFetchApplicationsMenuQuery } from '../../types/generated/proxy'; import FetchApplicationsMenu from './fetch-applications-menu.proxy.graphql'; -import useApplicationsMenu, { - MenuKey, - Config, - MenuLoaderResult, -} from './use-applications-menu'; +import useApplicationsMenu from './use-applications-menu'; jest.mock('@commercetools-frontend/sentry'); diff --git a/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.ts b/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.ts index 30358b72bf..69c73d2a13 100644 --- a/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.ts +++ b/packages/application-shell/src/hooks/use-applications-menu/use-applications-menu.ts @@ -1,10 +1,12 @@ -import React from 'react'; -import { useLazyQuery, QueryFunctionOptions } from 'react-apollo'; -import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; -import { +import type { QueryFunctionOptions } from 'react-apollo'; +import type { TFetchApplicationsMenuQuery, TFetchApplicationsMenuQueryVariables, } from '../../types/generated/proxy'; + +import React from 'react'; +import { useLazyQuery } from 'react-apollo'; +import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import FetchApplicationsMenu from './fetch-applications-menu.proxy.graphql'; export type MenuKey = 'appBar' | 'navBar'; diff --git a/packages/application-shell/src/middleware/hide-notifications.ts b/packages/application-shell/src/middleware/hide-notifications.ts index 2748ac4efa..1d34c21d73 100644 --- a/packages/application-shell/src/middleware/hide-notifications.ts +++ b/packages/application-shell/src/middleware/hide-notifications.ts @@ -1,13 +1,14 @@ -import { Action, Dispatch, MiddlewareAPI } from 'redux'; +import type { Action, Dispatch, MiddlewareAPI } from 'redux'; +import type { TNotificationAction } from '@commercetools-frontend/notifications'; +import type { + TApiErrorNotification, + TUnexpectedErrorNotification, +} from '@commercetools-frontend/actions-global'; + import { removeNotification, ADD_NOTIFICATION, - TNotificationAction, } from '@commercetools-frontend/notifications'; -import { - TApiErrorNotification, - TUnexpectedErrorNotification, -} from '@commercetools-frontend/actions-global'; import { selectPageNotifications } from '@commercetools-frontend/react-notifications'; import { HIDE_ALL_PAGE_NOTIFICATIONS, diff --git a/packages/application-shell/src/middleware/logger.ts b/packages/application-shell/src/middleware/logger.ts index 11cbd6ab7a..4f25a02eb4 100644 --- a/packages/application-shell/src/middleware/logger.ts +++ b/packages/application-shell/src/middleware/logger.ts @@ -1,4 +1,5 @@ -import { Middleware } from 'redux'; +import type { Middleware } from 'redux'; + import { createLogger } from 'redux-logger'; import { ADD_NOTIFICATION, diff --git a/packages/application-shell/src/test-utils/test-utils.spec.tsx b/packages/application-shell/src/test-utils/test-utils.spec.tsx index 3344fb2212..218848167c 100644 --- a/packages/application-shell/src/test-utils/test-utils.spec.tsx +++ b/packages/application-shell/src/test-utils/test-utils.spec.tsx @@ -4,11 +4,11 @@ // the `render` method sets up the tests correctly. // This is a bit different from our usual tests, as we are testing our testing // tools here instead of actual components. +import React from 'react'; +import PropTypes from 'prop-types'; import { InMemoryCache } from 'apollo-cache-inmemory'; import { ApolloClient } from 'apollo-client'; import { HttpLink } from 'apollo-link-http'; -import PropTypes from 'prop-types'; -import React, { useContext } from 'react'; import { useIntl } from 'react-intl'; import { Query } from 'react-apollo'; import { useSelector } from 'react-redux'; @@ -293,7 +293,7 @@ describe('custom render functions', () => { it('should merge the passed wrapper with renderApp internal wrapper', async () => { const TestComponent = () => { // provided wrapper - const value = useContext(Context); + const value = React.useContext(Context); // own wrapper useIntl(); @@ -309,7 +309,7 @@ describe('custom render functions', () => { it('should merge the passed wrapper with renderAppWithRedux internal wrapper', async () => { const TestComponent = () => { // provided wrapper - const value = useContext(Context); + const value = React.useContext(Context); // own wrapper useSelector(() => undefined); diff --git a/packages/application-shell/src/test-utils/test-utils.tsx b/packages/application-shell/src/test-utils/test-utils.tsx index 591f6866e2..8dca0e5019 100644 --- a/packages/application-shell/src/test-utils/test-utils.tsx +++ b/packages/application-shell/src/test-utils/test-utils.tsx @@ -1,3 +1,9 @@ +import type { MockedProviderProps } from '@apollo/react-testing'; +import type { TFlags } from '@flopflip/types'; +import type { TProviderProps } from '@commercetools-frontend/application-shell-connectors'; +import type { TMapNotificationToComponentProps } from '@commercetools-frontend/react-notifications'; +import type { TSdkMock } from '@commercetools-frontend/sdk/test-utils'; + import React from 'react'; import PropTypes from 'prop-types'; import { Router } from 'react-router-dom'; @@ -7,28 +13,17 @@ import * as rtl from '@testing-library/react'; import { createMemoryHistory } from 'history'; import { IntlProvider } from 'react-intl'; import { ConfigureFlopFlip } from '@flopflip/react-broadcast'; -import { TFlags } from '@flopflip/types'; -import { - MockedProvider as ApolloMockProvider, - MockedProviderProps, -} from '@apollo/react-testing'; +import { MockedProvider as ApolloMockProvider } from '@apollo/react-testing'; import memoryAdapter from '@flopflip/memory-adapter'; import { Provider as StoreProvider } from 'react-redux'; import { createEnhancedHistory } from '@commercetools-frontend/browser-history'; -import { - ApplicationContextProvider, - TProviderProps, -} from '@commercetools-frontend/application-shell-connectors'; +import { ApplicationContextProvider } from '@commercetools-frontend/application-shell-connectors'; import { NotificationsList, NotificationProviderForCustomComponent, - TMapNotificationToComponentProps, } from '@commercetools-frontend/react-notifications'; import { DOMAINS } from '@commercetools-frontend/constants'; -import { - createTestMiddleware as createSdkTestMiddleware, - TSdkMock, -} from '@commercetools-frontend/sdk/test-utils'; +import { createTestMiddleware as createSdkTestMiddleware } from '@commercetools-frontend/sdk/test-utils'; import { createReduxStore } from '../configure-store'; import { createApolloClient } from '../configure-apollo'; diff --git a/packages/application-shell/src/track-performance.ts b/packages/application-shell/src/track-performance.ts index 42d9f2786a..668562f507 100644 --- a/packages/application-shell/src/track-performance.ts +++ b/packages/application-shell/src/track-performance.ts @@ -1,7 +1,9 @@ -import Perfume, { +import type { IPerfumeNavigationTiming, IPerfumeDataConsumption, } from 'perfume.js'; + +import Perfume from 'perfume.js'; import { trackTiming } from './utils/gtm'; const trackPerformance = () => { diff --git a/packages/application-shell/src/utils/gtm.ts b/packages/application-shell/src/utils/gtm.ts index 3c9a075185..50a7b43013 100644 --- a/packages/application-shell/src/utils/gtm.ts +++ b/packages/application-shell/src/utils/gtm.ts @@ -1,7 +1,8 @@ /** * Google Tag Manager (GTM) Tracking Utilities */ -import { ApplicationWindow } from '@commercetools-frontend/constants'; +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import camelcase from 'lodash/camelCase'; import logger from './logger'; diff --git a/packages/application-shell/src/utils/select-user-id/select-user-id.ts b/packages/application-shell/src/utils/select-user-id/select-user-id.ts index 6e2e246087..813d0e1dc3 100644 --- a/packages/application-shell/src/utils/select-user-id/select-user-id.ts +++ b/packages/application-shell/src/utils/select-user-id/select-user-id.ts @@ -1,6 +1,7 @@ +import type { NormalizedCacheObject } from 'apollo-cache-inmemory'; +import type { TFetchUserIdQuery } from '../../types/generated/mc'; + import ApolloClient from 'apollo-client'; -import { NormalizedCacheObject } from 'apollo-cache-inmemory'; -import { TFetchUserIdQuery } from '../../types/generated/mc'; import FetchUserIdQuery from './select-user-id.mc.graphql'; export default function selectUserId({ diff --git a/packages/browser-history/src/index.ts b/packages/browser-history/src/index.ts index c8ce141aea..8f20fc70a1 100644 --- a/packages/browser-history/src/index.ts +++ b/packages/browser-history/src/index.ts @@ -1,5 +1,5 @@ // eslint-disable-next-line import/named -import { EnhancedLocation } from 'history-query-enhancer'; +import type { EnhancedLocation } from 'history-query-enhancer'; export { default as version } from './version'; diff --git a/packages/i18n/src/async-locale-data/async-locale-data.spec.tsx b/packages/i18n/src/async-locale-data/async-locale-data.spec.tsx index cbdf12cbb5..2692902e00 100644 --- a/packages/i18n/src/async-locale-data/async-locale-data.spec.tsx +++ b/packages/i18n/src/async-locale-data/async-locale-data.spec.tsx @@ -1,13 +1,11 @@ +import type { State, Props, TMessageTranslations } from './async-locale-data'; + import { mocked } from 'ts-jest/utils'; import React from 'react'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; import { render, waitFor } from '@testing-library/react'; import loadI18n from '../load-i18n'; -import AsyncLocaleData, { - State, - Props, - TMessageTranslations, -} from './async-locale-data'; +import AsyncLocaleData from './async-locale-data'; jest.mock('@commercetools-frontend/sentry'); diff --git a/packages/i18n/src/index.ts b/packages/i18n/src/index.ts index 6efb03db67..709c4702d3 100644 --- a/packages/i18n/src/index.ts +++ b/packages/i18n/src/index.ts @@ -1,4 +1,4 @@ -import { Props } from './async-locale-data/async-locale-data'; +import type { Props } from './async-locale-data/async-locale-data'; export type TAsyncLocaleDataProps = Props; diff --git a/packages/l10n/src/country-information.ts b/packages/l10n/src/country-information.ts index ecd84064e9..153c784921 100644 --- a/packages/l10n/src/country-information.ts +++ b/packages/l10n/src/country-information.ts @@ -1,7 +1,8 @@ +import type { Countries } from './types'; + import * as PropTypes from 'prop-types'; import { createL10NInjector, createL10NHook } from './create-l10n-injector'; import { getSupportedLocale, mapLocaleToIntlLocale } from './utils'; -import { Countries } from './types'; type ImportData = { default: Countries; diff --git a/packages/l10n/src/currency-information.ts b/packages/l10n/src/currency-information.ts index aefc9d49e5..cd8c9d2158 100644 --- a/packages/l10n/src/currency-information.ts +++ b/packages/l10n/src/currency-information.ts @@ -1,7 +1,8 @@ +import type { Currencies } from './types'; + import * as PropTypes from 'prop-types'; import { createL10NInjector, createL10NHook } from './create-l10n-injector'; import { getSupportedLocale, mapLocaleToIntlLocale } from './utils'; -import { Currencies } from './types'; type ImportData = { default: Currencies; diff --git a/packages/l10n/src/language-information.ts b/packages/l10n/src/language-information.ts index 0bfd16053c..b14d1501b4 100644 --- a/packages/l10n/src/language-information.ts +++ b/packages/l10n/src/language-information.ts @@ -1,7 +1,8 @@ +import type { Languages } from './types'; + import * as PropTypes from 'prop-types'; import { createL10NInjector, createL10NHook } from './create-l10n-injector'; import { getSupportedLocale, mapLocaleToIntlLocale } from './utils'; -import { Languages } from './types'; type ImportData = { default: Languages; diff --git a/packages/l10n/src/time-zone-information.ts b/packages/l10n/src/time-zone-information.ts index c742c1abb4..5ad28b83f8 100644 --- a/packages/l10n/src/time-zone-information.ts +++ b/packages/l10n/src/time-zone-information.ts @@ -1,7 +1,8 @@ +import type { TimeZones } from './types'; + import * as PropTypes from 'prop-types'; import { createL10NInjector, createL10NHook } from './create-l10n-injector'; import { getSupportedLocale, mapLocaleToIntlLocale } from './utils'; -import { TimeZones } from './types'; type ImportData = { default: TimeZones; diff --git a/packages/l10n/src/utils.ts b/packages/l10n/src/utils.ts index 62298e50ff..caea87faf3 100644 --- a/packages/l10n/src/utils.ts +++ b/packages/l10n/src/utils.ts @@ -1,4 +1,4 @@ -import { Currencies } from './types'; +import type { Currencies } from './types'; export const mapLocaleToIntlLocale = (locale: string) => { if (locale.startsWith('de')) return 'de'; diff --git a/packages/notifications/src/action-creators.ts b/packages/notifications/src/action-creators.ts index 8d6aa5527e..f8be48fb64 100644 --- a/packages/notifications/src/action-creators.ts +++ b/packages/notifications/src/action-creators.ts @@ -1,9 +1,10 @@ -import { +import type { TNotificationMetaOptions, TRemoveNotificationAction, TNotification, TAddNotificationAction, } from './types'; + import { ADD_NOTIFICATION, REMOVE_NOTIFICATION } from './action-types'; export function addNotification( diff --git a/packages/notifications/src/middleware.ts b/packages/notifications/src/middleware.ts index 1d8b8ab27f..c8d4515b6c 100644 --- a/packages/notifications/src/middleware.ts +++ b/packages/notifications/src/middleware.ts @@ -1,9 +1,10 @@ -import { Action, Dispatch, MiddlewareAPI } from 'redux'; -import { +import type { Action, Dispatch, MiddlewareAPI } from 'redux'; +import type { TNotification, TNotificationOnDismiss, TNotificationAction, } from './types'; + import { ADD_NOTIFICATION, REMOVE_NOTIFICATION } from './action-types'; import { removeNotification } from './action-creators'; diff --git a/packages/notifications/src/notifications.spec.ts b/packages/notifications/src/notifications.spec.ts index de4c42927e..7312428582 100644 --- a/packages/notifications/src/notifications.spec.ts +++ b/packages/notifications/src/notifications.spec.ts @@ -1,5 +1,6 @@ +import type { TNotificationAction, TNotificationState } from './types'; + import { createStore, applyMiddleware } from 'redux'; -import { TNotificationAction, TNotificationState } from './types'; import { addNotification } from './action-creators'; import reducer from './reducer'; import middleware from './middleware'; diff --git a/packages/notifications/src/reducer.ts b/packages/notifications/src/reducer.ts index b4baa38418..dd79e74f33 100644 --- a/packages/notifications/src/reducer.ts +++ b/packages/notifications/src/reducer.ts @@ -1,8 +1,9 @@ -import { +import type { TNotification, TNotificationAction, TNotificationState, } from './types'; + import { ADD_NOTIFICATION, REMOVE_NOTIFICATION } from './action-types'; export default function notificationsReducer( diff --git a/packages/notifications/src/types.ts b/packages/notifications/src/types.ts index 80e22141bc..d13c1d3edf 100644 --- a/packages/notifications/src/types.ts +++ b/packages/notifications/src/types.ts @@ -1,4 +1,5 @@ -import { Action } from 'redux'; +import type { Action } from 'redux'; + import { ADD_NOTIFICATION, REMOVE_NOTIFICATION } from './action-types'; export type TNotification = { diff --git a/packages/react-notifications/src/components/map-notification-to-component/index.ts b/packages/react-notifications/src/components/map-notification-to-component/index.ts index 7b1dce1aa0..ea4cddbe72 100644 --- a/packages/react-notifications/src/components/map-notification-to-component/index.ts +++ b/packages/react-notifications/src/components/map-notification-to-component/index.ts @@ -1,4 +1,4 @@ -import { Props } from './map-notification-to-component'; +import type { Props } from './map-notification-to-component'; // Re-export type for convenience export type TProps = Props; diff --git a/packages/react-notifications/src/components/map-notification-to-component/map-notification-to-component.tsx b/packages/react-notifications/src/components/map-notification-to-component/map-notification-to-component.tsx index dc471a861e..ce670966c8 100644 --- a/packages/react-notifications/src/components/map-notification-to-component/map-notification-to-component.tsx +++ b/packages/react-notifications/src/components/map-notification-to-component/map-notification-to-component.tsx @@ -1,10 +1,11 @@ -import React from 'react'; -import { +import type { TAppNotificationGlobal, TAppNotificationPage, TAppNotificationSide, } from '@commercetools-frontend/constants'; +import React from 'react'; + export type Props = { mapNotificationToComponent: ( notification: diff --git a/packages/react-notifications/src/components/notification-kinds/api-error-message/api-error-message.tsx b/packages/react-notifications/src/components/notification-kinds/api-error-message/api-error-message.tsx index b0e4364bcf..5385241112 100644 --- a/packages/react-notifications/src/components/notification-kinds/api-error-message/api-error-message.tsx +++ b/packages/react-notifications/src/components/notification-kinds/api-error-message/api-error-message.tsx @@ -1,8 +1,10 @@ +import type { TAppNotificationApiError } from '@commercetools-frontend/constants'; +import type { IntlShape } from 'react-intl'; + import React from 'react'; -import { useIntl, IntlShape } from 'react-intl'; +import { useIntl } from 'react-intl'; import has from 'lodash/has'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; -import { TAppNotificationApiError } from '@commercetools-frontend/constants'; import messages from './messages'; const regexInvalidOperationRequiredAttribute = /Required attribute '(.*)' cannot be removed/; diff --git a/packages/react-notifications/src/components/notification-kinds/api-error/api-error.tsx b/packages/react-notifications/src/components/notification-kinds/api-error/api-error.tsx index 4bab5808ad..1c460253f0 100644 --- a/packages/react-notifications/src/components/notification-kinds/api-error/api-error.tsx +++ b/packages/react-notifications/src/components/notification-kinds/api-error/api-error.tsx @@ -1,7 +1,10 @@ -import React from 'react'; -import { +import type { TAppNotification, TAppNotificationValuesApiError, +} from '@commercetools-frontend/constants'; + +import React from 'react'; +import { NOTIFICATION_DOMAINS, NOTIFICATION_KINDS_PAGE, } from '@commercetools-frontend/constants'; diff --git a/packages/react-notifications/src/components/notification-kinds/generic/generic.tsx b/packages/react-notifications/src/components/notification-kinds/generic/generic.tsx index 573b1c322b..0fbae19b4c 100644 --- a/packages/react-notifications/src/components/notification-kinds/generic/generic.tsx +++ b/packages/react-notifications/src/components/notification-kinds/generic/generic.tsx @@ -1,9 +1,10 @@ -import React from 'react'; -import { +import type { TAppNotification, TAppNotificationDomain, TAppNotificationKindSide, } from '@commercetools-frontend/constants'; + +import React from 'react'; import Notification from '../../notification'; type Props = { diff --git a/packages/react-notifications/src/components/notification-kinds/unexpected-error/unexpected-error.tsx b/packages/react-notifications/src/components/notification-kinds/unexpected-error/unexpected-error.tsx index 4d681e76c7..c025489e9f 100644 --- a/packages/react-notifications/src/components/notification-kinds/unexpected-error/unexpected-error.tsx +++ b/packages/react-notifications/src/components/notification-kinds/unexpected-error/unexpected-error.tsx @@ -1,10 +1,13 @@ +import type { + TAppNotification, + TAppNotificationValuesUnexpectedError, +} from '@commercetools-frontend/constants'; + import React from 'react'; import { FormattedMessage } from 'react-intl'; import { NOTIFICATION_DOMAINS, NOTIFICATION_KINDS_PAGE, - TAppNotification, - TAppNotificationValuesUnexpectedError, } from '@commercetools-frontend/constants'; import Spacings from '@commercetools-uikit/spacings'; import Notification from '../../notification'; diff --git a/packages/react-notifications/src/components/notification/notification.spec.tsx b/packages/react-notifications/src/components/notification/notification.spec.tsx index 31aa02a901..bd9d256b17 100644 --- a/packages/react-notifications/src/components/notification/notification.spec.tsx +++ b/packages/react-notifications/src/components/notification/notification.spec.tsx @@ -1,11 +1,14 @@ +import type { RenderResult } from '@testing-library/react'; +import type { Props } from './notification'; + import React from 'react'; import { IntlProvider } from 'react-intl'; -import { render, RenderResult, fireEvent } from '@testing-library/react'; +import { render, fireEvent } from '@testing-library/react'; import { NOTIFICATION_DOMAINS, NOTIFICATION_KINDS_SIDE, } from '@commercetools-frontend/constants'; -import Notification, { Props } from './notification'; +import Notification from './notification'; const TestComponent = () =>
{'Test'}
; diff --git a/packages/react-notifications/src/components/notification/notification.styles.ts b/packages/react-notifications/src/components/notification/notification.styles.ts index 2418d9644a..91a455af06 100644 --- a/packages/react-notifications/src/components/notification/notification.styles.ts +++ b/packages/react-notifications/src/components/notification/notification.styles.ts @@ -1,9 +1,12 @@ +import type { + TAppNotificationKind, + TAppNotificationDomain, +} from '@commercetools-frontend/constants'; + import { css, keyframes } from '@emotion/core'; import { customProperties } from '@commercetools-uikit/design-system'; import { NOTIFICATION_DOMAINS, - TAppNotificationKind, - TAppNotificationDomain, NOTIFICATION_KINDS_SIDE, } from '@commercetools-frontend/constants'; diff --git a/packages/react-notifications/src/components/notification/notification.tsx b/packages/react-notifications/src/components/notification/notification.tsx index 64ff8d206f..f2592b9203 100644 --- a/packages/react-notifications/src/components/notification/notification.tsx +++ b/packages/react-notifications/src/components/notification/notification.tsx @@ -1,3 +1,8 @@ +import type { + TAppNotificationKind, + TAppNotificationDomain, +} from '@commercetools-frontend/constants'; + import React from 'react'; import { useIntl } from 'react-intl'; import { @@ -10,8 +15,6 @@ import { import IconButton from '@commercetools-uikit/icon-button'; import { NOTIFICATION_DOMAINS, - TAppNotificationKind, - TAppNotificationDomain, NOTIFICATION_KINDS_SIDE, } from '@commercetools-frontend/constants'; import filterDataAttributes from '../../utils/filter-data-attributes'; diff --git a/packages/react-notifications/src/components/notifications-list/notifications-list.spec.tsx b/packages/react-notifications/src/components/notifications-list/notifications-list.spec.tsx index 8c290ecf7f..8433926aa1 100644 --- a/packages/react-notifications/src/components/notifications-list/notifications-list.spec.tsx +++ b/packages/react-notifications/src/components/notifications-list/notifications-list.spec.tsx @@ -1,8 +1,10 @@ +import type { RenderResult } from '@testing-library/react'; + import { mocked } from 'ts-jest/utils'; import React from 'react'; import { IntlProvider } from 'react-intl'; import { useSelector } from 'react-redux'; -import { render, RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { NOTIFICATION_DOMAINS, NOTIFICATION_KINDS_PAGE, diff --git a/packages/react-notifications/src/components/notifications-list/notifications-list.styles.ts b/packages/react-notifications/src/components/notifications-list/notifications-list.styles.ts index 031299c14a..1e09e2f278 100644 --- a/packages/react-notifications/src/components/notifications-list/notifications-list.styles.ts +++ b/packages/react-notifications/src/components/notifications-list/notifications-list.styles.ts @@ -1,9 +1,8 @@ +import type { TAppNotificationDomain } from '@commercetools-frontend/constants'; + import { css } from '@emotion/core'; import { customProperties } from '@commercetools-uikit/design-system'; -import { - NOTIFICATION_DOMAINS, - TAppNotificationDomain, -} from '@commercetools-frontend/constants'; +import { NOTIFICATION_DOMAINS } from '@commercetools-frontend/constants'; type StyleProps = { domain: TAppNotificationDomain; diff --git a/packages/react-notifications/src/components/notifications-list/notifications-list.tsx b/packages/react-notifications/src/components/notifications-list/notifications-list.tsx index 93ee884442..74a2c8dbfa 100644 --- a/packages/react-notifications/src/components/notifications-list/notifications-list.tsx +++ b/packages/react-notifications/src/components/notifications-list/notifications-list.tsx @@ -1,3 +1,12 @@ +import type { + TAppNotificationDomain, + TAppNotificationGlobal, + TAppNotificationPage, + TAppNotificationSide, + TAppNotificationValuesUnexpectedError, +} from '@commercetools-frontend/constants'; +import type { TAppState } from './types'; + import React from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { @@ -5,11 +14,6 @@ import { NOTIFICATION_KINDS_GLOBAL, NOTIFICATION_KINDS_PAGE, NOTIFICATION_KINDS_SIDE, - TAppNotificationDomain, - TAppNotificationGlobal, - TAppNotificationPage, - TAppNotificationSide, - TAppNotificationValuesUnexpectedError, } from '@commercetools-frontend/constants'; import { removeNotification } from '@commercetools-frontend/notifications'; import { reportErrorToSentry } from '@commercetools-frontend/sentry'; @@ -22,7 +26,6 @@ import { selectPageNotifications, selectSideNotifications, } from './selectors'; -import { TAppState } from './types'; import { getStyles } from './notifications-list.styles'; type Props = { diff --git a/packages/react-notifications/src/components/notifications-list/selectors.ts b/packages/react-notifications/src/components/notifications-list/selectors.ts index 4b8ff2c316..5d1c4b36bf 100644 --- a/packages/react-notifications/src/components/notifications-list/selectors.ts +++ b/packages/react-notifications/src/components/notifications-list/selectors.ts @@ -1,12 +1,13 @@ -import { createSelector } from 'reselect'; -import { - NOTIFICATION_DOMAINS, +import type { TAppNotificationGlobal, TAppNotificationPage, TAppNotificationSide, TAppNotificationDomain, } from '@commercetools-frontend/constants'; -import { TAppState } from './types'; +import type { TAppState } from './types'; + +import { createSelector } from 'reselect'; +import { NOTIFICATION_DOMAINS } from '@commercetools-frontend/constants'; // These selectors are okay memoization-wise, but once a single notifications // is added or removed the memoization for all domain selectors is reset diff --git a/packages/react-notifications/src/components/notifications-list/types.ts b/packages/react-notifications/src/components/notifications-list/types.ts index a2240b52f3..c250351e32 100644 --- a/packages/react-notifications/src/components/notifications-list/types.ts +++ b/packages/react-notifications/src/components/notifications-list/types.ts @@ -1,4 +1,4 @@ -import { +import type { TAppNotificationGlobal, TAppNotificationPage, TAppNotificationSide, diff --git a/packages/react-notifications/src/components/notifier/notifier.spec.tsx b/packages/react-notifications/src/components/notifier/notifier.spec.tsx index a1d23d7d57..edf6e8363d 100644 --- a/packages/react-notifications/src/components/notifier/notifier.spec.tsx +++ b/packages/react-notifications/src/components/notifier/notifier.spec.tsx @@ -1,24 +1,17 @@ /* eslint-disable react/prop-types */ +import type { RenderResult } from '@testing-library/react'; +import type { TAddNotificationAction } from '@commercetools-frontend/notifications'; +import type { TShowNotification } from '@commercetools-frontend/actions-global'; + import { mocked } from 'ts-jest/utils'; import React from 'react'; -import { - render, - fireEvent, - waitFor, - RenderResult, -} from '@testing-library/react'; -import { - TAddNotificationAction, - ADD_NOTIFICATION, -} from '@commercetools-frontend/notifications'; +import { render, fireEvent, waitFor } from '@testing-library/react'; +import { ADD_NOTIFICATION } from '@commercetools-frontend/notifications'; import { NOTIFICATION_DOMAINS, NOTIFICATION_KINDS_SIDE, } from '@commercetools-frontend/constants'; -import { - useShowNotification, - TShowNotification, -} from '@commercetools-frontend/actions-global'; +import { useShowNotification } from '@commercetools-frontend/actions-global'; import Notifier from './notifier'; jest.mock('@commercetools-frontend/actions-global'); diff --git a/packages/react-notifications/src/components/notifier/notifier.tsx b/packages/react-notifications/src/components/notifier/notifier.tsx index 71f53f0081..f42516c68e 100644 --- a/packages/react-notifications/src/components/notifier/notifier.tsx +++ b/packages/react-notifications/src/components/notifier/notifier.tsx @@ -1,10 +1,13 @@ +import type { + TAppNotificationDomain, + TAppNotificationKind, +} from '@commercetools-frontend/constants'; + import React from 'react'; import isNumber from 'lodash/isNumber'; import * as globalActions from '@commercetools-frontend/actions-global'; import { NOTIFICATION_DOMAINS, - TAppNotificationDomain, - TAppNotificationKind, NOTIFICATION_KINDS_SIDE, } from '@commercetools-frontend/constants'; diff --git a/packages/react-notifications/src/index.ts b/packages/react-notifications/src/index.ts index e53062baee..aa4da3b9e0 100644 --- a/packages/react-notifications/src/index.ts +++ b/packages/react-notifications/src/index.ts @@ -1,4 +1,4 @@ -import { TProps as MapNotificationToComponentProps } from './components/map-notification-to-component'; +import type { TProps as MapNotificationToComponentProps } from './components/map-notification-to-component'; // Re-export type for convenience export type TMapNotificationToComponentProps = MapNotificationToComponentProps; diff --git a/packages/sdk/src/actions/actions.ts b/packages/sdk/src/actions/actions.ts index a72468e8fa..5ab73b2d01 100644 --- a/packages/sdk/src/actions/actions.ts +++ b/packages/sdk/src/actions/actions.ts @@ -1,4 +1,4 @@ -import { +import type { TSdkActionPayload, TSdkActionPayloadBody, TSdkActionPayloadForUri, diff --git a/packages/sdk/src/components/sdk-get/sdk-get.spec.tsx b/packages/sdk/src/components/sdk-get/sdk-get.spec.tsx index 443448baad..b400063264 100644 --- a/packages/sdk/src/components/sdk-get/sdk-get.spec.tsx +++ b/packages/sdk/src/components/sdk-get/sdk-get.spec.tsx @@ -1,9 +1,12 @@ +import type { ShallowWrapper } from 'enzyme'; +import type { Props } from './sdk-get'; +import type { Json } from '../../types'; + import { mocked } from 'ts-jest/utils'; import React from 'react'; -import { shallow, ShallowWrapper } from 'enzyme'; +import { shallow } from 'enzyme'; import * as sdkActions from '../../actions'; -import { SdkGet, Props } from './sdk-get'; -import { Json } from '../../types'; +import { SdkGet } from './sdk-get'; const createTestProps = (custom: Partial = {}) => ({ dispatch: jest.fn(() => Promise.resolve({})), diff --git a/packages/sdk/src/components/sdk-get/sdk-get.tsx b/packages/sdk/src/components/sdk-get/sdk-get.tsx index 7a76c9b363..f032e43c46 100644 --- a/packages/sdk/src/components/sdk-get/sdk-get.tsx +++ b/packages/sdk/src/components/sdk-get/sdk-get.tsx @@ -1,9 +1,10 @@ +import type { ThunkDispatch } from 'redux-thunk'; +import type { SuccessResult, HttpErrorType } from '@commercetools/sdk-client'; +import type { TSdkAction } from '../../types'; + import React from 'react'; import { connect } from 'react-redux'; -import { ThunkDispatch } from 'redux-thunk'; import { deepEqual } from 'fast-equals'; -import { SuccessResult, HttpErrorType } from '@commercetools/sdk-client'; -import { TSdkAction } from '../../types'; type TSdkError = Error | HttpErrorType; type TActionCreatorArgs = unknown[]; diff --git a/packages/sdk/src/hooks/use-async-dispatch.ts b/packages/sdk/src/hooks/use-async-dispatch.ts index 7cc30dfc1d..dd9df47c3b 100644 --- a/packages/sdk/src/hooks/use-async-dispatch.ts +++ b/packages/sdk/src/hooks/use-async-dispatch.ts @@ -1,6 +1,7 @@ -import { Dispatch } from 'redux'; +import type { Dispatch } from 'redux'; +import type { TSdkAction } from '../types'; + import { useDispatch } from 'react-redux'; -import { TSdkAction } from '../types'; // Wraps `dispatch` and cast the return type to a Promise, as the middleware // returns a Promise. diff --git a/packages/sdk/src/middleware/client.ts b/packages/sdk/src/middleware/client.ts index a0438d808f..92a6a4b24e 100644 --- a/packages/sdk/src/middleware/client.ts +++ b/packages/sdk/src/middleware/client.ts @@ -1,13 +1,14 @@ -import { - createClient as createSdkClient, +import type { MiddlewareRequest, MiddlewareResponse, Next, } from '@commercetools/sdk-client'; +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + +import { createClient as createSdkClient } from '@commercetools/sdk-client'; import { createHttpMiddleware as createSdkHttpMiddleware } from '@commercetools/sdk-middleware-http'; import { createCorrelationIdMiddleware as createSdkCorrelationIdMiddleware } from '@commercetools/sdk-middleware-correlation-id'; import createHttpUserAgent from '@commercetools/http-user-agent'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; import { getMcApiUrl } from '../utils'; import version from '../version'; diff --git a/packages/sdk/src/middleware/middleware.spec.ts b/packages/sdk/src/middleware/middleware.spec.ts index 1c40b1567f..9519b4f5d1 100644 --- a/packages/sdk/src/middleware/middleware.spec.ts +++ b/packages/sdk/src/middleware/middleware.spec.ts @@ -1,11 +1,12 @@ +import type { SuccessResult, ClientRequest } from '@commercetools/sdk-client'; +import type { Json, TSdkAction } from '../types'; + import { mocked } from 'ts-jest/utils'; import { SHOW_LOADING, HIDE_LOADING, MC_API_PROXY_TARGETS, } from '@commercetools-frontend/constants'; -import { SuccessResult, ClientRequest } from '@commercetools/sdk-client'; -import { Json, TSdkAction } from '../types'; import * as sdkActions from '../actions'; import createMiddleware from './middleware'; import createClient from './client'; diff --git a/packages/sdk/src/middleware/middleware.ts b/packages/sdk/src/middleware/middleware.ts index f2c62c93a5..0dcefbc3d1 100644 --- a/packages/sdk/src/middleware/middleware.ts +++ b/packages/sdk/src/middleware/middleware.ts @@ -1,17 +1,18 @@ -import { Action, Dispatch, MiddlewareAPI } from 'redux'; +import type { Action, Dispatch, MiddlewareAPI } from 'redux'; +import type { HttpErrorType } from '@commercetools/sdk-client'; +import type { + TSdkAction, + TSdkActionPayload, + TSdkActionPayloadForUri, +} from '../types'; + import { createRequestBuilder } from '@commercetools/api-request-builder'; -import { HttpErrorType } from '@commercetools/sdk-client'; import { SHOW_LOADING, HIDE_LOADING, STATUS_CODES, } from '@commercetools-frontend/constants'; import { logRequest } from '../utils'; -import { - TSdkAction, - TSdkActionPayload, - TSdkActionPayloadForUri, -} from '../types'; import createClient from './client'; const isSdkActionForUri = ( diff --git a/packages/sdk/src/test-utils/test-utils.spec.ts b/packages/sdk/src/test-utils/test-utils.spec.ts index b8a37f2685..07166aab69 100644 --- a/packages/sdk/src/test-utils/test-utils.spec.ts +++ b/packages/sdk/src/test-utils/test-utils.spec.ts @@ -1,5 +1,6 @@ +import type { TSdkAction, Json } from '../types'; + import { getErrorByCode } from '@commercetools/sdk-middleware-http'; -import { TSdkAction, Json } from '../types'; import * as sdkActions from '../actions'; import { createTestMiddleware } from './test-utils'; diff --git a/packages/sdk/src/test-utils/test-utils.ts b/packages/sdk/src/test-utils/test-utils.ts index 253865bd95..7649ff27e4 100644 --- a/packages/sdk/src/test-utils/test-utils.ts +++ b/packages/sdk/src/test-utils/test-utils.ts @@ -1,9 +1,10 @@ +import type { Action, Dispatch } from 'redux'; +import type { HttpErrorType } from '@commercetools/sdk-client'; +import type { TSdkAction, Json } from '../types'; + import { deepEqual } from 'fast-equals'; -import { Action, Dispatch } from 'redux'; // eslint-disable-next-line import/named import { v4 as uuid } from 'uuid'; -import { HttpErrorType } from '@commercetools/sdk-client'; -import { TSdkAction, Json } from '../types'; interface TSdkMockBase { action: TSdkAction; diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 62420fa4dd..ed54589238 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1,4 +1,4 @@ -import { TMcApiProxyTargets } from '@commercetools-frontend/constants'; +import type { TMcApiProxyTargets } from '@commercetools-frontend/constants'; export type Json = { [key: string]: unknown }; diff --git a/packages/sdk/src/utils/utils.spec.ts b/packages/sdk/src/utils/utils.spec.ts index 85f63c3591..9e1a6ef058 100644 --- a/packages/sdk/src/utils/utils.spec.ts +++ b/packages/sdk/src/utils/utils.spec.ts @@ -1,5 +1,7 @@ +import type { ApplicationWindow } from './utils'; + import { decode } from 'qss'; -import { parseUri, getMcApiUrl, ApplicationWindow } from './utils'; +import { parseUri, getMcApiUrl } from './utils'; type Result = { pathname: string; search: ReturnType }; diff --git a/packages/sdk/src/utils/utils.ts b/packages/sdk/src/utils/utils.ts index 8846b1686b..0dd5e35574 100644 --- a/packages/sdk/src/utils/utils.ts +++ b/packages/sdk/src/utils/utils.ts @@ -1,6 +1,7 @@ +import type { THttpMethod, TSdkAction, Json, TSdkActionPost } from '../types'; + import { decode } from 'qss'; import logger from './logger'; -import { THttpMethod, TSdkAction, Json, TSdkActionPost } from '../types'; type LogRequestParams = { method: THttpMethod; diff --git a/packages/sentry/src/sentry-user-logout-tracker/sentry-user-logout-tracker.tsx b/packages/sentry/src/sentry-user-logout-tracker/sentry-user-logout-tracker.tsx index 7f0e8298c3..48dda1ab54 100644 --- a/packages/sentry/src/sentry-user-logout-tracker/sentry-user-logout-tracker.tsx +++ b/packages/sentry/src/sentry-user-logout-tracker/sentry-user-logout-tracker.tsx @@ -1,6 +1,7 @@ +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import React from 'react'; import * as Sentry from '@sentry/browser'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; declare let window: ApplicationWindow; diff --git a/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.spec.tsx b/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.spec.tsx index 74752847d0..4a00f9796f 100644 --- a/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.spec.tsx +++ b/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.spec.tsx @@ -1,7 +1,8 @@ +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import React from 'react'; import { render } from '@testing-library/react'; import * as Sentry from '@sentry/browser'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; import SentryUserTracker from './sentry-user-tracker'; declare let window: ApplicationWindow; diff --git a/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.tsx b/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.tsx index 3d6d470d5f..8f085b38b0 100644 --- a/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.tsx +++ b/packages/sentry/src/sentry-user-tracker/sentry-user-tracker.tsx @@ -1,6 +1,7 @@ +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import React from 'react'; import * as Sentry from '@sentry/browser'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; declare let window: ApplicationWindow; diff --git a/packages/sentry/src/sentry.ts b/packages/sentry/src/sentry.ts index 4a1e076294..983d31f628 100644 --- a/packages/sentry/src/sentry.ts +++ b/packages/sentry/src/sentry.ts @@ -1,5 +1,6 @@ +import type { ApplicationWindow } from '@commercetools-frontend/constants'; + import * as Sentry from '@sentry/browser'; -import { ApplicationWindow } from '@commercetools-frontend/constants'; declare let window: ApplicationWindow;