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:
Joshua Chen 2021-11-18 21:15:37 +08:00 committed by GitHub
parent 2f7d6fea1e
commit 0374426ce3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
104 changed files with 2662 additions and 2487 deletions

View file

@ -600,11 +600,9 @@ describe('versioned site, pluginId=default', () => {
test('readVersionsMetadata versioned site with invalid versions.json file', async () => {
const {defaultOptions, defaultContext} = await loadSite();
const mock = jest.spyOn(JSON, 'parse').mockImplementationOnce(() => {
return {
invalid: 'json',
};
});
const mock = jest.spyOn(JSON, 'parse').mockImplementationOnce(() => ({
invalid: 'json',
}));
expect(() => {
readVersionsMetadata({

View file

@ -31,13 +31,12 @@ export function getActivePlugin(
options: GetActivePluginOptions = {},
): ActivePlugin | undefined {
const activeEntry = Object.entries(allPluginDatas).find(
([_id, pluginData]) => {
return !!matchPath(pathname, {
([_id, pluginData]) =>
!!matchPath(pathname, {
path: pluginData.path,
exact: false,
strict: false,
});
},
}),
);
const activePlugin: ActivePlugin | undefined = activeEntry
@ -63,9 +62,8 @@ export type ActiveDocContext = {
alternateDocVersions: Record<string, Doc>;
};
export const getLatestVersion = (data: GlobalPluginData): Version => {
return data.versions.find((version) => version.isLast)!;
};
export const getLatestVersion = (data: GlobalPluginData): Version =>
data.versions.find((version) => version.isLast)!;
// Note: return undefined on doc-unrelated pages,
// because there's no version currently considered as active
@ -80,13 +78,14 @@ export const getActiveVersion = (
...data.versions.filter((version) => version !== lastVersion),
lastVersion,
];
return orderedVersionsMetadata.find((version) => {
return !!matchPath(pathname, {
path: version.path,
exact: false,
strict: false,
});
});
return orderedVersionsMetadata.find(
(version) =>
!!matchPath(pathname, {
path: version.path,
exact: false,
strict: false,
}),
);
};
export const getActiveDocContext = (

View file

@ -70,12 +70,10 @@ declare module '@theme/DocItem' {
readonly title: string;
readonly image?: string;
readonly keywords?: readonly string[];
/* eslint-disable camelcase */
readonly hide_title?: boolean;
readonly hide_table_of_contents?: boolean;
readonly toc_min_heading_level?: number;
readonly toc_max_heading_level?: number;
/* eslint-enable camelcase */
};
export type Metadata = {

View file

@ -36,14 +36,16 @@ describe('DefaultSidebarItemsGenerator', () => {
function mockCategoryMetadataFiles(
categoryMetadataFiles: Record<string, Partial<CategoryMetadataFile>>,
) {
jest.spyOn(fs, 'pathExists').mockImplementation((metadataFilePath) => {
return typeof categoryMetadataFiles[metadataFilePath] !== 'undefined';
});
jest
.spyOn(fs, 'pathExists')
.mockImplementation(
(metadataFilePath) =>
typeof categoryMetadataFiles[metadataFilePath] !== 'undefined',
);
jest.spyOn(fs, 'readFile').mockImplementation(
// @ts-expect-error: annoying TS error due to overrides
async (metadataFilePath: string) => {
return JSON.stringify(categoryMetadataFiles[metadataFilePath]);
},
async (metadataFilePath: string) =>
JSON.stringify(categoryMetadataFiles[metadataFilePath]),
);
}

View file

@ -21,9 +21,7 @@ describe('processSidebars', () => {
];
const StaticSidebarItemsGenerator: SidebarItemsGenerator = jest.fn(
async () => {
return StaticGeneratedSidebarSlice;
},
async () => StaticGeneratedSidebarSlice,
);
async function testProcessSidebars(unprocessedSidebars: NormalizedSidebars) {

View file

@ -73,9 +73,9 @@ export function collectSidebarLinks(sidebar: Sidebar): SidebarItemLink[] {
export function collectSidebarsDocIds(
sidebars: Sidebars,
): Record<string, string[]> {
return mapValues(sidebars, (sidebar) => {
return collectSidebarDocItems(sidebar).map((docItem) => docItem.id);
});
return mapValues(sidebars, (sidebar) =>
collectSidebarDocItems(sidebar).map((docItem) => docItem.id),
);
}
export function createSidebarsUtils(sidebars: Sidebars): {

View file

@ -11,11 +11,9 @@ import {mapValues} from 'lodash';
export function getVersionTags(docs: DocMetadata[]): VersionTags {
const groups = groupTaggedItems(docs, (doc) => doc.tags);
return mapValues(groups, (group) => {
return {
name: group.tag.label,
docIds: group.items.map((item) => item.id),
permalink: group.tag.permalink,
};
});
return mapValues(groups, (group) => ({
name: group.tag.label,
docIds: group.items.map((item) => item.id),
permalink: group.tag.permalink,
}));
}

View file

@ -164,16 +164,16 @@ function translateSidebars(
version: LoadedVersion,
sidebarsTranslations: TranslationFileContent,
): Sidebars {
return mapValues(version.sidebars, (sidebar, sidebarName) => {
return translateSidebar({
return mapValues(version.sidebars, (sidebar, sidebarName) =>
translateSidebar({
sidebar,
sidebarName: getNormalizedSidebarName({
sidebarName,
versionName: version.versionName,
}),
sidebarsTranslations,
});
});
}),
);
}
function getVersionTranslationFiles(version: LoadedVersion): TranslationFiles {

View file

@ -113,7 +113,6 @@ export type LastUpdateData = {
export type DocFrontMatter = {
// Front matter uses snake case
/* eslint-disable camelcase */
id?: string;
title?: string;
tags?: FrontMatterTag[];
@ -133,7 +132,6 @@ export type DocFrontMatter = {
toc_max_heading_level?: number;
pagination_next?: string | null;
pagination_prev?: string | null;
/* eslint-enable camelcase */
};
export type DocMetadataBase = LastUpdateData & {