Skip to content

Commit

Permalink
refactor: minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Mar 26, 2022
1 parent 72f005e commit 938cf8c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof ComponentInFolderType>
type Props = ComponentProps<typeof ComponentInFolderType>;
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
return (
Expand All @@ -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<typeof ComponentInSubFolderType>
type Props = ComponentProps<typeof ComponentInSubFolderType>;
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
return (
Expand All @@ -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<typeof FirstLevelComponentType>
type Props = ComponentProps<typeof FirstLevelComponentType>;
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof ComponentInFolderType>
type Props = ComponentProps<typeof ComponentInFolderType>;
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
return (
Expand Down Expand Up @@ -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<typeof ComponentInSubFolderType>
type Props = ComponentProps<typeof ComponentInSubFolderType>;
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
return (
Expand Down Expand Up @@ -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<typeof SiblingType>
type Props = ComponentProps<typeof SiblingType>;
export default function SiblingWrapper(props: Props): JSX.Element {
return (
Expand Down Expand Up @@ -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<typeof FirstLevelComponentType>
type Props = ComponentProps<typeof FirstLevelComponentType>;
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus/src/commands/swizzle/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,7 +122,7 @@ export async function wrap({
import type ${componentName}Type from '@theme/${themeComponentName}';
import ${componentName} from '@theme-${importType}/${themeComponentName}';
type Props = ComponentProps<typeof ${componentName}Type>
type Props = ComponentProps<typeof ${componentName}Type>;
export default function ${wrapperComponentName}(props: Props): JSX.Element {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus/src/commands/swizzle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
`;
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/configValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 938cf8c

Please sign in to comment.