mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 10:37:20 +02:00
chore: clean up ESLint config, enable a few rules (#6514)
* chore: clean up ESLint config, enable a few rules * enable max-len for comments * fix build
This commit is contained in:
parent
b8ccb869f1
commit
aa446b7a9c
167 changed files with 1157 additions and 960 deletions
packages/docusaurus-plugin-content-docs/src
|
@ -139,7 +139,8 @@ function doProcessDocMetadata({
|
|||
const {
|
||||
custom_edit_url: customEditURL,
|
||||
|
||||
// Strip number prefixes by default (01-MyFolder/01-MyDoc.md => MyFolder/MyDoc) by default,
|
||||
// Strip number prefixes by default
|
||||
// (01-MyFolder/01-MyDoc.md => MyFolder/MyDoc)
|
||||
// but allow to disable this behavior with front matter
|
||||
parse_number_prefixes: parseNumberPrefixes = true,
|
||||
} = frontMatter;
|
||||
|
@ -164,7 +165,8 @@ function doProcessDocMetadata({
|
|||
throw new Error(`Document id "${baseID}" cannot include slash.`);
|
||||
}
|
||||
|
||||
// For autogenerated sidebars, sidebar position can come from filename number prefix or front matter
|
||||
// For autogenerated sidebars, sidebar position can come from filename number
|
||||
// prefix or front matter
|
||||
const sidebarPosition: number | undefined =
|
||||
frontMatter.sidebar_position ?? numberPrefix;
|
||||
|
||||
|
@ -205,8 +207,9 @@ function doProcessDocMetadata({
|
|||
numberPrefixParser: options.numberPrefixParser,
|
||||
});
|
||||
|
||||
// Note: the title is used by default for page title, sidebar label, pagination buttons...
|
||||
// frontMatter.title should be used in priority over contentTitle (because it can contain markdown/JSX syntax)
|
||||
// Note: the title is used by default for page title, sidebar label,
|
||||
// pagination buttons... frontMatter.title should be used in priority over
|
||||
// contentTitle (because it can contain markdown/JSX syntax)
|
||||
const title: string = frontMatter.title ?? contentTitle ?? baseID;
|
||||
|
||||
const description: string = frontMatter.description ?? excerpt ?? '';
|
||||
|
@ -233,9 +236,8 @@ function doProcessDocMetadata({
|
|||
? versionMetadata.versionEditUrlLocalized
|
||||
: versionMetadata.versionEditUrl;
|
||||
return getEditUrl(relativeFilePath, baseVersionEditUrl);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Assign all of object properties during instantiation (if possible) for
|
||||
|
@ -361,9 +363,8 @@ export function getMainDocId({
|
|||
doc.id === firstDocIdOfFirstSidebar ||
|
||||
doc.unversionedId === firstDocIdOfFirstSidebar,
|
||||
)!;
|
||||
} else {
|
||||
return docs[0];
|
||||
}
|
||||
return docs[0];
|
||||
}
|
||||
|
||||
return getMainDoc().unversionedId;
|
||||
|
@ -407,7 +408,8 @@ export function toCategoryIndexMatcherParam({
|
|||
}
|
||||
|
||||
/**
|
||||
* guides/sidebar/autogenerated.md -> 'autogenerated', '.md', ['sidebar', 'guides']
|
||||
* `guides/sidebar/autogenerated.md` ->
|
||||
* `'autogenerated', '.md', ['sidebar', 'guides']`
|
||||
*/
|
||||
export function splitPath(str: string): {
|
||||
/**
|
||||
|
@ -428,15 +430,17 @@ export function splitPath(str: string): {
|
|||
}
|
||||
|
||||
// Return both doc ids
|
||||
// TODO legacy retro-compatibility due to old versioned sidebars using versioned doc ids
|
||||
// ("id" should be removed & "versionedId" should be renamed to "id")
|
||||
// TODO legacy retro-compatibility due to old versioned sidebars using
|
||||
// versioned doc ids ("id" should be removed & "versionedId" should be renamed
|
||||
// to "id")
|
||||
export function getDocIds(doc: DocMetadataBase): [string, string] {
|
||||
return [doc.unversionedId, doc.id];
|
||||
}
|
||||
|
||||
// docs are indexed by both versioned and unversioned ids at the same time
|
||||
// TODO legacy retro-compatibility due to old versioned sidebars using versioned doc ids
|
||||
// ("id" should be removed & "versionedId" should be renamed to "id")
|
||||
// TODO legacy retro-compatibility due to old versioned sidebars using
|
||||
// versioned doc ids ("id" should be removed & "versionedId" should be renamed
|
||||
// to "id")
|
||||
export function createDocsByIdIndex<
|
||||
Doc extends {id: string; unversionedId: string},
|
||||
>(docs: Doc[]): Record<string, Doc> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue