From 938cf8c4beb192aa68ddb11f06c784d273bcba6a Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Sat, 26 Mar 2022 21:56:48 +0300 Subject: [PATCH] refactor: minor code improvements --- .../swizzle/__tests__/__snapshots__/actions.test.ts.snap | 6 +++--- .../swizzle/__tests__/__snapshots__/index.test.ts.snap | 8 ++++---- packages/docusaurus/src/commands/swizzle/actions.ts | 4 ++-- packages/docusaurus/src/commands/swizzle/index.ts | 4 ++-- .../server/__tests__/__snapshots__/config.test.ts.snap | 2 +- .../__tests__/__snapshots__/configValidation.test.ts.snap | 4 ++-- packages/docusaurus/src/server/configValidation.ts | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/actions.test.ts.snap b/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/actions.test.ts.snap index 7473f7a0233d..3483ffb8a487 100644 --- a/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/actions.test.ts.snap +++ b/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/actions.test.ts.snap @@ -47,7 +47,7 @@ exports[`wrap TypeScript wrap ComponentInFolder 2`] = ` import type ComponentInFolderType from '@theme/ComponentInFolder'; import ComponentInFolder from '@theme-original/ComponentInFolder'; -type Props = ComponentProps +type Props = ComponentProps; export default function ComponentInFolderWrapper(props: Props): JSX.Element { return ( @@ -64,7 +64,7 @@ exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = ` import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder'; import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder'; -type Props = ComponentProps +type Props = ComponentProps; export default function ComponentInSubFolderWrapper(props: Props): JSX.Element { return ( @@ -81,7 +81,7 @@ exports[`wrap TypeScript wrap FirstLevelComponent 2`] = ` import type FirstLevelComponentType from '@theme/FirstLevelComponent'; import FirstLevelComponent from '@theme-original/FirstLevelComponent'; -type Props = ComponentProps +type Props = ComponentProps; export default function FirstLevelComponentWrapper(props: Props): JSX.Element { return ( diff --git a/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/index.test.ts.snap index faeadf641e2f..e48def8da891 100644 --- a/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/index.test.ts.snap @@ -275,7 +275,7 @@ exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = ` import type ComponentInFolderType from '@theme/ComponentInFolder'; import ComponentInFolder from '@theme-original/ComponentInFolder'; -type Props = ComponentProps +type Props = ComponentProps; export default function ComponentInFolderWrapper(props: Props): JSX.Element { return ( @@ -319,7 +319,7 @@ exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFold import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder'; import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder'; -type Props = ComponentProps +type Props = ComponentProps; export default function ComponentInSubFolderWrapper(props: Props): JSX.Element { return ( @@ -363,7 +363,7 @@ exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.ts import type SiblingType from '@theme/ComponentInFolder/Sibling'; import Sibling from '@theme-original/ComponentInFolder/Sibling'; -type Props = ComponentProps +type Props = ComponentProps; export default function SiblingWrapper(props: Props): JSX.Element { return ( @@ -405,7 +405,7 @@ exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = ` import type FirstLevelComponentType from '@theme/FirstLevelComponent'; import FirstLevelComponent from '@theme-original/FirstLevelComponent'; -type Props = ComponentProps +type Props = ComponentProps; export default function FirstLevelComponentWrapper(props: Props): JSX.Element { return ( diff --git a/packages/docusaurus/src/commands/swizzle/actions.ts b/packages/docusaurus/src/commands/swizzle/actions.ts index f85bfb7a0f79..6f3c2208f0d7 100644 --- a/packages/docusaurus/src/commands/swizzle/actions.ts +++ b/packages/docusaurus/src/commands/swizzle/actions.ts @@ -84,7 +84,7 @@ export async function eject({ await fs.copy(sourceFile, targetFile, {overwrite: true}); } catch (err) { throw new Error( - logger.interpolate`Could not copy file from ${sourceFile} to ${targetFile}`, + logger.interpolate`Could not copy file from path=${sourceFile} to path=${targetFile}`, ); } return targetFile; @@ -122,7 +122,7 @@ export async function wrap({ import type ${componentName}Type from '@theme/${themeComponentName}'; import ${componentName} from '@theme-${importType}/${themeComponentName}'; -type Props = ComponentProps +type Props = ComponentProps; export default function ${wrapperComponentName}(props: Props): JSX.Element { return ( diff --git a/packages/docusaurus/src/commands/swizzle/index.ts b/packages/docusaurus/src/commands/swizzle/index.ts index a391bd1cc906..604b7266c96d 100644 --- a/packages/docusaurus/src/commands/swizzle/index.ts +++ b/packages/docusaurus/src/commands/swizzle/index.ts @@ -133,7 +133,7 @@ export default async function swizzle( typescript, }); logger.success` -Created wrapper of name=${componentName} from name=${themeName} in path=${result.createdFiles}. +Created wrapper of name=${componentName} from name=${themeName} in path=${result.createdFiles} `; return result; } @@ -144,7 +144,7 @@ Created wrapper of name=${componentName} from name=${themeName} in path=${result componentName, }); logger.success` -Ejected name=${componentName} from name=${themeName} to path=${result.createdFiles}. +Ejected name=${componentName} from name=${themeName} to path=${result.createdFiles} `; return result; } diff --git a/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap b/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap index 05963da88ac7..01a7674fb5c0 100644 --- a/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap +++ b/packages/docusaurus/src/server/__tests__/__snapshots__/config.test.ts.snap @@ -8,7 +8,7 @@ exports[`loadConfig website with incomplete siteConfig 1`] = ` exports[`loadConfig website with useless field (wrong field) in siteConfig 1`] = ` "These field(s) (\\"useLessField\\",) are not recognized in docusaurus.config.js. If you still want these fields to be in your configuration, put them in the \\"customFields\\" field. -See https://docusaurus.io/docs/docusaurus.config.js/#customfields" +See https://docusaurus.io/docs/api/docusaurus-config/#customfields" `; exports[`loadConfig website with valid async config 1`] = ` diff --git a/packages/docusaurus/src/server/__tests__/__snapshots__/configValidation.test.ts.snap b/packages/docusaurus/src/server/__tests__/__snapshots__/configValidation.test.ts.snap index 0c24cbaf8b8a..0d5185c5a678 100644 --- a/packages/docusaurus/src/server/__tests__/__snapshots__/configValidation.test.ts.snap +++ b/packages/docusaurus/src/server/__tests__/__snapshots__/configValidation.test.ts.snap @@ -153,11 +153,11 @@ exports[`normalizeConfig throws error for required fields 1`] = ` \\"stylesheets\\" must be an array These field(s) (\\"invalidField\\",) are not recognized in docusaurus.config.js. If you still want these fields to be in your configuration, put them in the \\"customFields\\" field. -See https://docusaurus.io/docs/docusaurus.config.js/#customfields" +See https://docusaurus.io/docs/api/docusaurus-config/#customfields" `; exports[`normalizeConfig throws error for unknown field 1`] = ` "These field(s) (\\"invalid\\",) are not recognized in docusaurus.config.js. If you still want these fields to be in your configuration, put them in the \\"customFields\\" field. -See https://docusaurus.io/docs/docusaurus.config.js/#customfields" +See https://docusaurus.io/docs/api/docusaurus-config/#customfields" `; diff --git a/packages/docusaurus/src/server/configValidation.ts b/packages/docusaurus/src/server/configValidation.ts index 4ad81037565b..a25659ae892e 100644 --- a/packages/docusaurus/src/server/configValidation.ts +++ b/packages/docusaurus/src/server/configValidation.ts @@ -258,7 +258,7 @@ export function validateConfig( '', ); formattedError = unknownFields - ? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/docusaurus.config.js/#customfields` + ? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/api/docusaurus-config/#customfields` : formattedError; throw new Error(formattedError); } else {