mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-13 00:03:57 +02:00
refactor: enforce type import specifiers (#6230)
* refactor: enforce type import specifiers * fix * Upgrade esbuild * Fix (haha)
This commit is contained in:
parent
24d65d9bdd
commit
cb1aa30286
192 changed files with 484 additions and 337 deletions
|
@ -8,7 +8,7 @@
|
|||
/* Based on remark-slug (https://github.com/remarkjs/remark-slug) and gatsby-remark-autolink-headers (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-autolink-headers) */
|
||||
|
||||
import {parseMarkdownHeadingId, createSlugger} from '@docusaurus/utils';
|
||||
import visit, {Visitor} from 'unist-util-visit';
|
||||
import visit, {type Visitor} from 'unist-util-visit';
|
||||
import toString from 'mdast-util-to-string';
|
||||
import type {Transformer} from 'unified';
|
||||
import type {Parent} from 'unist';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {parse, ParserOptions} from '@babel/parser';
|
||||
import {parse, type ParserOptions} from '@babel/parser';
|
||||
import type {Identifier} from '@babel/types';
|
||||
import traverse from '@babel/traverse';
|
||||
import stringifyObject from 'stringify-object';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import toString from 'mdast-util-to-string';
|
||||
import visit, {Visitor} from 'unist-util-visit';
|
||||
import visit from 'unist-util-visit';
|
||||
import {toValue} from '../utils';
|
||||
import type {TOCItem} from '@docusaurus/types';
|
||||
import type {Node} from 'unist';
|
||||
|
@ -26,7 +26,7 @@ interface SearchItem {
|
|||
export default function search(node: Node): TOCItem[] {
|
||||
const headings: SearchItem[] = [];
|
||||
|
||||
const visitor: Visitor<Heading> = (child, _index, parent) => {
|
||||
visit(node, 'heading', (child: Heading, _index, parent) => {
|
||||
const value = toString(child);
|
||||
|
||||
// depth:1 headings are titles and not included in the TOC
|
||||
|
@ -44,9 +44,7 @@ export default function search(node: Node): TOCItem[] {
|
|||
level: child.depth,
|
||||
parentIndex: -1,
|
||||
});
|
||||
};
|
||||
|
||||
visit(node, 'heading', visitor);
|
||||
});
|
||||
|
||||
// Keep track of which previous index would be the current heading's direcy parent.
|
||||
// Each entry <i> is the last index of the `headings` array at heading level <i>.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue