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 Sep 17, 2024
1 parent 4be1154 commit 94e970b
Show file tree
Hide file tree
Showing 41 changed files with 59 additions and 81 deletions.
2 changes: 1 addition & 1 deletion packages/hast-util-from-string/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @import {Nodes} from 'hast'
*/

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

import assert from 'node:assert/strict'
Expand Down
2 changes: 1 addition & 1 deletion packages/hast-util-is-body-ok-link/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @import {Nodes} from 'hast'
*/

const list = new Set(['pingback', 'prefetch', 'stylesheet'])
Expand Down
2 changes: 1 addition & 1 deletion packages/hast-util-is-conditional-comment/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @import {Nodes} from 'hast'
*/

const re = /^\[if[ \t\f\n\r]+[^\]]+]|<!\[endif]$/
Expand Down
2 changes: 1 addition & 1 deletion packages/hast-util-is-css-link/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @import {Nodes} from 'hast'
*/

import {collapseWhiteSpace} from 'collapse-white-space'
Expand Down
2 changes: 1 addition & 1 deletion packages/hast-util-is-css-style/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @import {Nodes} from 'hast'
*/

import {collapseWhiteSpace} from 'collapse-white-space'
Expand Down
3 changes: 1 addition & 2 deletions packages/hast-util-is-javascript/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @typedef {import('hast').Properties} Properties
* @import {Nodes, Properties} from 'hast'
*/

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

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/rehype-concat-css-style/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Root} Root
* @import {Element, Parents, Root} from 'hast'
*/

import {fromString} from 'hast-util-from-string'
Expand Down
4 changes: 1 addition & 3 deletions packages/rehype-concat-javascript/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Root} Root
* @import {Element, Parents, Root} from 'hast'
*/

import {fromString} from 'hast-util-from-string'
Expand Down
4 changes: 1 addition & 3 deletions packages/rehype-css-to-top/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Root} Root
* @import {Element, Parents, Root} from 'hast'
*/

import {isCssLink} from 'hast-util-is-css-link'
Expand Down
4 changes: 1 addition & 3 deletions packages/rehype-javascript-to-bottom/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Root} Root
* @import {Element, Parents, Root} from 'hast'
*/

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-minify-attribute-whitespace/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Properties} Properties
* @typedef {import('hast').Root} Root
* @import {Properties, Root} from 'hast'
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-css-style/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import CleanCSS from 'clean-css'
Expand Down
4 changes: 2 additions & 2 deletions packages/rehype-minify-enumerated-attribute/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @typedef {import('hast').Root} Root
* @typedef {import('html-enumerated-attributes').Definition} Definition
* @import {Root} from 'hast'
* @import {Definition} from 'html-enumerated-attributes'
*/

import {matches} from 'hast-util-select'
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-minify-event-handler/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Properties} Properties
* @typedef {import('hast').Root} Root
* @import {Properties, Root} from 'hast'
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-javascript-script/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {fromString} from 'hast-util-from-string'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-javascript-url/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isElement} from 'hast-util-is-element'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-json-script/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {fromString} from 'hast-util-from-string'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-language/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {bcp47Normalize} from 'bcp-47-normalize'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-media-attribute/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import CleanCSS from 'clean-css'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-meta-color/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import CleanCSS from 'clean-css'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-meta-content/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {parse, stringify} from 'comma-separated-tokens'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-minify-style-attribute/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import CleanCSS from 'clean-css'
Expand Down
8 changes: 3 additions & 5 deletions packages/rehype-minify-url/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* @typedef {import('hast').Root} Root
* @typedef {import('hast').Properties} Properties
* @typedef {import('relateurl')} RelateUrl
* @typedef {import('relateurl').Options} RelateOptions
* @typedef {import('vfile').VFile} VFile
* @import {Properties, Root} from 'hast'
* @import {default as RelateUrl, Options as RelateOptions} from 'relateurl'
* @import {VFile} from 'vfile'
*/

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/rehype-minify-whitespace/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/**
* @typedef {import('hast').Nodes} Nodes
* @typedef {import('hast').Parents} Parents
* @typedef {import('hast').Root} Root
* @typedef {import('hast').Text} Text
* @import {Nodes, Parents, Root, Text} from 'hast'
*/

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-normalize-attribute-value-case/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Properties} Properties
* @typedef {import('hast').Root} Root
* @import {Properties, Root} from 'hast'
*/

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/rehype-preset-minify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
* </html>
*/

/**
* @import {Preset} from 'unified'
*/

import rehypeMinifyAttributeWhitespace from 'rehype-minify-attribute-whitespace'
import rehypeMinifyCssStyle from 'rehype-minify-css-style'
import rehypeMinifyEnumeratedAttribute from 'rehype-minify-enumerated-attribute'
Expand Down Expand Up @@ -114,7 +118,7 @@ const plugins = [
/**
* Preset to minify HTML.
*
* @type {import('unified').Preset}
* @type {Preset}
*/
const rehypePresetMinify = {plugins, settings}

Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-prevent-favicon-request/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Root} Root
* @import {Element, Root} from 'hast'
*/

import {visit} from 'unist-util-visit'
Expand Down
6 changes: 4 additions & 2 deletions packages/rehype-remove-comments/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* @typedef {import('hast').Root} Root
*
* @import {Root} from 'hast'
*/

/**
* @typedef Options
* Configuration.
* @property {boolean | null | undefined} [removeConditional=false]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isElement} from 'hast-util-is-element'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-remove-empty-attribute/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isElement} from 'hast-util-is-element'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isJavaScript} from 'hast-util-is-javascript'
Expand Down
4 changes: 1 addition & 3 deletions packages/rehype-remove-meta-http-equiv/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Parents} Parents
* @import {Element, Parents, Root} from 'hast'
*/

import {visit} from 'unist-util-visit'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-remove-script-type-javascript/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isJavaScript} from 'hast-util-is-javascript'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-remove-style-type-css/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isCssLink} from 'hast-util-is-css-link'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-sort-attribute-values/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('hast').Root} Root
* @import {Root} from 'hast'
*/

import {isElement} from 'hast-util-is-element'
Expand Down
3 changes: 1 addition & 2 deletions packages/rehype-sort-attributes/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('hast').Properties} Properties
* @typedef {import('hast').Root} Root
* @import {Properties, Root} from 'hast'
*/

import {visit} from 'unist-util-visit'
Expand Down
2 changes: 1 addition & 1 deletion script/build-packages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('type-fest').PackageJson} PackageJson
* @import {PackageJson} from 'type-fest'
*/

import fs from 'node:fs/promises'
Expand Down
13 changes: 5 additions & 8 deletions script/pipeline-package.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/**
* @typedef {import('comment-parser').Spec} Spec
* @typedef {import('mdast').Paragraph} Paragraph
* @typedef {import('mdast').PhrasingContent} PhrasingContent
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast').TopLevelContent} TopLevelContent
* @typedef {import('parse-author').Author} Author
* @typedef {import('type-fest').PackageJson} PackageJson
* @typedef {import('unified').Plugin} Plugin
* @import {Spec} from 'comment-parser'
* @import {Paragraph, PhrasingContent, Root, TopLevelContent} from 'mdast'
* @import {Author} from 'parse-author'
* @import {PackageJson} from 'type-fest'
* @import {Plugin} from 'unified'
*/

/**
Expand Down
13 changes: 5 additions & 8 deletions script/pipeline-root.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('mdast').List} List
* @typedef {import('mdast').Html} Html
* @typedef {import('type-fest').PackageJson} PackageJson
* @typedef {import('vfile').VFile} VFile
* @typedef {import('./benchmark.js').Result} Result
* @typedef {import('./benchmark.js').Datum} Datum
* @import {ElementContent, Element} from 'hast'
* @import {List, Html} from 'mdast'
* @import {PackageJson} from 'type-fest'
* @import {VFile} from 'vfile'
* @import {Datum, Result} from './benchmark.js'
*/

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

0 comments on commit 94e970b

Please sign in to comment.