mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 08:19:07 +02:00
chore: upgrade TypeScript & other ESLint related deps (#5963)
* chore: upgrade ESLint related deps * Upgrade TS * Fix lock * Bump Babel * Update config
This commit is contained in:
parent
2f7d6fea1e
commit
0374426ce3
104 changed files with 2662 additions and 2487 deletions
|
@ -14,9 +14,9 @@ import {memoize} from 'lodash';
|
|||
|
||||
import type {DocusaurusContext, Plugin} from '@docusaurus/types';
|
||||
|
||||
const getCompiledOpenSearchTemplate = memoize(() => {
|
||||
return compile(openSearchTemplate.trim());
|
||||
});
|
||||
const getCompiledOpenSearchTemplate = memoize(() =>
|
||||
compile(openSearchTemplate.trim()),
|
||||
);
|
||||
|
||||
function renderOpenSearchTemplate(data: {
|
||||
title: string;
|
||||
|
|
|
@ -152,8 +152,8 @@ function DocSearch({
|
|||
}).current;
|
||||
|
||||
const transformItems = useRef<DocSearchModalProps['transformItems']>(
|
||||
(items) => {
|
||||
return items.map((item) => {
|
||||
(items) =>
|
||||
items.map((item) => {
|
||||
// If Algolia contains a external domain, we should navigate without relative URL
|
||||
if (isRegexpStringMatch(externalUrlRegex, item.url)) {
|
||||
return item;
|
||||
|
@ -165,11 +165,11 @@ function DocSearch({
|
|||
...item,
|
||||
url: withBaseUrl(`${url.pathname}${url.hash}`),
|
||||
};
|
||||
});
|
||||
},
|
||||
}),
|
||||
).current;
|
||||
|
||||
const resultsFooterComponent = useMemo(
|
||||
// eslint-disable-next-line react/no-unstable-nested-components
|
||||
() => (footerProps: ResultsFooterProps) =>
|
||||
<ResultsFooter {...footerProps} onClose={onClose} />,
|
||||
[onClose],
|
||||
|
@ -250,7 +250,7 @@ function DocSearch({
|
|||
);
|
||||
}
|
||||
|
||||
function SearchBar() {
|
||||
function SearchBar(): JSX.Element {
|
||||
const {siteConfig} = useDocusaurusContext();
|
||||
// @ts-ignore
|
||||
return <DocSearch {...siteConfig.themeConfig.algolia} />;
|
||||
|
|
|
@ -54,14 +54,14 @@ function useDocsSearchVersionsHelpers() {
|
|||
// State of the version select menus / algolia facet filters
|
||||
// docsPluginId -> versionName map
|
||||
const [searchVersions, setSearchVersions] = useState<Record<string, string>>(
|
||||
() => {
|
||||
return Object.entries(allDocsData).reduce(
|
||||
(acc, [pluginId, pluginData]) => {
|
||||
return {...acc, [pluginId]: pluginData.versions[0].name};
|
||||
},
|
||||
() =>
|
||||
Object.entries(allDocsData).reduce(
|
||||
(acc, [pluginId, pluginData]) => ({
|
||||
...acc,
|
||||
[pluginId]: pluginData.versions[0].name,
|
||||
}),
|
||||
{},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Set the value of a single select menu
|
||||
|
@ -81,11 +81,11 @@ function useDocsSearchVersionsHelpers() {
|
|||
}
|
||||
|
||||
// We want to display one select per versioned docs plugin instance
|
||||
const SearchVersionSelectList = ({
|
||||
function SearchVersionSelectList({
|
||||
docsSearchVersionsHelpers,
|
||||
}: {
|
||||
docsSearchVersionsHelpers: ReturnType<typeof useDocsSearchVersionsHelpers>;
|
||||
}) => {
|
||||
}) {
|
||||
const versionedPluginEntries = Object.entries(
|
||||
docsSearchVersionsHelpers.allDocsData,
|
||||
)
|
||||
|
@ -126,7 +126,7 @@ const SearchVersionSelectList = ({
|
|||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
type ResultDispatcherState = {
|
||||
items: {
|
||||
|
@ -225,12 +225,11 @@ function SearchPage(): JSX.Element {
|
|||
return;
|
||||
}
|
||||
|
||||
const sanitizeValue = (value: string) => {
|
||||
return value.replace(
|
||||
const sanitizeValue = (value: string) =>
|
||||
value.replace(
|
||||
/algolia-docsearch-suggestion--highlight/g,
|
||||
'search-result-match',
|
||||
);
|
||||
};
|
||||
|
||||
const items = hits.map(
|
||||
({
|
||||
|
@ -239,9 +238,9 @@ function SearchPage(): JSX.Element {
|
|||
_snippetResult: snippet = {},
|
||||
}) => {
|
||||
const parsedURL = new URL(url);
|
||||
const titles = Object.keys(hierarchy).map((key) => {
|
||||
return sanitizeValue(hierarchy[key].value);
|
||||
});
|
||||
const titles = Object.keys(hierarchy).map((key) =>
|
||||
sanitizeValue(hierarchy[key].value),
|
||||
);
|
||||
|
||||
return {
|
||||
title: titles.pop()!,
|
||||
|
|
|
@ -47,10 +47,9 @@ function useSearchQuery(): SearchQuery {
|
|||
);
|
||||
|
||||
const generateSearchPageLink = useCallback(
|
||||
(targetSearchQuery: string) => {
|
||||
(targetSearchQuery: string) =>
|
||||
// Refer to https://github.com/facebook/docusaurus/pull/2838
|
||||
return `${baseUrl}search?q=${encodeURIComponent(targetSearchQuery)}`;
|
||||
},
|
||||
`${baseUrl}search?q=${encodeURIComponent(targetSearchQuery)}`,
|
||||
[baseUrl],
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue