chore: tighten ESLint config (#6931)

* chore: tighten ESLint config

* more refactor

* refactor push

* fix
This commit is contained in:
Joshua Chen 2022-03-17 17:59:41 +08:00 committed by GitHub
parent f70ddf7e69
commit cc0bceab9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 177 additions and 193 deletions

View file

@ -5,26 +5,25 @@
* LICENSE file in the root directory of this source tree.
*/
export {useThemeConfig} from './utils/useThemeConfig';
export {
useThemeConfig,
type ThemeConfig,
type UserThemeConfig,
type Navbar,
type NavbarItem,
type NavbarLogo,
type MultiColumnFooter,
type SimpleFooter,
type Footer,
type FooterLogo,
type FooterLinkItem,
type ColorModeConfig,
} from './utils/useThemeConfig';
export {
DocSidebarItemsExpandedStateProvider,
useDocSidebarItemsExpandedState,
} from './utils/docSidebarItemsExpandedState';
export type {
ThemeConfig,
UserThemeConfig,
Navbar,
NavbarItem,
NavbarLogo,
MultiColumnFooter,
SimpleFooter,
Footer,
FooterLogo,
FooterLinkItem,
ColorModeConfig,
} from './utils/useThemeConfig';
export {createStorageSlot, listStorageKeys} from './utils/storageUtils';
export {useAlternatePageUtils} from './utils/useAlternatePageUtils';
@ -63,14 +62,14 @@ export {useLocationChange} from './utils/useLocationChange';
export {usePrevious} from './utils/usePrevious';
export {useCollapsible, Collapsible} from './components/Collapsible';
export type {
UseCollapsibleConfig,
UseCollapsibleReturns,
export {
useCollapsible,
Collapsible,
type UseCollapsibleConfig,
type UseCollapsibleReturns,
} from './components/Collapsible';
export {default as Details} from './components/Details';
export type {DetailsProps} from './components/Details';
export {default as Details, type DetailsProps} from './components/Details';
export {
MobileSecondaryMenuProvider,
@ -97,13 +96,19 @@ export {
export {useLocalPathname} from './utils/useLocalPathname';
export {translateTagsPageTitle, listTagsByLetters} from './utils/tagsUtils';
export type {TagLetterEntry} from './utils/tagsUtils';
export {
translateTagsPageTitle,
listTagsByLetters,
type TagLetterEntry,
type TagsListItem,
} from './utils/tagsUtils';
export {useHistoryPopHandler} from './utils/historyUtils';
export {default as useTOCHighlight} from './utils/useTOCHighlight';
export type {TOCHighlightConfig} from './utils/useTOCHighlight';
export {
default as useTOCHighlight,
type TOCHighlightConfig,
} from './utils/useTOCHighlight';
export {
useFilteredAndTreeifiedTOC,

View file

@ -199,14 +199,12 @@ function getBreadcrumbs({
function extract(items: PropSidebar) {
for (const item of items) {
if (
item.type === 'category' &&
(isSamePath(item.href, pathname) || extract(item.items))
(item.type === 'category' &&
(isSamePath(item.href, pathname) || extract(item.items))) ||
(item.type === 'link' && isSamePath(item.href, pathname))
) {
breadcrumbs.push(item);
return true;
} else if (item.type === 'link' && isSamePath(item.href, pathname)) {
breadcrumbs.push(item);
return true;
}
}

View file

@ -10,7 +10,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
export function useTitleFormatter(title?: string | undefined): string {
const {siteConfig} = useDocusaurusContext();
const {title: siteTitle, titleDelimiter} = siteConfig;
return title && title.trim().length
return title?.trim().length
? `${title.trim()} ${titleDelimiter} ${siteTitle}`
: siteTitle;
}

View file

@ -14,7 +14,11 @@ export const translateTagsPageTitle = (): string =>
description: 'The title of the tag list page',
});
type TagsListItem = Readonly<{name: string; permalink: string; count: number}>; // TODO remove duplicated type :s
export type TagsListItem = Readonly<{
name: string;
permalink: string;
count: number;
}>;
export type TagLetterEntry = Readonly<{letter: string; tags: TagsListItem[]}>;

View file

@ -8,10 +8,8 @@
import {useEffect, useRef} from 'react';
import {useThemeConfig} from './useThemeConfig';
/*
TODO make the hardcoded theme-classic classnames configurable
(or add them to ThemeClassNames?)
*/
// TODO make the hardcoded theme-classic classnames configurable (or add them
// to ThemeClassNames?)
// If the anchor has no height and is just a "marker" in the dom; we'll use the
// parent (normally the link text) rect boundaries instead