mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-29 08:57:03 +02:00
chore(v2): Fix more linter warnings (#4450)
This commit is contained in:
parent
3422f80a9a
commit
83d043ecb3
27 changed files with 116 additions and 85 deletions
|
@ -13,6 +13,7 @@ import Color from 'color';
|
|||
|
||||
import {
|
||||
ClassicPresetEntries,
|
||||
SidebarEntry,
|
||||
SidebarEntries,
|
||||
VersionOneConfig,
|
||||
VersionTwoConfig,
|
||||
|
@ -584,9 +585,8 @@ function migrateVersionedSidebar(
|
|||
return;
|
||||
}
|
||||
const newSidebar = Object.entries(sidebarEntries).reduce(
|
||||
(topLevel: {[key: string]: any}, value) => {
|
||||
(topLevel: SidebarEntries, value) => {
|
||||
const key = value[0].replace(versionRegex, '');
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
topLevel[key] = Object.entries(value[1]).reduce(
|
||||
(
|
||||
acc: {[key: string]: Array<Record<string, unknown> | string>},
|
||||
|
@ -594,16 +594,14 @@ function migrateVersionedSidebar(
|
|||
) => {
|
||||
acc[
|
||||
val[0].replace(versionRegex, '')
|
||||
] = (val[1] as Array<any>).map((item) => {
|
||||
] = (val[1] as Array<SidebarEntry>).map((item) => {
|
||||
if (typeof item === 'string') {
|
||||
return item.replace(versionRegex, '');
|
||||
}
|
||||
return {
|
||||
type: 'category',
|
||||
label: item.label,
|
||||
ids: item.ids.map((id: string) =>
|
||||
id.replace(versionRegex, ''),
|
||||
),
|
||||
ids: item.ids.map((id) => id.replace(versionRegex, '')),
|
||||
};
|
||||
});
|
||||
return acc;
|
||||
|
@ -618,14 +616,14 @@ function migrateVersionedSidebar(
|
|||
});
|
||||
sidebars.forEach((sidebar) => {
|
||||
const newSidebar = Object.entries(sidebar.entries).reduce(
|
||||
(acc: {[key: string]: any}, val) => {
|
||||
(acc: SidebarEntries, val) => {
|
||||
const key = `version-${sidebar.version}/${val[0]}`;
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
acc[key] = Object.entries(val[1]).map((value) => {
|
||||
return {
|
||||
type: 'category',
|
||||
label: value[0],
|
||||
items: (value[1] as Array<any>).map((sidebarItem) => {
|
||||
items: (value[1] as Array<SidebarEntry>).map((sidebarItem) => {
|
||||
if (typeof sidebarItem === 'string') {
|
||||
return {
|
||||
type: 'doc',
|
||||
|
@ -756,7 +754,10 @@ function migratePackageFile(
|
|||
newDir: string,
|
||||
): void {
|
||||
const packageFile = importFresh(`${siteDir}/package.json`) as {
|
||||
[key: string]: any;
|
||||
scripts?: Record<string, string>;
|
||||
dependencies?: Record<string, string>;
|
||||
devDependencies?: Record<string, string>;
|
||||
[otherKey: string]: unknown;
|
||||
};
|
||||
packageFile.scripts = {
|
||||
...packageFile.scripts,
|
||||
|
|
|
@ -21,6 +21,14 @@ export type ClassicPresetEntries = {
|
|||
theme: {[key: string]: unknown};
|
||||
};
|
||||
|
||||
export type SidebarEntry =
|
||||
| string
|
||||
| {
|
||||
type: string;
|
||||
label: string;
|
||||
ids: string[];
|
||||
};
|
||||
|
||||
export type SidebarEntries = {
|
||||
[key: string]:
|
||||
| Record<string, unknown>
|
||||
|
@ -97,10 +105,10 @@ export type VersionOneConfig = {
|
|||
organizationName?: string;
|
||||
projectName?: string;
|
||||
noIndex?: boolean;
|
||||
headerLinks?: Array<any>;
|
||||
headerLinks?: Array<{doc: string; href: string; label: string; page: string}>;
|
||||
headerIcon?: string;
|
||||
favicon?: string;
|
||||
colors?: any;
|
||||
colors?: {primaryColor: string};
|
||||
copyright?: string;
|
||||
editUrl?: string;
|
||||
customDocsPath?: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue