mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +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
|
@ -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};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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`,
|
||||
);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue