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

@ -19,7 +19,7 @@ import {
} from '@docusaurus/utils';
import {LoadContext} from '@docusaurus/types';
export function truncate(fileString: string, truncateMarker: RegExp) {
export function truncate(fileString: string, truncateMarker: RegExp): string {
return fileString.split(truncateMarker, 1).shift()!;
}
@ -37,7 +37,7 @@ function toUrl({date, link}: DateLink) {
export async function generateBlogFeed(
context: LoadContext,
options: PluginOptions,
) {
): Promise<Feed | null> {
if (!options.feedOptions) {
throw new Error(
'Invalid options - `feedOptions` is not expected to be null.',
@ -76,7 +76,7 @@ export async function generateBlogFeed(
} = post;
feed.addItem({
title,
id: id,
id,
link: normalizeUrl([siteUrl, permalink]),
date,
description,
@ -90,7 +90,7 @@ export async function generateBlogPosts(
blogDir: string,
{siteConfig, siteDir}: LoadContext,
options: PluginOptions,
) {
): Promise<BlogPost[]> {
const {
include,
routeBasePath,
@ -181,14 +181,16 @@ export function linkify(
siteDir: string,
blogPath: string,
blogPosts: BlogPost[],
) {
): string {
let fencedBlock = false;
const lines = fileContent.split('\n').map((line) => {
if (line.trim().startsWith('```')) {
fencedBlock = !fencedBlock;
}
if (fencedBlock) return line;
if (fencedBlock) {
return line;
}
let modifiedLine = line;
const mdRegex = /(?:(?:\]\()|(?:\]:\s?))(?!https)([^'")\]\s>]+\.mdx?)/g;