Skip to content

Commit 3f1f825

Browse files
authored
chore: upgrade Prettier + regenerate lock file (facebook#5611)
* Bump deps * Run prettier * Format docs * Minor refactor * Collapse objects * Fix type * Update lock file
1 parent 4dbc458 commit 3f1f825

File tree

70 files changed

+1534
-1517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1534
-1517
lines changed

Diff for: .prettierignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ coverage
77
packages/docusaurus/lib/
88
packages/docusaurus-*/lib/*
99
packages/docusaurus-*/lib-next/
10+
packages/docusaurus-init/templates/*/docusaurus.config.js
1011
__fixtures__
1112

1213
website/i18n
1314
website/versions.json
15+
website/docusaurus.config.js
1416

15-
examples/**/package.json
16-
examples/**/sandbox.config.json
17+
examples/

Diff for: .prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"arrowParens": "always",
33
"bracketSpacing": false,
4-
"jsxBracketSameLine": true,
4+
"bracketSameLine": true,
55
"printWidth": 80,
66
"proseWrap": "never",
77
"singleQuote": true,

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"netlify-cli": "^2.58.0",
109109
"nodemon": "^2.0.13",
110110
"npm-run-all": "^4.1.5",
111-
"prettier": "^2.2.1",
111+
"prettier": "^2.4.1",
112112
"react": "^17.0.1",
113113
"react-dom": "^17.0.1",
114114
"rimraf": "^3.0.2",

Diff for: packages/docusaurus-init/bin/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/usr/bin/env node
2-
3-
// TODO remove when fixed: https://github.com/Stuk/eslint-plugin-header/issues/39
4-
/* eslint-disable header/header */
52
/**
63
* Copyright (c) Facebook, Inc. and its affiliates.
74
*

Diff for: packages/docusaurus-mdx-loader/src/remark/transformImage/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ interface PluginOptions {
3030

3131
const createJSX = (node: Image, pathUrl: string) => {
3232
const jsxNode = node;
33-
((jsxNode as unknown) as Literal).type = 'jsx';
34-
((jsxNode as unknown) as Literal).value = `<img ${
33+
(jsxNode as unknown as Literal).type = 'jsx';
34+
(jsxNode as unknown as Literal).value = `<img ${
3535
node.alt ? `alt={"${escapeHtml(node.alt)}"} ` : ''
3636
}${
3737
node.url

Diff for: packages/docusaurus-mdx-loader/src/remark/transformLinks/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ function toAssetRequireNode({
6868
const children = stringifyContent(node);
6969
const title = node.title ? `title="${escapeHtml(node.title)}"` : '';
7070

71-
((node as unknown) as Literal).type = 'jsx';
72-
((node as unknown) as Literal).value = `<a target="_blank" href={${href}}${title}>${children}</a>`;
71+
(node as unknown as Literal).type = 'jsx';
72+
(
73+
node as unknown as Literal
74+
).value = `<a target="_blank" href={${href}}${title}>${children}</a>`;
7375
}
7476

7577
// If the link looks like an asset link, we'll link to the asset,

Diff for: packages/docusaurus-migrate/bin/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/usr/bin/env node
2-
3-
// TODO remove when fixed: https://github.com/Stuk/eslint-plugin-header/issues/39
4-
/* eslint-disable header/header */
52
/**
63
* Copyright (c) Facebook, Inc. and its affiliates.
74
*

Diff for: packages/docusaurus-migrate/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,9 @@ function migrateVersionedSidebar(
592592
acc: {[key: string]: Array<Record<string, unknown> | string>},
593593
val,
594594
) => {
595-
acc[
596-
val[0].replace(versionRegex, '')
597-
] = (val[1] as Array<SidebarEntry>).map((item) => {
595+
acc[val[0].replace(versionRegex, '')] = (
596+
val[1] as Array<SidebarEntry>
597+
).map((item) => {
598598
if (typeof item === 'string') {
599599
return item.replace(versionRegex, '');
600600
}

Diff for: packages/docusaurus-module-type-aliases/src/index.d.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,21 @@ declare module '@docusaurus/Head' {
8686
}
8787

8888
declare module '@docusaurus/Link' {
89+
import type {CSSProperties, ComponentProps} from 'react';
90+
8991
type NavLinkProps = Partial<import('react-router-dom').NavLinkProps>;
90-
export type LinkProps = NavLinkProps & {
91-
readonly isNavLink?: boolean;
92-
readonly to?: string;
93-
readonly href?: string;
94-
readonly autoAddBaseUrl?: boolean;
95-
96-
// escape hatch in case broken links check is annoying for a specific link
97-
readonly 'data-noBrokenLinkCheck'?: boolean;
98-
};
92+
export type LinkProps = NavLinkProps &
93+
ComponentProps<'a'> & {
94+
readonly className?: string;
95+
readonly style?: CSSProperties;
96+
readonly isNavLink?: boolean;
97+
readonly to?: string;
98+
readonly href?: string;
99+
readonly autoAddBaseUrl?: boolean;
100+
101+
// escape hatch in case broken links check is annoying for a specific link
102+
readonly 'data-noBrokenLinkCheck'?: boolean;
103+
};
99104
const Link: (props: LinkProps) => JSX.Element;
100105
export default Link;
101106
}
@@ -110,7 +115,7 @@ declare module '@docusaurus/Interpolate' {
110115

111116
export type InterpolateValues<
112117
Str extends string,
113-
Value extends ReactNode
118+
Value extends ReactNode,
114119
> = Record<ExtractInterpolatePlaceholders<Str>, Value>;
115120

116121
// TS function overload: if all the values are plain strings, then interpolate returns a simple string

Diff for: packages/docusaurus-plugin-client-redirects/src/__tests__/collectRedirects.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ describe('collectRedirects', () => {
291291
{
292292
createRedirects: (routePath) => {
293293
if (routePath === '/') {
294-
return ([[`/fromPath`]] as unknown) as string;
294+
return [[`/fromPath`]] as unknown as string;
295295
}
296296
return undefined;
297297
},

Diff for: packages/docusaurus-plugin-client-redirects/src/__tests__/normalizePluginOptions.test.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,23 @@ describe('normalizePluginOptions', () => {
5050
test('should reject bad fromExtensions user inputs', () => {
5151
expect(() =>
5252
normalizePluginOptions({
53-
fromExtensions: ([null, undefined, 123, true] as unknown) as string[],
53+
fromExtensions: [null, undefined, 123, true] as unknown as string[],
5454
}),
5555
).toThrowErrorMatchingSnapshot();
5656
});
5757

5858
test('should reject bad toExtensions user inputs', () => {
5959
expect(() =>
6060
normalizePluginOptions({
61-
toExtensions: ([null, undefined, 123, true] as unknown) as string[],
61+
toExtensions: [null, undefined, 123, true] as unknown as string[],
6262
}),
6363
).toThrowErrorMatchingSnapshot();
6464
});
6565

6666
test('should reject bad createRedirects user inputs', () => {
6767
expect(() =>
6868
normalizePluginOptions({
69-
createRedirects: ([
70-
'bad',
71-
'value',
72-
] as unknown) as CreateRedirectsFnOption,
69+
createRedirects: ['bad', 'value'] as unknown as CreateRedirectsFnOption,
7370
}),
7471
).toThrowErrorMatchingSnapshot();
7572
});

Diff for: packages/docusaurus-plugin-client-redirects/src/__tests__/redirectValidation.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ describe('validateRedirect', () => {
5151

5252
expect(() =>
5353
validateRedirect({
54-
from: (null as unknown) as string,
54+
from: null as unknown as string,
5555
to: '/toSomePath?queryString=xyz',
5656
}),
5757
).toThrowErrorMatchingSnapshot();
5858

5959
expect(() =>
6060
validateRedirect({
61-
from: (['heyho'] as unknown) as string,
61+
from: ['heyho'] as unknown as string,
6262
to: '/toSomePath?queryString=xyz',
6363
}),
6464
).toThrowErrorMatchingSnapshot();

Diff for: packages/docusaurus-plugin-content-blog/src/blogUtils.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export function getBlogTags(blogPosts: BlogPost[]): BlogTags {
6262
});
6363
}
6464

65-
const DATE_FILENAME_REGEX = /^(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(\/index)?.mdx?$/;
65+
const DATE_FILENAME_REGEX =
66+
/^(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(\/index)?.mdx?$/;
6667

6768
type ParsedBlogFileName = {
6869
date: Date | undefined;
@@ -199,12 +200,8 @@ async function processBlogSourceFile(
199200

200201
const blogSourceAbsolute = path.join(blogDirPath, blogSourceRelative);
201202

202-
const {
203-
frontMatter,
204-
content,
205-
contentTitle,
206-
excerpt,
207-
} = await parseBlogPostMarkdownFile(blogSourceAbsolute);
203+
const {frontMatter, content, contentTitle, excerpt} =
204+
await parseBlogPostMarkdownFile(blogSourceAbsolute);
208205

209206
const aliasedSource = aliasedSitePath(blogSourceAbsolute, siteDir);
210207

Diff for: packages/docusaurus-plugin-content-docs/src/__tests__/docs.test.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,8 @@ describe('versioned site', () => {
563563
options,
564564
});
565565
expect(versionsMetadata.length).toEqual(4);
566-
const [
567-
currentVersion,
568-
version101,
569-
version100,
570-
versionWithSlugs,
571-
] = versionsMetadata;
566+
const [currentVersion, version101, version100, versionWithSlugs] =
567+
versionsMetadata;
572568

573569
const currentVersionTestUtils = createTestUtils({
574570
siteDir,

Diff for: packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts

+6-16
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,8 @@ describe('versioned website', () => {
575575
const {siteDir, plugin, pluginContentDir} = await loadSite();
576576
const content = await plugin.loadContent!();
577577
expect(content.loadedVersions.length).toEqual(4);
578-
const [
579-
currentVersion,
580-
version101,
581-
version100,
582-
versionWithSlugs,
583-
] = content.loadedVersions;
578+
const [currentVersion, version101, version100, versionWithSlugs] =
579+
content.loadedVersions;
584580

585581
// foo/baz.md only exists in version -1.0.0
586582
expect(findDocById(currentVersion, 'foo/baz')).toBeUndefined();
@@ -751,13 +747,8 @@ describe('versioned website (community)', () => {
751747
}
752748

753749
test('extendCli - docsVersion', async () => {
754-
const {
755-
siteDir,
756-
routeBasePath,
757-
sidebarPath,
758-
pluginId,
759-
plugin,
760-
} = await loadSite();
750+
const {siteDir, routeBasePath, sidebarPath, pluginId, plugin} =
751+
await loadSite();
761752
const mock = jest
762753
.spyOn(cliDocs, 'cliDocsVersionCommand')
763754
.mockImplementation();
@@ -1784,12 +1775,11 @@ describe('site with custom sidebar items generator', () => {
17841775
});
17851776

17861777
test('sidebar is autogenerated according to a custom sidebarItemsGenerator', async () => {
1787-
const customSidebarItemsGenerator: SidebarItemsGeneratorOption = async () => {
1788-
return [
1778+
const customSidebarItemsGenerator: SidebarItemsGeneratorOption =
1779+
async () => [
17891780
{type: 'doc', id: 'API/api-overview'},
17901781
{type: 'doc', id: 'API/api-end'},
17911782
];
1792-
};
17931783

17941784
const {content} = await loadSite(customSidebarItemsGenerator);
17951785
const version = content.loadedVersions[0];

Diff for: packages/docusaurus-plugin-content-docs/src/__tests__/sidebars.test.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,8 @@ describe('createSidebarsUtils', () => {
646646

647647
const sidebars: Sidebars = {sidebar1, sidebar2};
648648

649-
const {
650-
getFirstDocIdOfFirstSidebar,
651-
getSidebarNameByDocId,
652-
getDocNavigation,
653-
} = createSidebarsUtils(sidebars);
649+
const {getFirstDocIdOfFirstSidebar, getSidebarNameByDocId, getDocNavigation} =
650+
createSidebarsUtils(sidebars);
654651

655652
test('getSidebarNameByDocId', async () => {
656653
expect(getFirstDocIdOfFirstSidebar()).toEqual('doc1');

Diff for: packages/docusaurus-plugin-content-docs/src/__tests__/versions.test.ts

+10-39
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,8 @@ describe('versioned site, pluginId=default', () => {
324324
}
325325

326326
test('readVersionsMetadata versioned site', async () => {
327-
const {
328-
defaultOptions,
329-
defaultContext,
330-
vCurrent,
331-
v101,
332-
v100,
333-
vwithSlugs,
334-
} = await loadSite();
327+
const {defaultOptions, defaultContext, vCurrent, v101, v100, vwithSlugs} =
328+
await loadSite();
335329

336330
const versionsMetadata = readVersionsMetadata({
337331
options: defaultOptions,
@@ -342,13 +336,8 @@ describe('versioned site, pluginId=default', () => {
342336
});
343337

344338
test('readVersionsMetadata versioned site with includeCurrentVersion=false', async () => {
345-
const {
346-
defaultOptions,
347-
defaultContext,
348-
v101,
349-
v100,
350-
vwithSlugs,
351-
} = await loadSite();
339+
const {defaultOptions, defaultContext, v101, v100, vwithSlugs} =
340+
await loadSite();
352341

353342
const versionsMetadata = readVersionsMetadata({
354343
options: {...defaultOptions, includeCurrentVersion: false},
@@ -364,14 +353,8 @@ describe('versioned site, pluginId=default', () => {
364353
});
365354

366355
test('readVersionsMetadata versioned site with version options', async () => {
367-
const {
368-
defaultOptions,
369-
defaultContext,
370-
vCurrent,
371-
v101,
372-
v100,
373-
vwithSlugs,
374-
} = await loadSite();
356+
const {defaultOptions, defaultContext, vCurrent, v101, v100, vwithSlugs} =
357+
await loadSite();
375358

376359
const versionsMetadata = readVersionsMetadata({
377360
options: {
@@ -424,14 +407,8 @@ describe('versioned site, pluginId=default', () => {
424407
});
425408

426409
test('readVersionsMetadata versioned site with editUrl', async () => {
427-
const {
428-
defaultOptions,
429-
defaultContext,
430-
vCurrent,
431-
v101,
432-
v100,
433-
vwithSlugs,
434-
} = await loadSite();
410+
const {defaultOptions, defaultContext, vCurrent, v101, v100, vwithSlugs} =
411+
await loadSite();
435412

436413
const versionsMetadata = readVersionsMetadata({
437414
options: {
@@ -474,14 +451,8 @@ describe('versioned site, pluginId=default', () => {
474451
});
475452

476453
test('readVersionsMetadata versioned site with editUrl and editCurrentVersion=true', async () => {
477-
const {
478-
defaultOptions,
479-
defaultContext,
480-
vCurrent,
481-
v101,
482-
v100,
483-
vwithSlugs,
484-
} = await loadSite();
454+
const {defaultOptions, defaultContext, vCurrent, v101, v100, vwithSlugs} =
455+
await loadSite();
485456

486457
const versionsMetadata = readVersionsMetadata({
487458
options: {

Diff for: packages/docusaurus-plugin-content-docs/src/index.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,8 @@ export default function pluginContentDocs(
201201

202202
// Add sidebar/next/previous to the docs
203203
function addNavData(doc: DocMetadataBase): DocMetadata {
204-
const {
205-
sidebarName,
206-
previousId,
207-
nextId,
208-
} = sidebarsUtils.getDocNavigation(doc.id);
204+
const {sidebarName, previousId, nextId} =
205+
sidebarsUtils.getDocNavigation(doc.id);
209206
const toDocNavLink = (navDocId: string): DocNavLink => {
210207
const {title, permalink, frontMatter} = docsBaseById[navDocId];
211208
return {
@@ -239,7 +236,8 @@ export default function pluginContentDocs(
239236
(doc) =>
240237
doc.unversionedId === options.homePageId || doc.slug === '/',
241238
);
242-
const firstDocIdOfFirstSidebar = sidebarsUtils.getFirstDocIdOfFirstSidebar();
239+
const firstDocIdOfFirstSidebar =
240+
sidebarsUtils.getFirstDocIdOfFirstSidebar();
243241
if (versionHomeDoc) {
244242
return versionHomeDoc;
245243
} else if (firstDocIdOfFirstSidebar) {

0 commit comments

Comments
 (0)