refactor: enforce type import specifiers (#6230)

* refactor: enforce type import specifiers

* fix

* Upgrade esbuild

* Fix (haha)
This commit is contained in:
Joshua Chen 2021-12-31 21:17:09 +08:00 committed by GitHub
parent 24d65d9bdd
commit cb1aa30286
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
192 changed files with 484 additions and 337 deletions

View file

@ -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';

View file

@ -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';

View file

@ -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>.