refactor: enforce type import specifiers (#6230)

* refactor: enforce type import specifiers

* fix

* Upgrade esbuild

* Fix (haha)
This commit is contained in:
Joshua Chen 2021-12-31 21:17:09 +08:00 committed by GitHub
parent 24d65d9bdd
commit cb1aa30286
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
192 changed files with 484 additions and 337 deletions

View file

@ -6,7 +6,7 @@
*/
import {getTranslationFiles, translateThemeConfig} from '../translations';
import {ThemeConfig} from '@docusaurus/theme-common';
import type {ThemeConfig} from '@docusaurus/theme-common';
import {updateTranslationFileMessages} from '@docusaurus/utils';
const ThemeConfigSample: ThemeConfig = {

View file

@ -5,7 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
import {DocusaurusContext, Plugin, PostCssOptions} from '@docusaurus/types';
import type {
DocusaurusContext,
Plugin,
PostCssOptions,
} from '@docusaurus/types';
import type {ThemeConfig} from '@docusaurus/theme-common';
import {getTranslationFiles, translateThemeConfig} from './translations';
import path from 'path';

View file

@ -107,7 +107,7 @@ declare module '@theme/BlogLayout' {
}
declare module '@theme/CodeBlock' {
import {ReactElement} from 'react';
import type {ReactElement} from 'react';
export interface Props {
readonly children: string | ReactElement;
@ -182,7 +182,7 @@ declare module '@theme/EditThisPage' {
}
declare module '@theme/ErrorPageContent' {
import ErrorComponent from '@theme/Error';
import type ErrorComponent from '@theme/Error';
const ErrorPageContent: typeof ErrorComponent;
export default ErrorPageContent;
@ -220,7 +220,7 @@ declare module '@theme/hooks/useLockBodyScroll' {
}
declare module '@theme/hooks/usePrismTheme' {
import defaultTheme from 'prism-react-renderer/themes/palenight';
import type defaultTheme from 'prism-react-renderer/themes/palenight';
const usePrismTheme: () => typeof defaultTheme;
export default usePrismTheme;
@ -582,7 +582,7 @@ declare module '@theme/ThemedImage' {
}
declare module '@theme/Details' {
import {Details, DetailsProps} from '@docusaurus/theme-common';
import {Details, type DetailsProps} from '@docusaurus/theme-common';
export interface Props extends DetailsProps {}
export default Details;

View file

@ -7,7 +7,7 @@
import React from 'react';
import clsx from 'clsx';
import {Props} from '@theme/Admonition';
import type {Props} from '@theme/Admonition';
const icons = {
note: (

View file

@ -7,7 +7,7 @@
import React, {isValidElement, useEffect, useState} from 'react';
import clsx from 'clsx';
import Highlight, {defaultProps, Language} from 'prism-react-renderer';
import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
import copy from 'copy-text-to-clipboard';
import Translate, {translate} from '@docusaurus/Translate';
import {

View file

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {ReactNode} from 'react';
import React, {type ReactNode} from 'react';
import Link from '@docusaurus/Link';
import {
import type {
PropSidebarItemCategory,
PropSidebarItemLink,
} from '@docusaurus/plugin-content-docs';

View file

@ -8,7 +8,7 @@
import React from 'react';
import DocCard from '@theme/DocCard';
import {PropSidebarItem} from '@docusaurus/plugin-content-docs';
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
export default function DocCardList({
items,

View file

@ -12,7 +12,7 @@ import LastUpdated from '@theme/LastUpdated';
import type {Props} from '@theme/DocItem';
import EditThisPage from '@theme/EditThisPage';
import TagsListInline, {
Props as TagsListInlineProps,
type Props as TagsListInlineProps,
} from '@theme/TagsListInline';
import styles from './styles.module.css';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {ReactNode, useState, useCallback} from 'react';
import React, {type ReactNode, useState, useCallback} from 'react';
import {MDXProvider} from '@mdx-js/react';
import renderRoutes from '@docusaurus/renderRoutes';

View file

@ -11,7 +11,7 @@ import {
useThemeConfig,
useAnnouncementBar,
MobileSecondaryMenuFiller,
MobileSecondaryMenuComponent,
type MobileSecondaryMenuComponent,
ThemeClassNames,
useScrollPosition,
} from '@docusaurus/theme-common';

View file

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {ComponentType} from 'react';
import React, {type ComponentType} from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import Translate from '@docusaurus/Translate';
import {
useActivePlugin,
useDocVersionSuggestions,
GlobalVersion,
type GlobalVersion,
} from '@theme/hooks/useDocs';
import {
ThemeClassNames,

View file

@ -10,15 +10,15 @@ import clsx from 'clsx';
import Link from '@docusaurus/Link';
import {
FooterLinkItem,
type FooterLinkItem,
useThemeConfig,
MultiColumnFooter,
SimpleFooter,
type MultiColumnFooter,
type SimpleFooter,
} from '@docusaurus/theme-common';
import useBaseUrl from '@docusaurus/useBaseUrl';
import isInternalUrl from '@docusaurus/isInternalUrl';
import styles from './styles.module.css';
import ThemedImage, {Props as ThemedImageProps} from '@theme/ThemedImage';
import ThemedImage, {type Props as ThemedImageProps} from '@theme/ThemedImage';
import IconExternalLink from '@theme/IconExternalLink';
function FooterLink({

View file

@ -5,7 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {ComponentProps, isValidElement, ReactElement} from 'react';
import React, {
type ComponentProps,
isValidElement,
type ReactElement,
} from 'react';
import Head from '@docusaurus/Head';
import Link from '@docusaurus/Link';
import CodeBlock from '@theme/CodeBlock';

View file

@ -21,7 +21,7 @@ import useHideableNavbar from '@theme/hooks/useHideableNavbar';
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
import useWindowSize from '@theme/hooks/useWindowSize';
import {useActivePlugin} from '@theme/hooks/useDocs';
import NavbarItem, {Props as NavbarItemConfig} from '@theme/NavbarItem';
import NavbarItem, {type Props as NavbarItemConfig} from '@theme/NavbarItem';
import Logo from '@theme/Logo';
import IconMenu from '@theme/IconMenu';
import IconClose from '@theme/IconClose';

View file

@ -10,7 +10,7 @@ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import {
useActiveVersion,
useLatestVersion,
GlobalVersion,
type GlobalVersion,
} from '@theme/hooks/useDocs';
import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
import {useDocsPreferredVersion} from '@docusaurus/theme-common';

View file

@ -8,7 +8,7 @@
import React from 'react';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import DropdownNavbarItem, {
Props as DropdownNavbarItemProps,
type Props as DropdownNavbarItemProps,
} from '@theme/NavbarItem/DropdownNavbarItem';
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';

View file

@ -7,9 +7,9 @@
import React, {useMemo} from 'react';
import type {TOCItemsProps} from '@theme/TOCItems';
import {TOCItem} from '@docusaurus/types';
import type {TOCItem} from '@docusaurus/types';
import {
TOCHighlightConfig,
type TOCHighlightConfig,
useThemeConfig,
useTOCFilter,
useTOCHighlight,

View file

@ -10,7 +10,7 @@ import React, {
cloneElement,
Children,
isValidElement,
ReactElement,
type ReactElement,
} from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';
import useUserPreferencesContext from '@theme/hooks/useUserPreferencesContext';

View file

@ -8,7 +8,7 @@
import React from 'react';
import Tag from '@theme/Tag';
import type {Props} from '@theme/TagsListByLetter';
import {listTagsByLetters, TagLetterEntry} from '@docusaurus/theme-common';
import {listTagsByLetters, type TagLetterEntry} from '@docusaurus/theme-common';
import styles from './styles.module.css';

View file

@ -7,7 +7,7 @@
import React, {useState, useRef, memo} from 'react';
import type {Props} from '@theme/Toggle';
import {useThemeConfig, ColorModeConfig} from '@docusaurus/theme-common';
import {useThemeConfig, type ColorModeConfig} from '@docusaurus/theme-common';
import useIsBrowser from '@docusaurus/useIsBrowser';
import clsx from 'clsx';

View file

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import {TranslationFile, TranslationFileContent} from '@docusaurus/types';
import {
import type {TranslationFile, TranslationFileContent} from '@docusaurus/types';
import type {
ThemeConfig,
Navbar,
NavbarItem,