Skip to content

Commit

Permalink
Refactor to use @imports
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 27, 2024
1 parent 79d3de7 commit f1c5dd7
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 64 deletions.
6 changes: 2 additions & 4 deletions lib/handle/comment.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @typedef {import('hast').Comment} Comment
* @typedef {import('hast').Parents} Parents
*
* @typedef {import('../index.js').State} State
* @import {Comment, Parents} from 'hast'
* @import {State} from '../index.js'
*/

import {stringifyEntities} from 'stringify-entities'
Expand Down
9 changes: 2 additions & 7 deletions lib/handle/doctype.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/**
* @typedef {import('hast').Doctype} Doctype
* @typedef {import('hast').Parents} Parents
*
* @typedef {import('../index.js').State} State
* @import {Doctype, Parents} from 'hast'
* @import {State} from '../index.js'
*/

// Make VS code see references to the above types.
''

/**
* Serialize a doctype.
*
Expand Down
7 changes: 2 additions & 5 deletions lib/handle/element.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Properties} Properties
*
* @typedef {import('../index.js').State} State
* @import {Element, Parents, Properties} from 'hast'
* @import {State} from '../index.js'
*/

import {ccount} from 'ccount'
Expand Down
6 changes: 2 additions & 4 deletions lib/handle/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @typedef {import('hast').Parents} Parents
*
* @typedef {import('../index.js').State} State
* @import {Nodes, Parents} from 'hast'
* @import {State} from '../index.js'
*/

import {zwitch} from 'zwitch'
Expand Down
8 changes: 3 additions & 5 deletions lib/handle/raw.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* @typedef {import('hast').Parents} Parents
*
* @typedef {import('mdast-util-to-hast').Raw} Raw
*
* @typedef {import('../index.js').State} State
* @import {Parents} from 'hast'
* @import {Raw} from 'mdast-util-to-hast'
* @import {State} from '../index.js'
*/

import {text} from './text.js'
Expand Down
9 changes: 2 additions & 7 deletions lib/handle/root.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/**
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Root} Root
*
* @typedef {import('../index.js').State} State
* @import {Parents, Root} from 'hast'
* @import {State} from '../index.js'
*/

// Make VS code see references to the above types.
''

/**
* Serialize a root.
*
Expand Down
9 changes: 3 additions & 6 deletions lib/handle/text.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/**
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Text} Text
*
* @typedef {import('mdast-util-to-hast').Raw} Raw
*
* @typedef {import('../index.js').State} State
* @import {Parents, Text} from 'hast'
* @import {Raw} from 'mdast-util-to-hast'
* @import {State} from '../index.js'
*/

import {stringifyEntities} from 'stringify-entities'
Expand Down
30 changes: 13 additions & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').RootContent} RootContent
*
* @typedef {import('property-information').Schema} Schema
*
* @typedef {import('stringify-entities').Options} StringifyEntitiesOptions
* @import {Nodes, Parents, RootContent} from 'hast'
* @import {Schema} from 'property-information'
* @import {Options as StringifyEntitiesOptions} from 'stringify-entities'
*/

/**
Expand Down Expand Up @@ -77,10 +73,10 @@
* Leave attributes unquoted if that results in less bytes (default: `false`).
*
* Not used in the SVG space.
* @property {Quote | null | undefined} [quote='"']
* Preferred quote to use (default: `'"'`).
* @property {boolean | null | undefined} [quoteSmart=false]
* Use the other quote if that results in less bytes (default: `false`).
* @property {Quote | null | undefined} [quote='"']
* Preferred quote to use (default: `'"'`).
* @property {Space | null | undefined} [space='html']
* When an `<svg>` element is found in the HTML space, this package already
* automatically switches to and from the SVG space when entering and exiting
Expand Down Expand Up @@ -138,18 +134,18 @@
*
* @typedef State
* Info passed around about the current state.
* @property {(node: Nodes, index: number | undefined, parent: Parents | undefined) => string} one
* Serialize one node.
* @property {(node: Parents | undefined) => string} all
* Serialize the children of a parent node.
* @property {Settings} settings
* User configuration.
* @property {Schema} schema
* Current schema.
* @property {Quote} quote
* Preferred quote.
* @property {Quote} alternative
* Alternative quote.
* @property {(node: Nodes, index: number | undefined, parent: Parents | undefined) => string} one
* Serialize one node.
* @property {Quote} quote
* Preferred quote.
* @property {Schema} schema
* Current schema.
* @property {Settings} settings
* User configuration.
*/

import {htmlVoidElements} from 'html-void-elements'
Expand Down
3 changes: 1 addition & 2 deletions lib/omission/closing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @import {Element, Parents} from 'hast'
*/

import {whitespace} from 'hast-util-whitespace'
Expand Down
3 changes: 1 addition & 2 deletions lib/omission/omission.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @import {Element, Parents} from 'hast'
*/

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/omission/opening.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @import {Element, Parents} from 'hast'
*/

import {whitespace} from 'hast-util-whitespace'
Expand Down
3 changes: 1 addition & 2 deletions lib/omission/util/siblings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').RootContent} RootContent
* @import {Parents, RootContent} from 'hast'
*/

import {whitespace} from 'hast-util-whitespace'
Expand Down
2 changes: 1 addition & 1 deletion test/raw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('mdast-util-to-hast')} DoNotTouchThisRegistersRawInTheTree
* @import {} from 'mdast-util-to-hast'
*/

import assert from 'node:assert/strict'
Expand Down

0 comments on commit f1c5dd7

Please sign in to comment.