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
|
@ -29,7 +29,7 @@ export type DetailsProps = {
|
|||
summary?: ReactElement;
|
||||
} & ComponentProps<'details'>;
|
||||
|
||||
const Details = ({summary, children, ...props}: DetailsProps): JSX.Element => {
|
||||
function Details({summary, children, ...props}: DetailsProps): JSX.Element {
|
||||
const isBrowser = useIsBrowser();
|
||||
const detailsRef = useRef<HTMLDetailsElement>(null);
|
||||
|
||||
|
@ -89,6 +89,6 @@ const Details = ({summary, children, ...props}: DetailsProps): JSX.Element => {
|
|||
</Collapsible>
|
||||
</details>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default Details;
|
||||
|
|
|
@ -41,13 +41,13 @@ const useAnnouncementBarContextValue = (): AnnouncementBarAPI => {
|
|||
const {announcementBar} = useThemeConfig();
|
||||
const isBrowser = useIsBrowser();
|
||||
|
||||
const [isClosed, setClosed] = useState(() => {
|
||||
return isBrowser
|
||||
const [isClosed, setClosed] = useState(() =>
|
||||
isBrowser
|
||||
? // On client navigation: init with localstorage value
|
||||
isDismissedInStorage()
|
||||
: // On server/hydration: always visible to prevent layout shifts (will be hidden with css if needed)
|
||||
false;
|
||||
});
|
||||
false,
|
||||
);
|
||||
// Update state after hydration
|
||||
useEffect(() => {
|
||||
setClosed(isDismissedInStorage());
|
||||
|
@ -85,28 +85,29 @@ const useAnnouncementBarContextValue = (): AnnouncementBarAPI => {
|
|||
}
|
||||
}, [announcementBar]);
|
||||
|
||||
return useMemo(() => {
|
||||
return {
|
||||
return useMemo(
|
||||
() => ({
|
||||
isActive: !!announcementBar && !isClosed,
|
||||
close: handleClose,
|
||||
};
|
||||
}, [announcementBar, isClosed, handleClose]);
|
||||
}),
|
||||
[announcementBar, isClosed, handleClose],
|
||||
);
|
||||
};
|
||||
|
||||
const AnnouncementBarContext = createContext<AnnouncementBarAPI | null>(null);
|
||||
|
||||
export const AnnouncementBarProvider = ({
|
||||
export function AnnouncementBarProvider({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}): JSX.Element => {
|
||||
}): JSX.Element {
|
||||
const value = useAnnouncementBarContextValue();
|
||||
return (
|
||||
<AnnouncementBarContext.Provider value={value}>
|
||||
{children}
|
||||
</AnnouncementBarContext.Provider>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export const useAnnouncementBar = (): AnnouncementBarAPI => {
|
||||
const api = useContext(AnnouncementBarContext);
|
||||
|
|
|
@ -132,7 +132,7 @@ const Context = createContext<DocsPreferredVersionContextValue | null>(null);
|
|||
export function DocsPreferredVersionContextProvider({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
children: JSX.Element;
|
||||
}): JSX.Element {
|
||||
if (isDocsPluginEnabled) {
|
||||
return (
|
||||
|
@ -141,7 +141,7 @@ export function DocsPreferredVersionContextProvider({
|
|||
</DocsPreferredVersionContextProviderUnsafe>
|
||||
);
|
||||
} else {
|
||||
return <>{children}</>;
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,8 @@ const DocsPreferredVersionStorage = {
|
|||
read: (
|
||||
pluginId: string,
|
||||
persistence: DocsVersionPersistence,
|
||||
): string | null => {
|
||||
return createStorageSlot(storageKey(pluginId), {persistence}).get();
|
||||
},
|
||||
): string | null =>
|
||||
createStorageSlot(storageKey(pluginId), {persistence}).get(),
|
||||
|
||||
clear: (pluginId: string, persistence: DocsVersionPersistence): void => {
|
||||
createStorageSlot(storageKey(pluginId), {persistence}).del();
|
||||
|
|
|
@ -24,12 +24,12 @@ export function useHistoryActionHandler(handler: HistoryBlockHandler): void {
|
|||
lastHandlerRef.current = handler;
|
||||
}, [handler]);
|
||||
|
||||
useEffect(() => {
|
||||
// See https://github.com/remix-run/history/blob/main/docs/blocking-transitions.md
|
||||
return block((location, action) => {
|
||||
return lastHandlerRef.current(location, action);
|
||||
});
|
||||
}, [block, lastHandlerRef]);
|
||||
useEffect(
|
||||
() =>
|
||||
// See https://github.com/remix-run/history/blob/main/docs/blocking-transitions.md
|
||||
block((location, action) => lastHandlerRef.current(location, action)),
|
||||
[block, lastHandlerRef],
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -29,7 +29,7 @@ type ExtraProps = {
|
|||
toggleSidebar: () => void;
|
||||
};
|
||||
|
||||
export type MobileSecondaryMenuComponent<Props extends unknown> = ComponentType<
|
||||
export type MobileSecondaryMenuComponent<Props> = ComponentType<
|
||||
Props & ExtraProps
|
||||
>;
|
||||
|
||||
|
@ -108,9 +108,7 @@ export function MobileSecondaryMenuFiller<
|
|||
setState({component, props: memoizedProps});
|
||||
}, [setState, component, memoizedProps]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => setState(null);
|
||||
}, [setState]);
|
||||
useEffect(() => () => setState(null), [setState]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ export const isSamePath = (
|
|||
path1: string | undefined,
|
||||
path2: string | undefined,
|
||||
): boolean => {
|
||||
const normalize = (pathname: string | undefined) => {
|
||||
return !pathname || pathname?.endsWith('/') ? pathname : `${pathname}/`;
|
||||
};
|
||||
const normalize = (pathname: string | undefined) =>
|
||||
!pathname || pathname?.endsWith('/') ? pathname : `${pathname}/`;
|
||||
return normalize(path1) === normalize(path2);
|
||||
};
|
||||
|
|
|
@ -83,14 +83,13 @@ export function useScrollController(): ScrollController {
|
|||
return context;
|
||||
}
|
||||
|
||||
const getScrollPosition = (): ScrollPosition | null => {
|
||||
return ExecutionEnvironment.canUseDOM
|
||||
const getScrollPosition = (): ScrollPosition | null =>
|
||||
ExecutionEnvironment.canUseDOM
|
||||
? {
|
||||
scrollX: window.pageXOffset,
|
||||
scrollY: window.pageYOffset,
|
||||
}
|
||||
: null;
|
||||
};
|
||||
|
||||
type ScrollPosition = {scrollX: number; scrollY: number};
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ export function useTOCFilter({
|
|||
minHeadingLevel,
|
||||
maxHeadingLevel,
|
||||
}: FilterTOCParam): readonly TOCItem[] {
|
||||
return useMemo(() => {
|
||||
return filterTOC({toc, minHeadingLevel, maxHeadingLevel});
|
||||
}, [toc, minHeadingLevel, maxHeadingLevel]);
|
||||
return useMemo(
|
||||
() => filterTOC({toc, minHeadingLevel, maxHeadingLevel}),
|
||||
[toc, minHeadingLevel, maxHeadingLevel],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -112,8 +112,7 @@ export function usePluralForm(): {
|
|||
} {
|
||||
const localePluralForm = useLocalePluralForms();
|
||||
return {
|
||||
selectMessage: (count: number, pluralMessages: string): string => {
|
||||
return selectPluralMessage(pluralMessages, count, localePluralForm);
|
||||
},
|
||||
selectMessage: (count: number, pluralMessages: string): string =>
|
||||
selectPluralMessage(pluralMessages, count, localePluralForm),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue