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

@ -92,6 +92,10 @@ module.exports = {
],
'react/no-unstable-nested-components': [WARNING, {allowAsProps: true}],
'@typescript-eslint/no-inferrable-types': OFF,
'@typescript-eslint/consistent-type-imports': [
WARNING,
{disallowTypeAnnotations: false},
],
'import/first': OFF,
'import/order': OFF,
'import/prefer-default-export': OFF,

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {HandlerEvent, HandlerResponse} from '@netlify/functions';
import type {HandlerEvent, HandlerResponse} from '@netlify/functions';
const CookieName = 'DocusaurusPlaygroundName';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {Handler} from '@netlify/functions';
import type {Handler} from '@netlify/functions';
import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {Handler} from '@netlify/functions';
import type {Handler} from '@netlify/functions';
import {
readPlaygroundName,

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {Handler} from '@netlify/functions';
import type {Handler} from '@netlify/functions';
import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';

View file

@ -87,8 +87,8 @@
"@types/shelljs": "^0.8.6",
"@types/wait-on": "^5.2.0",
"@types/webpack-dev-server": "^4.5.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"concurrently": "^6.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.2.0",

View file

@ -8,7 +8,7 @@
import logger from '@docusaurus/logger';
import fs from 'fs-extra';
import {execSync} from 'child_process';
import prompts, {Choice} from 'prompts';
import prompts, {type Choice} from 'prompts';
import path from 'path';
import shell from 'shelljs';
import {kebabCase, sortBy} from 'lodash';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import chalk, {Chalk} from 'chalk';
import chalk, {type Chalk} from 'chalk';
type InterpolatableValue = string | number | (string | number)[];

View file

@ -8,7 +8,7 @@
/* Based on remark-slug (https://github.com/remarkjs/remark-slug) and gatsby-remark-autolink-headers (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-autolink-headers) */
import {parseMarkdownHeadingId, createSlugger} from '@docusaurus/utils';
import visit, {Visitor} from 'unist-util-visit';
import visit, {type Visitor} from 'unist-util-visit';
import toString from 'mdast-util-to-string';
import type {Transformer} from 'unified';
import type {Parent} from 'unist';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {parse, ParserOptions} from '@babel/parser';
import {parse, type ParserOptions} from '@babel/parser';
import type {Identifier} from '@babel/types';
import traverse from '@babel/traverse';
import stringifyObject from 'stringify-object';

View file

@ -6,7 +6,7 @@
*/
import toString from 'mdast-util-to-string';
import visit, {Visitor} from 'unist-util-visit';
import visit from 'unist-util-visit';
import {toValue} from '../utils';
import type {TOCItem} from '@docusaurus/types';
import type {Node} from 'unist';
@ -26,7 +26,7 @@ interface SearchItem {
export default function search(node: Node): TOCItem[] {
const headings: SearchItem[] = [];
const visitor: Visitor<Heading> = (child, _index, parent) => {
visit(node, 'heading', (child: Heading, _index, parent) => {
const value = toString(child);
// depth:1 headings are titles and not included in the TOC
@ -44,9 +44,7 @@ export default function search(node: Node): TOCItem[] {
level: child.depth,
parentIndex: -1,
});
};
visit(node, 'heading', visitor);
});
// Keep track of which previous index would be the current heading's direcy parent.
// Each entry <i> is the last index of the `headings` array at heading level <i>.

View file

@ -7,7 +7,7 @@
import importFresh from 'import-fresh';
import {createConfigFile} from '../index';
import {VersionOneConfig} from '../types';
import type {VersionOneConfig} from '../types';
describe('create config', () => {
test('simple test', () => {

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {RawData, Data} from './types';
import type {RawData, Data} from './types';
function splitHeader(content: string): RawData {
// New line characters need to handle all operating systems.

View file

@ -11,7 +11,7 @@ import logger from '@docusaurus/logger';
import glob from 'glob';
import Color from 'color';
import {
import type {
ClassicPresetEntries,
SidebarEntry,
SidebarEntries,

View file

@ -6,11 +6,11 @@
*/
import jscodeshift, {
ArrowFunctionExpression,
type ArrowFunctionExpression,
AssignmentExpression,
ASTPath,
Collection,
TemplateElement,
type ASTPath,
type Collection,
type TemplateElement,
VariableDeclarator,
} from 'jscodeshift';

View file

@ -120,7 +120,7 @@ declare module '@docusaurus/constants' {
declare module '@docusaurus/ErrorBoundary' {
import type {ReactNode} from 'react';
import ErrorComponent from '@theme/Error';
import type ErrorComponent from '@theme/Error';
export interface Props {
readonly fallback?: typeof ErrorComponent;

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {PluginContext, UserPluginOptions} from '../types';
import type {PluginContext, UserPluginOptions} from '../types';
import collectRedirects from '../collectRedirects';
import normalizePluginOptions from '../normalizePluginOptions';
import {removeTrailingSlash} from '@docusaurus/utils';

View file

@ -8,7 +8,7 @@
import normalizePluginOptions, {
DefaultPluginOptions,
} from '../normalizePluginOptions';
import {CreateRedirectsFnOption} from '../types';
import type {CreateRedirectsFnOption} from '../types';
describe('normalizePluginOptions', () => {
test('should return default options for undefined user options', () => {

View file

@ -6,7 +6,7 @@
*/
import {uniqBy, difference, groupBy} from 'lodash';
import {
import type {
PluginContext,
RedirectMetadata,
PluginOptions,
@ -19,7 +19,7 @@ import {
import {validateRedirect} from './redirectValidation';
import {
applyTrailingSlash,
ApplyTrailingSlashParams,
type ApplyTrailingSlashParams,
} from '@docusaurus/utils-common';
import logger from '@docusaurus/logger';

View file

@ -10,7 +10,7 @@ import {
removeSuffix,
removeTrailingSlash,
} from '@docusaurus/utils';
import {RedirectMetadata} from './types';
import type {RedirectMetadata} from './types';
const ExtensionAdditionalMessage =
'If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the "createRedirects" plugin option.';

View file

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/
import {LoadContext, Plugin, Props} from '@docusaurus/types';
import {UserPluginOptions, PluginContext, RedirectMetadata} from './types';
import type {LoadContext, Plugin, Props} from '@docusaurus/types';
import type {UserPluginOptions, PluginContext, RedirectMetadata} from './types';
import normalizePluginOptions from './normalizePluginOptions';
import collectRedirects from './collectRedirects';
import writeRedirectFiles, {
toRedirectFilesMetadata,
RedirectFileMetadata,
type RedirectFileMetadata,
} from './writeRedirectFiles';
import {removePrefix, addLeadingSlash} from '@docusaurus/utils';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {PluginOptions, RedirectOption, UserPluginOptions} from './types';
import type {PluginOptions, RedirectOption, UserPluginOptions} from './types';
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {RedirectMetadata} from './types';
import type {RedirectMetadata} from './types';
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
const RedirectSchema = Joi.object<RedirectMetadata>({

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {Props} from '@docusaurus/types';
import type {Props} from '@docusaurus/types';
export type PluginOptions = {
id: string;

View file

@ -9,7 +9,7 @@ import fs from 'fs-extra';
import path from 'path';
import {memoize} from 'lodash';
import {PluginContext, RedirectMetadata} from './types';
import type {PluginContext, RedirectMetadata} from './types';
import createRedirectPageContent from './createRedirectPageContent';
import {normalizeUrl} from '@docusaurus/utils';

View file

@ -6,7 +6,7 @@
*/
import {
BlogPostFrontMatter,
type BlogPostFrontMatter,
validateBlogPostFrontMatter,
} from '../blogFrontMatter';
import escapeStringRegexp from 'escape-string-regexp';

View file

@ -7,11 +7,11 @@
import path from 'path';
import {generateBlogFeed} from '../feed';
import {LoadContext, I18n} from '@docusaurus/types';
import {PluginOptions, BlogContentPaths} from '../types';
import type {LoadContext, I18n} from '@docusaurus/types';
import type {PluginOptions, BlogContentPaths} from '../types';
import {DEFAULT_OPTIONS} from '../pluginOptionSchema';
import {generateBlogPosts} from '../blogUtils';
import {Feed} from 'feed';
import type {Feed} from 'feed';
const DefaultI18N: I18n = {
currentLocale: 'en',

View file

@ -8,10 +8,10 @@
import fs from 'fs-extra';
import path from 'path';
import pluginContentBlog from '../index';
import {DocusaurusConfig, LoadContext, I18n} from '@docusaurus/types';
import type {DocusaurusConfig, LoadContext, I18n} from '@docusaurus/types';
import {PluginOptionSchema} from '../pluginOptionSchema';
import {PluginOptions, EditUrlFunction, BlogPost} from '../types';
import {Joi} from '@docusaurus/utils-validation';
import type {PluginOptions, EditUrlFunction, BlogPost} from '../types';
import type {Joi} from '@docusaurus/utils-validation';
import {posixPath} from '@docusaurus/utils';
function findByTitle(

View file

@ -7,8 +7,12 @@
import fs from 'fs-extra';
import path from 'path';
import {linkify, LinkifyParams, getSourceToPermalink} from '../blogUtils';
import {BlogBrokenMarkdownLink, BlogContentPaths, BlogPost} from '../types';
import {linkify, type LinkifyParams, getSourceToPermalink} from '../blogUtils';
import type {
BlogBrokenMarkdownLink,
BlogContentPaths,
BlogPost,
} from '../types';
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const contentPaths: BlogContentPaths = {

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {BlogPost, BlogContent, PluginOptions} from '../types';
import type {BlogPost, BlogContent, PluginOptions} from '../types';
import {getTranslationFiles, translateContent} from '../translations';
import {DEFAULT_OPTIONS} from '../pluginOptionSchema';
import {updateTranslationFileMessages} from '@docusaurus/utils';

View file

@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/
import {Author, BlogContentPaths} from './types';
import type {Author, BlogContentPaths} from './types';
import {getDataFileData} from '@docusaurus/utils';
import {Joi, URISchema} from '@docusaurus/utils-validation';
import {
import type {
BlogPostFrontMatter,
BlogPostFrontMatterAuthor,
BlogPostFrontMatterAuthors,

View file

@ -9,7 +9,7 @@ import fs from 'fs-extra';
import path from 'path';
import readingTime from 'reading-time';
import {keyBy, mapValues} from 'lodash';
import {
import type {
PluginOptions,
BlogPost,
BlogContentPaths,
@ -30,9 +30,9 @@ import {
groupTaggedItems,
getContentPathList,
} from '@docusaurus/utils';
import {LoadContext} from '@docusaurus/types';
import type {LoadContext} from '@docusaurus/types';
import {validateBlogPostFrontMatter} from './blogFrontMatter';
import {AuthorsMap, getAuthorsMap, getBlogPostAuthors} from './authors';
import {type AuthorsMap, getAuthorsMap, getBlogPostAuthors} from './authors';
import logger from '@docusaurus/logger';
export function truncate(fileString: string, truncateMarker: RegExp): string {

View file

@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/
import {Feed, Author as FeedAuthor, Item as FeedItem} from 'feed';
import {PluginOptions, Author, BlogPost, FeedType} from './types';
import {Feed, type Author as FeedAuthor, type Item as FeedItem} from 'feed';
import type {PluginOptions, Author, BlogPost, FeedType} from './types';
import {normalizeUrl, mdxToHtml} from '@docusaurus/utils';
import {DocusaurusConfig} from '@docusaurus/types';
import type {DocusaurusConfig} from '@docusaurus/types';
import path from 'path';
import fs from 'fs-extra';

View file

@ -22,7 +22,7 @@ import {
} from '@docusaurus/utils';
import {translateContent, getTranslationFiles} from './translations';
import {
import type {
PluginOptions,
BlogTags,
BlogContent,
@ -35,7 +35,7 @@ import {
Assets,
} from './types';
import {PluginOptionSchema} from './pluginOptionSchema';
import {
import type {
LoadContext,
ConfigureWebpackUtils,
Props,
@ -44,13 +44,13 @@ import {
OptionValidationContext,
ValidationResult,
} from '@docusaurus/types';
import {Configuration} from 'webpack';
import type {Configuration} from 'webpack';
import {
generateBlogPosts,
getSourceToPermalink,
getBlogTags,
} from './blogUtils';
import {BlogPostFrontMatter} from './blogFrontMatter';
import type {BlogPostFrontMatter} from './blogFrontMatter';
import {createBlogFeedFiles} from './feed';
export default async function pluginContentBlog(

View file

@ -7,7 +7,7 @@
import {truncate, linkify} from './blogUtils';
import {parseQuery} from 'loader-utils';
import {BlogMarkdownLoaderOptions} from './types';
import type {BlogMarkdownLoaderOptions} from './types';
import type {LoaderContext} from 'webpack';
export default function markdownLoader(

View file

@ -13,7 +13,7 @@ import {
URISchema,
} from '@docusaurus/utils-validation';
import {GlobExcludeDefault} from '@docusaurus/utils';
import {PluginOptions} from './types';
import type {PluginOptions} from './types';
export const DEFAULT_OPTIONS: PluginOptions = {
feedOptions: {type: ['rss', 'atom'], copyright: ''},

View file

@ -11,8 +11,8 @@ import type {
BrokenMarkdownLink,
ContentPaths,
} from '@docusaurus/utils/lib/markdownLinks';
import {Overwrite} from 'utility-types';
import {BlogPostFrontMatter} from './blogFrontMatter';
import type {Overwrite} from 'utility-types';
import type {BlogPostFrontMatter} from './blogFrontMatter';
export type BlogContentPaths = ContentPaths;

View file

@ -7,7 +7,7 @@
import path from 'path';
import {cliDocsVersionCommand} from '../cli';
import {PathOptions, SidebarOptions} from '../types';
import type {PathOptions, SidebarOptions} from '../types';
import fs from 'fs-extra';
import {
getVersionedDocsDirPath,

View file

@ -6,7 +6,7 @@
*/
import {validateDocFrontMatter} from '../docFrontMatter';
import {DocFrontMatter} from '../types';
import type {DocFrontMatter} from '../types';
import escapeStringRegexp from 'escape-string-regexp';
function testField(params: {

View file

@ -27,7 +27,7 @@ import type {
} from '../types';
import type {LoadContext} from '@docusaurus/types';
import {DEFAULT_OPTIONS} from '../options';
import {Optional} from 'utility-types';
import type {Optional} from 'utility-types';
import {createSlugger, posixPath, DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
import {createSidebarsUtils} from '../sidebars/utils';

View file

@ -13,7 +13,7 @@ import {
DisabledNumberPrefixParser,
} from '../numberPrefix';
import {GlobExcludeDefault} from '@docusaurus/utils';
import {PluginOptions} from '../types';
import type {PluginOptions} from '../types';
// the type of remark/rehype plugins is function
const markdownPluginsFunctionStub = () => {};

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {LoadedContent, DocMetadata, LoadedVersion} from '../types';
import type {LoadedContent, DocMetadata, LoadedVersion} from '../types';
import {CURRENT_VERSION_NAME} from '../constants';
import {
getLoadedContentTranslationFiles,

View file

@ -14,7 +14,7 @@ import {
} from '../versions';
import {DEFAULT_OPTIONS} from '../options';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
import {PluginOptions, VersionMetadata} from '../types';
import type {PluginOptions, VersionMetadata} from '../types';
import type {I18n} from '@docusaurus/types';
const DefaultI18N: I18n = {

View file

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import {CategoryGeneratedIndexMetadata, DocMetadataBase} from './types';
import {SidebarItemCategoryWithGeneratedIndex} from './sidebars/types';
import {SidebarsUtils, toNavigationLink} from './sidebars/utils';
import type {CategoryGeneratedIndexMetadata, DocMetadataBase} from './types';
import type {SidebarItemCategoryWithGeneratedIndex} from './sidebars/types';
import {type SidebarsUtils, toNavigationLink} from './sidebars/utils';
import {createDocsByIdIndex} from './docs';
function getCategoryGeneratedIndexMetadata({

View file

@ -6,14 +6,14 @@
*/
import {
ActivePlugin,
type ActivePlugin,
getActivePlugin,
getLatestVersion,
getActiveDocContext,
getActiveVersion,
getDocVersionSuggestions,
} from '../docsClientUtils';
import {GlobalPluginData, GlobalVersion} from '../../types';
import type {GlobalPluginData, GlobalVersion} from '../../types';
import {shuffle} from 'lodash';
describe('docsClientUtils', () => {

View file

@ -7,7 +7,7 @@
import {matchPath} from '@docusaurus/router';
import {GlobalPluginData, GlobalVersion, GlobalDoc} from '../types';
import type {GlobalPluginData, GlobalVersion, GlobalDoc} from '../types';
// This code is not part of the api surface, not in ./theme on purpose

View file

@ -22,7 +22,7 @@ import {
import type {LoadContext} from '@docusaurus/types';
import {getFileLastUpdate} from './lastUpdate';
import {
import type {
DocFile,
DocMetadataBase,
DocMetadata,
@ -38,11 +38,8 @@ import {CURRENT_VERSION_NAME} from './constants';
import {getDocsDirPaths} from './versions';
import {stripPathNumberPrefixes} from './numberPrefix';
import {validateDocFrontMatter} from './docFrontMatter';
import {
SidebarsUtils,
toDocNavigationLink,
toNavigationLink,
} from './sidebars/utils';
import type {SidebarsUtils} from './sidebars/utils';
import {toDocNavigationLink, toNavigationLink} from './sidebars/utils';
type LastUpdateOptions = Pick<
PluginOptions,

View file

@ -29,7 +29,7 @@ import {
} from './docs';
import {getDocsDirPaths, readVersionsMetadata} from './versions';
import {
import type {
PluginOptions,
LoadedContent,
SourceToPermalink,

View file

@ -8,7 +8,7 @@
import fs from 'fs-extra';
import path from 'path';
import {linkify} from '../linkify';
import {
import type {
DocsMarkdownOption,
SourceToPermalink,
VersionMetadata,

View file

@ -6,7 +6,7 @@
*/
import {linkify} from './linkify';
import {DocsMarkdownOption} from '../types';
import type {DocsMarkdownOption} from '../types';
import type {LoaderContext} from 'webpack';
export default function markdownLoader(

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {DocsMarkdownOption} from '../types';
import type {DocsMarkdownOption} from '../types';
import {getDocsDirPaths} from '../versions';
import {replaceMarkdownLinks} from '@docusaurus/utils';

View file

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
import {PluginContentLoadedActions, RouteConfig} from '@docusaurus/types';
import type {PluginContentLoadedActions, RouteConfig} from '@docusaurus/types';
import {docuHash, createSlugger} from '@docusaurus/utils';
import {
import type {
CategoryGeneratedIndexMetadata,
DocMetadata,
LoadedVersion,

View file

@ -5,8 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
import {CategoryMetadataFile, DefaultSidebarItemsGenerator} from '../generator';
import {Sidebar, SidebarItemsGenerator} from '../types';
import {
DefaultSidebarItemsGenerator,
type CategoryMetadataFile,
} from '../generator';
import type {Sidebar, SidebarItemsGenerator} from '../types';
import fs from 'fs-extra';
import {DefaultNumberPrefixParser} from '../../numberPrefix';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {processSidebars, SidebarProcessorParams} from '../processor';
import {processSidebars, type SidebarProcessorParams} from '../processor';
import type {
SidebarItem,
SidebarItemsGenerator,
@ -14,7 +14,7 @@ import type {
} from '../types';
import {DefaultSidebarItemsGenerator} from '../generator';
import {createSlugger} from '@docusaurus/utils';
import {VersionMetadata} from '../../types';
import type {VersionMetadata} from '../../types';
import {DefaultNumberPrefixParser} from '../../numberPrefix';
describe('processSidebars', () => {

View file

@ -12,12 +12,12 @@ import {
collectSidebarLinks,
transformSidebarItems,
collectSidebarsDocIds,
SidebarNavigation,
type SidebarNavigation,
toDocNavigationLink,
toNavigationLink,
} from '../utils';
import type {Sidebar, Sidebars} from '../types';
import {DocMetadataBase, DocNavLink} from '../../types';
import type {DocMetadataBase, DocNavLink} from '../../types';
describe('createSidebarsUtils', () => {
const sidebar1: Sidebar = [

View file

@ -6,8 +6,8 @@
*/
import {validateSidebars, validateCategoryMetadataFile} from '../validation';
import {CategoryMetadataFile} from '../generator';
import {SidebarsConfig} from '../types';
import type {CategoryMetadataFile} from '../generator';
import type {SidebarsConfig} from '../types';
describe('validateSidebars', () => {
// TODO add more tests

View file

@ -11,7 +11,7 @@ import type {SidebarsConfig, Sidebars, NormalizedSidebars} from './types';
import type {NormalizeSidebarsParams, PluginOptions} from '../types';
import {validateSidebars} from './validation';
import {normalizeSidebars} from './normalization';
import {processSidebars, SidebarProcessorParams} from './processor';
import {processSidebars, type SidebarProcessorParams} from './processor';
import path from 'path';
import {createSlugger} from '@docusaurus/utils';

View file

@ -30,7 +30,7 @@ import {DefaultSidebarItemsGenerator} from './generator';
import {mapValues, memoize, pick} from 'lodash';
import combinePromises from 'combine-promises';
import {normalizeItem} from './normalization';
import {Slugger} from '@docusaurus/utils';
import type {Slugger} from '@docusaurus/utils';
export type SidebarProcessorParams = {
sidebarItemsGenerator: SidebarItemsGeneratorOption;

View file

@ -5,14 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/
import type {Optional} from 'utility-types';
import type {Optional, Required} from 'utility-types';
import type {
DocMetadataBase,
VersionMetadata,
NumberPrefixParser,
SidebarOptions,
} from '../types';
import {Required} from 'utility-types';
// Makes all properties visible when hovering over the type
type Expand<T extends Record<string, unknown>> = {[P in keyof T]: T[P]};

View file

@ -15,17 +15,15 @@ import type {
SidebarItemType,
SidebarCategoriesShorthand,
SidebarItemConfig,
} from './types';
import {mapValues, difference, uniq} from 'lodash';
import {getElementsAround, toMessageRelativeFilePath} from '@docusaurus/utils';
import {DocMetadataBase, DocNavLink} from '../types';
import {
SidebarItemCategoryWithGeneratedIndex,
SidebarItemCategoryWithLink,
SidebarNavigationItem,
} from './types';
import {mapValues, difference, uniq} from 'lodash';
import {getElementsAround, toMessageRelativeFilePath} from '@docusaurus/utils';
import type {DocMetadataBase, DocNavLink} from '../types';
export function isCategoriesShorthand(
item: SidebarItemConfig,
): item is SidebarCategoriesShorthand {

View file

@ -20,7 +20,7 @@ import type {
SidebarItemCategoryLinkGeneratedIndex,
} from './types';
import {isCategoriesShorthand} from './utils';
import {CategoryMetadataFile} from './generator';
import type {CategoryMetadataFile} from './generator';
const sidebarItemBaseSchema = Joi.object<SidebarItemBase>({
className: Joi.string(),

View file

@ -11,17 +11,17 @@ import useGlobalData, {
usePluginData,
} from '@docusaurus/useGlobalData';
import {GlobalPluginData, GlobalVersion} from '../../types';
import type {GlobalPluginData, GlobalVersion} from '../../types';
import {
getActivePlugin,
getLatestVersion,
getActiveVersion,
getActiveDocContext,
getDocVersionSuggestions,
ActivePlugin,
ActiveDocContext,
DocVersionSuggestions,
GetActivePluginOptions,
type ActivePlugin,
type ActiveDocContext,
type DocVersionSuggestions,
type GetActivePluginOptions,
} from '../../client/docsClientUtils';
// Important to use a constant object to avoid React useEffect executions etc...,

View file

@ -23,10 +23,10 @@ import type {
TranslationFileContent,
TranslationFile,
TranslationFiles,
TranslationMessage,
} from '@docusaurus/types';
import {mergeTranslations} from '@docusaurus/utils';
import {CURRENT_VERSION_NAME} from './constants';
import {TranslationMessage} from '@docusaurus/types';
function getVersionFileName(versionName: string): string {
if (versionName === CURRENT_VERSION_NAME) {

View file

@ -6,7 +6,7 @@
*/
import {PluginOptionSchema, DEFAULT_OPTIONS} from '../pluginOptionSchema';
import {PluginOptions} from '../types';
import type {PluginOptions} from '../types';
export default function normalizePluginOptions(
options: Partial<PluginOptions>,

View file

@ -20,18 +20,18 @@ import {
normalizeUrl,
DEFAULT_PLUGIN_ID,
} from '@docusaurus/utils';
import {
import type {
LoadContext,
Plugin,
OptionValidationContext,
ValidationResult,
ConfigureWebpackUtils,
} from '@docusaurus/types';
import {Configuration} from 'webpack';
import type {Configuration} from 'webpack';
import admonitions from 'remark-admonitions';
import {PluginOptionSchema} from './pluginOptionSchema';
import {
import type {
PluginOptions,
LoadedContent,
Metadata,

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {PluginOptions} from './types';
import type {PluginOptions} from './types';
import {
Joi,
RemarkPluginsSchema,

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {LoadContext, Plugin} from '@docusaurus/types';
import type {LoadContext, Plugin} from '@docusaurus/types';
import {docuHash, normalizeUrl, posixPath} from '@docusaurus/utils';
import path from 'path';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {ReactNode} from 'react';
import React, {type ReactNode} from 'react';
import Head from '@docusaurus/Head';
import Link from '@docusaurus/Link';
import styles from './styles.module.css';

View file

@ -13,7 +13,7 @@ import LogPlugin from '@docusaurus/core/lib/webpack/plugins/LogPlugin';
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
import path from 'path';
import webpack, {Configuration} from 'webpack';
import webpack, {type Configuration} from 'webpack';
import Terser from 'terser-webpack-plugin';
import {injectManifest} from 'workbox-build';

View file

@ -6,7 +6,7 @@
*/
import createSitemap from '../createSitemap';
import {DocusaurusConfig} from '@docusaurus/types';
import type {DocusaurusConfig} from '@docusaurus/types';
import {EnumChangefreq} from 'sitemap';
describe('createSitemap', () => {

View file

@ -7,7 +7,7 @@
import {SitemapStream, streamToPromise} from 'sitemap';
import type {Options} from '@docusaurus/plugin-sitemap';
import {DocusaurusConfig} from '@docusaurus/types';
import type {DocusaurusConfig} from '@docusaurus/types';
import {addTrailingSlash} from '@docusaurus/utils';
import {applyTrailingSlash} from '@docusaurus/utils-common';

View file

@ -9,7 +9,7 @@ import fs from 'fs-extra';
import path from 'path';
import type {Options} from '@docusaurus/plugin-sitemap';
import createSitemap from './createSitemap';
import {
import type {
LoadContext,
Props,
OptionValidationContext,

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {EnumChangefreq} from 'sitemap';
import type {EnumChangefreq} from 'sitemap';
export type Options = {
changefreq?: EnumChangefreq;

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,

View file

@ -11,10 +11,10 @@ import React, {
useEffect,
useRef,
useCallback,
RefObject,
Dispatch,
SetStateAction,
ReactNode,
type RefObject,
type Dispatch,
type SetStateAction,
type ReactNode,
useLayoutEffect,
} from 'react';

View file

@ -5,7 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {ComponentProps, ReactElement, useRef, useState} from 'react';
import React, {
type ComponentProps,
type ReactElement,
useRef,
useState,
} from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';
import clsx from 'clsx';
import {useCollapsible, Collapsible} from '../Collapsible';

View file

@ -17,7 +17,7 @@ import {
DocsSidebarProvider,
findSidebarCategory,
} from '../docsUtils';
import {
import type {
PropSidebar,
PropSidebarItem,
PropSidebarItemCategory,

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {TOCItem} from '@docusaurus/types';
import type {TOCItem} from '@docusaurus/types';
import {filterTOC} from '../tocUtils';
describe('filterTOC', () => {

View file

@ -10,7 +10,7 @@ import React, {
useEffect,
useCallback,
useMemo,
ReactNode,
type ReactNode,
useContext,
createContext,
} from 'react';

View file

@ -7,16 +7,16 @@
import React, {
createContext,
ReactNode,
type ReactNode,
useContext,
useEffect,
useMemo,
useState,
} from 'react';
import {useThemeConfig, DocsVersionPersistence} from '../useThemeConfig';
import {useThemeConfig, type DocsVersionPersistence} from '../useThemeConfig';
import {isDocsPluginEnabled} from '../docsUtils';
import {useAllDocsData, GlobalPluginData} from '@theme/hooks/useDocs';
import {useAllDocsData, type GlobalPluginData} from '@theme/hooks/useDocs';
import DocsPreferredVersionStorage from './DocsPreferredVersionStorage';

Some files were not shown because too many files have changed in this diff Show more