Skip to content

Commit

Permalink
feat(docs-tools): fixing types
Browse files Browse the repository at this point in the history
  • Loading branch information
realdreamer committed Nov 15, 2023
1 parent 421733e commit adabee6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/tools/docs-tools/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
lib
etc
temp
1 change: 1 addition & 0 deletions packages/tools/docs-tools/src/remarkAdmonition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions packages/tools/docs-tools/src/remarkCheckForCodeTitle.ts
Original file line number Diff line number Diff line change
@@ -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=" "';
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions packages/tools/docs-tools/src/remarkFigureOutOfParagraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { DocsRootContent, ITree, Plugin } from './types';

const remarkFigureOutOfParagraph = (): Plugin => {
return async (tree): Promise<ITree> => {
const children = tree.children.map((node) => {
const children = tree.children.map((node: Partial<DocsRootContent>) => {
const { type } = node;

if (
Expand All @@ -24,7 +24,6 @@ const remarkFigureOutOfParagraph = (): Plugin => {
type: 'image',
};

// @ts-ignore
delete newNode.children;
return newNode;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/docs-tools/src/remarkHeadersToProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 1 addition & 2 deletions packages/tools/docs-tools/src/remarkYoutube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ const remarkYoutube = (): Plugin => {
title: leaf.title,
},
},
children: [],
};

// @ts-ignore
delete newNode.children;
return newNode;
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/tools/docs-tools/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export type ChildrenWithValues = TypeWithValue[];

export interface IElementType {
type: 'element';
value?: string;
children: TypeWithValue[];
data: {
hName: string;
Expand Down

0 comments on commit adabee6

Please sign in to comment.