diff --git a/packages/tools/docs-tools/.prettierignore b/packages/tools/docs-tools/.prettierignore new file mode 100644 index 00000000000..d5c3e32566c --- /dev/null +++ b/packages/tools/docs-tools/.prettierignore @@ -0,0 +1,5 @@ +node_modules +dist +lib +etc +temp diff --git a/packages/tools/docs-tools/src/remarkAdmonition.ts b/packages/tools/docs-tools/src/remarkAdmonition.ts index 614d2d71e97..c8f5b465d94 100644 --- a/packages/tools/docs-tools/src/remarkAdmonition.ts +++ b/packages/tools/docs-tools/src/remarkAdmonition.ts @@ -14,6 +14,7 @@ let STARTELM: Paragraph | undefined; // check the branch with the start of a notification // notifications start with ':::' followed by a label and maybe a title +// eslint-disable-next-line @rushstack/no-new-null const isStart = (branch: DocsRootContent): null | RegExpMatchArray => { if ('children' in branch === false) return null; diff --git a/packages/tools/docs-tools/src/remarkCheckForCodeTitle.ts b/packages/tools/docs-tools/src/remarkCheckForCodeTitle.ts index 5302436801b..f2bf1dbf459 100644 --- a/packages/tools/docs-tools/src/remarkCheckForCodeTitle.ts +++ b/packages/tools/docs-tools/src/remarkCheckForCodeTitle.ts @@ -1,6 +1,6 @@ import type { ITree, Plugin } from './types'; -const replaceOrConcatString = (str?: string | null): string => { +const replaceOrConcatString = (str?: string): string => { if (!str) str = ''; const emptyTitleRegex = /title=""/g; const emptyTitleReplacement = 'title=" "'; @@ -20,7 +20,7 @@ const remarkCheckForCodeTitle = (): Plugin => { const { type } = node; if (type === 'code') { - node.meta = replaceOrConcatString(node.meta); + node.meta = replaceOrConcatString(node.meta ?? ''); } return node; diff --git a/packages/tools/docs-tools/src/remarkFigureOutOfParagraph.ts b/packages/tools/docs-tools/src/remarkFigureOutOfParagraph.ts index e579d2bcc00..e439954a1df 100644 --- a/packages/tools/docs-tools/src/remarkFigureOutOfParagraph.ts +++ b/packages/tools/docs-tools/src/remarkFigureOutOfParagraph.ts @@ -8,7 +8,7 @@ import type { DocsRootContent, ITree, Plugin } from './types'; const remarkFigureOutOfParagraph = (): Plugin => { return async (tree): Promise => { - const children = tree.children.map((node) => { + const children = tree.children.map((node: Partial) => { const { type } = node; if ( @@ -24,7 +24,6 @@ const remarkFigureOutOfParagraph = (): Plugin => { type: 'image', }; - // @ts-ignore delete newNode.children; return newNode; } diff --git a/packages/tools/docs-tools/src/remarkHeadersToProps.ts b/packages/tools/docs-tools/src/remarkHeadersToProps.ts index 6154dfef9e6..284161d6a15 100644 --- a/packages/tools/docs-tools/src/remarkHeadersToProps.ts +++ b/packages/tools/docs-tools/src/remarkHeadersToProps.ts @@ -10,7 +10,7 @@ import type { TagNameType, } from './types'; -const getTagName = (depth = 1) => `h${depth}` as TagNameType; +const getTagName = (depth = 1): TagNameType => `h${depth}` as TagNameType; const lastHeading = (parent: IStartArray, newChild: Heading): IStartArray => { const nodes = [parent]; diff --git a/packages/tools/docs-tools/src/remarkYoutube.ts b/packages/tools/docs-tools/src/remarkYoutube.ts index e14e6e4ec84..d0c1de6a7ed 100644 --- a/packages/tools/docs-tools/src/remarkYoutube.ts +++ b/packages/tools/docs-tools/src/remarkYoutube.ts @@ -35,10 +35,9 @@ const remarkYoutube = (): Plugin => { title: leaf.title, }, }, + children: [], }; - // @ts-ignore - delete newNode.children; return newNode; } } diff --git a/packages/tools/docs-tools/src/types.ts b/packages/tools/docs-tools/src/types.ts index 329ba93dd99..09d33d24d6e 100644 --- a/packages/tools/docs-tools/src/types.ts +++ b/packages/tools/docs-tools/src/types.ts @@ -186,6 +186,7 @@ export type ChildrenWithValues = TypeWithValue[]; export interface IElementType { type: 'element'; + value?: string; children: TypeWithValue[]; data: { hName: string;