chore(v2): Fix more linter warnings (#4450)

This commit is contained in:
Sam Zhou 2021-03-18 13:05:09 -04:00 committed by GitHub
parent 3422f80a9a
commit 83d043ecb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 116 additions and 85 deletions

View file

@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import path from 'path';
import {isMatch} from 'picomatch';
import commander from 'commander';
@ -42,8 +44,8 @@ const defaultDocMetadata: Partial<DocMetadata> = {
const createFakeActions = (contentDir: string) => {
const routeConfigs: RouteConfig[] = [];
const dataContainer: any = {};
const globalDataContainer: any = {};
const dataContainer: Record<string, unknown> = {};
const globalDataContainer: {pluginName?: {pluginId: unknown}} = {};
const actions = {
addRoute: (config: RouteConfig) => {
@ -53,7 +55,7 @@ const createFakeActions = (contentDir: string) => {
dataContainer[name] = content;
return path.join(contentDir, name);
},
setGlobalData: (data: any) => {
setGlobalData: (data: unknown) => {
globalDataContainer.pluginName = {pluginId: data};
},
};

View file

@ -49,7 +49,8 @@ export function cliDocsVersionCommand(
// Since we are going to create `version-${version}` folder, we need to make
// sure it's a valid pathname.
if (/[<>:"\/\\|?*\x00-\x1F]/g.test(version)) {
// eslint-disable-next-line no-control-regex
if (/[<>:"|?*\x00-\x1F]/g.test(version)) {
throw new Error(
`${pluginIdLogPrefix}Invalid version tag specified! Please ensure its a valid pathname too. Try something like: 1.0.0`,
);

View file

@ -121,7 +121,7 @@ export const getActiveDocContext = (
data.versions.forEach((version) => {
version.docs.forEach((doc) => {
if (doc.id === docId) {
result[version.name!] = doc;
result[version.name] = doc;
}
});
});
@ -157,7 +157,7 @@ export const getDocVersionSuggestions = (
const isNotOnLatestVersion = activeDocContext.activeVersion !== latestVersion;
const latestDocSuggestion: GlobalDoc | undefined = isNotOnLatestVersion
? activeDocContext?.alternateDocVersions[latestVersion.name!]
? activeDocContext?.alternateDocVersions[latestVersion.name]
: undefined;
const latestVersionSuggestion = isNotOnLatestVersion

View file

@ -78,7 +78,7 @@ function normalizeCategoryShorthand(
function assertItem<K extends string>(
item: Record<string, unknown>,
keys: K[],
): asserts item is Record<K, any> {
): asserts item is Record<K, never> {
const unknownKeys = Object.keys(item).filter(
// @ts-expect-error: key is always string
(key) => !keys.includes(key as string) && key !== 'type',
@ -272,9 +272,7 @@ export function collectSidebarsDocIds(
});
}
export function createSidebarsUtils(
sidebars: Sidebars,
): Record<string, Function> {
export function createSidebarsUtils(sidebars: Sidebars) {
const sidebarNameToDocIds = collectSidebarsDocIds(sidebars);
function getFirstDocIdOfFirstSidebar(): string | undefined {

View file

@ -8,6 +8,7 @@
// eslint-disable-next-line spaced-comment
/// <reference types="@docusaurus/module-type-aliases" />
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
import {
BrokenMarkdownLink as IBrokenMarkdownLink,
ContentPaths,
@ -72,21 +73,12 @@ export type VersionsOptions = {
export type PluginOptions = MetadataOptions &
PathOptions &
VersionsOptions & {
VersionsOptions &
RemarkAndRehypePluginOptions & {
id: string;
include: string[];
docLayoutComponent: string;
docItemComponent: string;
remarkPlugins: ([Function, Record<string, unknown>] | Function)[];
rehypePlugins: string[];
beforeDefaultRemarkPlugins: (
| [Function, Record<string, unknown>]
| Function
)[];
beforeDefaultRehypePlugins: (
| [Function, Record<string, unknown>]
| Function
)[];
admonitions: Record<string, unknown>;
disableVersioning: boolean;
excludeNextVersionDocs?: boolean;