chore: upgrade Prettier + regenerate lock file (#5611)

* Bump deps

* Run prettier

* Format docs

* Minor refactor

* Collapse objects

* Fix type

* Update lock file
This commit is contained in:
Joshua Chen 2021-09-30 18:54:17 +08:00 committed by GitHub
parent 4dbc458a22
commit 3f1f8255a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 1534 additions and 1517 deletions

View file

@ -1,7 +1,4 @@
#!/usr/bin/env node
// TODO remove when fixed: https://github.com/Stuk/eslint-plugin-header/issues/39
/* eslint-disable header/header */
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import React, {useEffect, useRef} from 'react';
import React, {useEffect, useRef, ComponentType} from 'react';
import {NavLink, Link as RRLink} from 'react-router-dom';
import useDocusaurusContext from './useDocusaurusContext';
@ -84,7 +84,9 @@ function Link({
}
const preloaded = useRef(false);
const LinkComponent = isNavLink ? NavLink : RRLink;
const LinkComponent = (
isNavLink ? NavLink : RRLink
) as ComponentType<LinkProps>;
const IOSupported = ExecutionEnvironment.canUseIntersectionObserver;

View file

@ -42,9 +42,8 @@ function addBaseUrl(
}
export function useBaseUrlUtils(): BaseUrlUtils {
const {
siteConfig: {baseUrl = '/', url: siteUrl} = {},
} = useDocusaurusContext();
const {siteConfig: {baseUrl = '/', url: siteUrl} = {}} =
useDocusaurusContext();
return {
withBaseUrl: (url, options) => {
return addBaseUrl(siteUrl, baseUrl, url, options);

View file

@ -49,7 +49,8 @@ export default async function render(locals) {
),
);
const isNotDefinedErrorRegex = /(window|document|localStorage|navigator|alert|location|buffer|self) is not defined/i;
const isNotDefinedErrorRegex =
/(window|document|localStorage|navigator|alert|location|buffer|self) is not defined/i;
if (isNotDefinedErrorRegex.test(e.message)) {
console.error(

View file

@ -190,13 +190,13 @@ describe('normalizeConfig', () => {
test('should throw error for required fields', () => {
expect(
() =>
validateConfig(({
validateConfig({
invalidField: true,
presets: {},
stylesheets: {},
themes: {},
scripts: {},
} as unknown) as DocusaurusConfig), // to fields not in the type
} as unknown as DocusaurusConfig), // to fields not in the type
).toThrowErrorMatchingSnapshot();
});
});

View file

@ -14,8 +14,7 @@ describe('htmlTagObjectToString', () => {
tagName: 'script',
attributes: {
type: 'text/javascript',
src:
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
src: 'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
async: true,
'data-options': '{"prop":true}',
},

View file

@ -256,15 +256,8 @@ export async function load(
} = context;
// Plugins.
const pluginConfigs: PluginConfig[] = loadPluginConfigs(context);
const {
plugins,
pluginsRouteConfigs,
globalData,
themeConfigTranslated,
} = await loadPlugins({
pluginConfigs,
context,
});
const {plugins, pluginsRouteConfigs, globalData, themeConfigTranslated} =
await loadPlugins({pluginConfigs, context});
// Side-effect to replace the untranslated themeConfig by the translated one
context.siteConfig.themeConfig = themeConfigTranslated;
@ -299,12 +292,8 @@ export async function load(
const {headTags, preBodyTags, postBodyTags} = loadHtmlTags(plugins);
// Routing.
const {
registry,
routesChunkNames,
routesConfig,
routesPaths,
} = await loadRoutes(pluginsRouteConfigs, baseUrl);
const {registry, routesChunkNames, routesConfig, routesPaths} =
await loadRoutes(pluginsRouteConfigs, baseUrl);
const genRegistry = generate(
generatedFilesDir,

View file

@ -87,28 +87,29 @@ export async function loadPlugins({
type ContentLoadedTranslatedPlugin = LoadedPlugin & {
translationFiles: TranslationFiles;
};
const contentLoadedTranslatedPlugins: ContentLoadedTranslatedPlugin[] = await Promise.all(
loadedPlugins.map(async (contentLoadedPlugin) => {
const translationFiles =
(await contentLoadedPlugin?.getTranslationFiles?.({
content: contentLoadedPlugin.content,
})) ?? [];
const localizedTranslationFiles = await Promise.all(
translationFiles.map((translationFile) =>
localizePluginTranslationFile({
locale: context.i18n.currentLocale,
siteDir: context.siteDir,
translationFile,
plugin: contentLoadedPlugin,
}),
),
);
return {
...contentLoadedPlugin,
translationFiles: localizedTranslationFiles,
};
}),
);
const contentLoadedTranslatedPlugins: ContentLoadedTranslatedPlugin[] =
await Promise.all(
loadedPlugins.map(async (contentLoadedPlugin) => {
const translationFiles =
(await contentLoadedPlugin?.getTranslationFiles?.({
content: contentLoadedPlugin.content,
})) ?? [];
const localizedTranslationFiles = await Promise.all(
translationFiles.map((translationFile) =>
localizePluginTranslationFile({
locale: context.i18n.currentLocale,
siteDir: context.siteDir,
translationFile,
plugin: contentLoadedPlugin,
}),
),
);
return {
...contentLoadedPlugin,
translationFiles: localizedTranslationFiles,
};
}),
);
const allContent: AllContent = chain(loadedPlugins)
.groupBy((item) => item.name)

View file

@ -193,9 +193,8 @@ export default function initPlugins({
pluginConfig,
pluginRequire,
);
const pluginVersion: DocusaurusPluginVersionInformation = doGetPluginVersion(
normalizedPluginConfig,
);
const pluginVersion: DocusaurusPluginVersionInformation =
doGetPluginVersion(normalizedPluginConfig);
const pluginOptions = doValidatePluginOptions(normalizedPluginConfig);
// Side-effect: merge the normalized theme config in the original one

View file

@ -14,9 +14,7 @@ import {
PresetConfig,
} from '@docusaurus/types';
export default function loadPresets(
context: LoadContext,
): {
export default function loadPresets(context: LoadContext): {
plugins: PluginConfig[];
themes: PluginConfig[];
} {

View file

@ -98,10 +98,11 @@ export async function extractSiteSourceCodeTranslations(
...extraSourceCodeFilePaths,
];
const sourceCodeFilesTranslations = await extractAllSourceCodeFileTranslations(
allSourceCodeFilePaths,
babelOptions,
);
const sourceCodeFilesTranslations =
await extractAllSourceCodeFileTranslations(
allSourceCodeFilePaths,
babelOptions,
);
logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations);
@ -215,9 +216,10 @@ function extractSourceCodeAstTranslations(
if (attributePath) {
const attributeValue = attributePath.get('value') as NodePath;
const attributeValueEvaluated = attributeValue.isJSXExpressionContainer()
? (attributeValue.get('expression') as NodePath).evaluate()
: attributeValue.evaluate();
const attributeValueEvaluated =
attributeValue.isJSXExpressionContainer()
? (attributeValue.get('expression') as NodePath).evaluate()
: attributeValue.evaluate();
if (
attributeValueEvaluated.confident &&
@ -265,9 +267,9 @@ function extractSourceCodeAstTranslations(
singleChildren.isJSXExpressionContainer() &&
(singleChildren.get('expression') as NodePath).evaluate().confident
) {
const message = (singleChildren.get(
'expression',
) as NodePath).evaluate().value;
const message = (
singleChildren.get('expression') as NodePath
).evaluate().value;
const id = evaluateJSXProp('id');
const description = evaluateJSXProp('description');

View file

@ -236,9 +236,10 @@ class CleanWebpackPlugin {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
const needsForce = /Cannot delete files\/folders outside the current working directory\./.test(
error.message,
);
const needsForce =
/Cannot delete files\/folders outside the current working directory\./.test(
error.message,
);
if (needsForce) {
const message =

View file

@ -151,18 +151,18 @@ function getDefaultBabelLoader({
};
}
export const getCustomizableJSLoader = (
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) = 'babel',
) => ({
isServer,
babelOptions,
}: {
isServer: boolean;
babelOptions?: TransformOptions | string;
}): RuleSetRule =>
jsLoader === 'babel'
? getDefaultBabelLoader({isServer, babelOptions})
: jsLoader(isServer);
export const getCustomizableJSLoader =
(jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) = 'babel') =>
({
isServer,
babelOptions,
}: {
isServer: boolean;
babelOptions?: TransformOptions | string;
}): RuleSetRule =>
jsLoader === 'babel'
? getDefaultBabelLoader({isServer, babelOptions})
: jsLoader(isServer);
// TODO remove this before end of 2021?
const warnBabelLoaderOnce = memoize(function () {