chore(v2): Fix a lot of eslint warnings (#2972)

This commit is contained in:
Sam Zhou 2020-06-20 00:30:18 -04:00 committed by GitHub
parent 4aa77651d3
commit 3611c96f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 145 additions and 130 deletions

View file

@ -310,7 +310,7 @@ describe('versioned website', () => {
permalink: '/docs/next/',
},
});
expect(docsMetadata['hello']).toEqual({
expect(docsMetadata.hello).toEqual({
id: 'hello',
isDocsHomePage: true,
permalink: '/docs/next/',

View file

@ -68,7 +68,7 @@ const DEFAULT_OPTIONS: PluginOptions = {
function getFirstDocLinkOfSidebar(
sidebarItems: DocsSidebarItem[],
): string | null {
for (let sidebarItem of sidebarItems) {
for (const sidebarItem of sidebarItems) {
if (sidebarItem.type === 'category') {
const url = getFirstDocLinkOfSidebar(sidebarItem.items);
if (url) {
@ -534,7 +534,7 @@ Available document ids=
options: {
siteDir,
docsDir,
sourceToPermalink: sourceToPermalink,
sourceToPermalink,
versionedDir,
},
},

View file

@ -17,7 +17,7 @@ export default function (
siteDir: string,
sourceToPermalink: SourceToPermalink,
versionedDir?: string,
) {
): string {
// Determine the source dir. e.g: /website/docs, /website/versioned_docs/version-1.0.0
let sourceDir: string | undefined;
const thisSource = filePath;
@ -40,7 +40,9 @@ export default function (
if (line.trim().startsWith('```')) {
fencedBlock = !fencedBlock;
}
if (fencedBlock) return line;
if (fencedBlock) {
return line;
}
let modifiedLine = line;
// Replace inline-style links or reference-style links e.g:

View file

@ -135,7 +135,7 @@ function normalizeItem(item: SidebarItemRaw): SidebarItem[] {
case 'doc':
assertIsDoc(item);
return [item];
default:
default: {
const extraMigrationError =
item.type === 'subcategory'
? "Docusaurus v2: 'subcategory' has been renamed as 'category'"
@ -145,6 +145,7 @@ function normalizeItem(item: SidebarItemRaw): SidebarItem[] {
item.type
}]. Sidebar item=${JSON.stringify(item)} ${extraMigrationError}`,
);
}
}
}
@ -168,7 +169,7 @@ function normalizeSidebar(sidebars: SidebarRaw): Sidebar {
export default function loadSidebars(sidebarPaths?: string[]): Sidebar {
// We don't want sidebars to be cached because of hot reloading.
let allSidebars: SidebarRaw = {};
const allSidebars: SidebarRaw = {};
if (!sidebarPaths || !sidebarPaths.length) {
return {} as Sidebar;

View file

@ -19,7 +19,7 @@ export function docsVersion(
version: string | null | undefined,
siteDir: string,
options: PathOptions,
) {
): void {
if (!version) {
throw new Error(
'No version tag specified!. Pass the version you wish to create as an argument. Ex: 1.0.0',