From e29d37dff24cfaf569f9fd148aa4f0a28457dcf4 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 1 May 2024 11:17:33 +0200 Subject: [PATCH 1/6] Update dev-dependencies --- .github/workflows/main.yml | 8 +++---- package.json | 4 ++-- readme.md | 46 +++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb63387..7ab61d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,15 +7,15 @@ jobs: name: ${{matrix.node}} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{matrix.node}} - run: npm install - run: npm test - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 strategy: matrix: node: - lts/gallium - - node + - lts/iron diff --git a/package.json b/package.json index 3638e73..1d43fe5 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "c8": "^9.0.0", "hastscript": "^9.0.0", "prettier": "^3.0.0", - "remark-cli": "^11.0.0", - "remark-preset-wooorm": "^9.0.0", + "remark-cli": "^12.0.0", + "remark-preset-wooorm": "^10.0.0", "type-coverage": "^2.0.0", "typescript": "^5.0.0", "unist-builder": "^4.0.0", diff --git a/readme.md b/readme.md index 8790ee5..160ea23 100644 --- a/readme.md +++ b/readme.md @@ -12,23 +12,23 @@ ## Contents -* [What is this?](#what-is-this) -* [When should I use this?](#when-should-i-use-this) -* [Install](#install) -* [Use](#use) -* [API](#api) - * [`toHtml(tree[, options])`](#tohtmltree-options) - * [`CharacterReferences`](#characterreferences) - * [`Options`](#options) - * [`Quote`](#quote-1) - * [`Space`](#space-1) -* [Syntax](#syntax) -* [Types](#types) -* [Compatibility](#compatibility) -* [Security](#security) -* [Related](#related) -* [Contribute](#contribute) -* [License](#license) +* [What is this?](#what-is-this) +* [When should I use this?](#when-should-i-use-this) +* [Install](#install) +* [Use](#use) +* [API](#api) + * [`toHtml(tree[, options])`](#tohtmltree-options) + * [`CharacterReferences`](#characterreferences) + * [`Options`](#options) + * [`Quote`](#quote-1) + * [`Space`](#space-1) +* [Syntax](#syntax) +* [Types](#types) +* [Compatibility](#compatibility) +* [Security](#security) +* [Related](#related) +* [Contribute](#contribute) +* [License](#license) ## What is this? @@ -116,10 +116,10 @@ Serialize hast as HTML. ###### Parameters -* `tree` ([`Node`][node] or `Array`) - — tree to serialize -* `options` ([`Options`][api-options], optional) - — configuration +* `tree` ([`Node`][node] or `Array`) + — tree to serialize +* `options` ([`Options`][api-options], optional) + — configuration ###### Returns @@ -365,8 +365,8 @@ Use [`hast-util-santize`][hast-util-sanitize] to make the hast tree safe. ## Related -* [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize) - — sanitize hast +* [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize) + — sanitize hast ## Contribute From 9d7a2f7d63ec2d11b3ae5a5e4201181fdeedf6ea Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 1 May 2024 11:45:03 +0200 Subject: [PATCH 2/6] Add declaration maps --- .gitignore | 1 + package.json | 1 + readme.md | 2 +- tsconfig.json | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c977c85..40205b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +*.d.ts.map *.d.ts *.log coverage/ diff --git a/package.json b/package.json index 1d43fe5..710856f 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "exports": "./index.js", "files": [ "lib/", + "index.d.ts.map", "index.d.ts", "index.js" ], diff --git a/readme.md b/readme.md index 160ea23..d3d8820 100644 --- a/readme.md +++ b/readme.md @@ -89,7 +89,7 @@ npm install hastscript hast-util-to-html import {h} from 'hastscript' import {toHtml} from 'hast-util-to-html' -var tree = h('.alpha', [ +const tree = h('.alpha', [ 'bravo ', h('b', 'charlie'), ' delta ', diff --git a/tsconfig.json b/tsconfig.json index 82cc749..4d9161a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "checkJs": true, "customConditions": ["development"], "declaration": true, + "declarationMap": true, "emitDeclarationOnly": true, "exactOptionalPropertyTypes": true, "lib": ["es2022"], From 0a30b45db1f2d50a8222b94ad14a20d8edd3575e Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 27 Aug 2024 17:17:43 +0800 Subject: [PATCH 3/6] Remove unused dependency Closes GH-42. Reviewed-by: Titus Wormer --- package.json | 1 - test/raw.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 710856f..8cfc85e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", - "hast-util-raw": "^9.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", diff --git a/test/raw.js b/test/raw.js index 3ad8b94..77c1d0d 100644 --- a/test/raw.js +++ b/test/raw.js @@ -1,5 +1,5 @@ /** - * @typedef {import('hast-util-raw')} DoNotTouchThisRegistersRawInTheTree + * @typedef {import('mdast-util-to-hast')} DoNotTouchThisRegistersRawInTheTree */ import assert from 'node:assert/strict' From 79d3de7f3a449ca96c9706b097d958135c28a8b1 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 27 Aug 2024 11:19:09 +0200 Subject: [PATCH 4/6] Update dev-dependencies --- .github/workflows/main.yml | 12 ++++++------ package.json | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ab61d9..2ce794f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,3 @@ -name: main -on: - - pull_request - - push jobs: main: name: ${{matrix.node}} @@ -17,5 +13,9 @@ jobs: strategy: matrix: node: - - lts/gallium - - lts/iron + - lts/hydrogen + - node +name: main +on: + - pull_request + - push diff --git a/package.json b/package.json index 8cfc85e..28c4dde 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "zwitch": "^2.0.4" }, "devDependencies": { - "@types/node": "^20.0.0", - "c8": "^9.0.0", + "@types/node": "^22.0.0", + "c8": "^10.0.0", "hastscript": "^9.0.0", "prettier": "^3.0.0", "remark-cli": "^12.0.0", @@ -56,7 +56,7 @@ "type-coverage": "^2.0.0", "typescript": "^5.0.0", "unist-builder": "^4.0.0", - "xo": "^0.58.0" + "xo": "^0.59.0" }, "scripts": { "prepack": "npm run build && npm run format", From f1c5dd78dd0635fb7790b3373ec4a7cc8db5f363 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 27 Aug 2024 11:24:37 +0200 Subject: [PATCH 5/6] Refactor to use `@import`s --- lib/handle/comment.js | 6 ++---- lib/handle/doctype.js | 9 ++------- lib/handle/element.js | 7 ++----- lib/handle/index.js | 6 ++---- lib/handle/raw.js | 8 +++----- lib/handle/root.js | 9 ++------- lib/handle/text.js | 9 +++------ lib/index.js | 30 +++++++++++++----------------- lib/omission/closing.js | 3 +-- lib/omission/omission.js | 3 +-- lib/omission/opening.js | 3 +-- lib/omission/util/siblings.js | 3 +-- test/raw.js | 2 +- 13 files changed, 34 insertions(+), 64 deletions(-) diff --git a/lib/handle/comment.js b/lib/handle/comment.js index 95ff4aa..3a49064 100644 --- a/lib/handle/comment.js +++ b/lib/handle/comment.js @@ -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' diff --git a/lib/handle/doctype.js b/lib/handle/doctype.js index d2b9c4a..36b43ad 100644 --- a/lib/handle/doctype.js +++ b/lib/handle/doctype.js @@ -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. * diff --git a/lib/handle/element.js b/lib/handle/element.js index 217f105..17b4713 100644 --- a/lib/handle/element.js +++ b/lib/handle/element.js @@ -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' diff --git a/lib/handle/index.js b/lib/handle/index.js index e861c01..31401e1 100644 --- a/lib/handle/index.js +++ b/lib/handle/index.js @@ -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' diff --git a/lib/handle/raw.js b/lib/handle/raw.js index 6c89a11..834ab92 100644 --- a/lib/handle/raw.js +++ b/lib/handle/raw.js @@ -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' diff --git a/lib/handle/root.js b/lib/handle/root.js index ccd84e1..97ef35b 100644 --- a/lib/handle/root.js +++ b/lib/handle/root.js @@ -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. * diff --git a/lib/handle/text.js b/lib/handle/text.js index af08b28..03cefde 100644 --- a/lib/handle/text.js +++ b/lib/handle/text.js @@ -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' diff --git a/lib/index.js b/lib/index.js index 93bb730..05da5b5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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' */ /** @@ -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 `` element is found in the HTML space, this package already * automatically switches to and from the SVG space when entering and exiting @@ -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' diff --git a/lib/omission/closing.js b/lib/omission/closing.js index a7cd1a1..b30baf7 100644 --- a/lib/omission/closing.js +++ b/lib/omission/closing.js @@ -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' diff --git a/lib/omission/omission.js b/lib/omission/omission.js index 692101c..902f38f 100644 --- a/lib/omission/omission.js +++ b/lib/omission/omission.js @@ -1,6 +1,5 @@ /** - * @typedef {import('hast').Element} Element - * @typedef {import('hast').Parents} Parents + * @import {Element, Parents} from 'hast' */ /** diff --git a/lib/omission/opening.js b/lib/omission/opening.js index 65c9964..edc878c 100644 --- a/lib/omission/opening.js +++ b/lib/omission/opening.js @@ -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' diff --git a/lib/omission/util/siblings.js b/lib/omission/util/siblings.js index c686a17..09edae4 100644 --- a/lib/omission/util/siblings.js +++ b/lib/omission/util/siblings.js @@ -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' diff --git a/test/raw.js b/test/raw.js index 77c1d0d..6b586f5 100644 --- a/test/raw.js +++ b/test/raw.js @@ -1,5 +1,5 @@ /** - * @typedef {import('mdast-util-to-hast')} DoNotTouchThisRegistersRawInTheTree + * @import {} from 'mdast-util-to-hast' */ import assert from 'node:assert/strict' From 661367abb012ddade4712fefa7c8ae7ff2b10eac Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 27 Aug 2024 11:26:38 +0200 Subject: [PATCH 6/6] 9.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28c4dde..cdbb819 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hast-util-to-html", - "version": "9.0.1", + "version": "9.0.2", "description": "hast utility to serialize to HTML", "license": "MIT", "keywords": [