From 7d5dc44997e900e47c962849ee669a71abb257f6 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 16 Jul 2024 11:58:41 +0200 Subject: [PATCH 01/14] Fix build by pinning `typescript@5.4` Related-to: GH-247. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d359e43..7e6a2fd1 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "remark-preset-wooorm": "^10.0.0", "tsd": "^0.31.0", "type-coverage": "^2.0.0", - "typescript": "^5.0.0", + "typescript": "~5.4.0", "xo": "^0.58.0" }, "scripts": { From 35e72b97b067f697730db18b8a902a40065882b0 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 16 Jul 2024 14:38:15 +0200 Subject: [PATCH 02/14] Fix code generated by TS in 5.5 Related-to: 7d5dc44. Related-to: GH-247. --- package.json | 2 +- script/fix-types.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7e6a2fd1..7d359e43 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "remark-preset-wooorm": "^10.0.0", "tsd": "^0.31.0", "type-coverage": "^2.0.0", - "typescript": "~5.4.0", + "typescript": "^5.0.0", "xo": "^0.58.0" }, "scripts": { diff --git a/script/fix-types.js b/script/fix-types.js index 905cfe8f..0140555d 100644 --- a/script/fix-types.js +++ b/script/fix-types.js @@ -29,11 +29,23 @@ const result = file */ function ($0, $1) { console.log( - 'Fixed `use` overload with plugin, and *non-optional* parameters' + 'Fixed `use` overload with plugin, and *non-optional* parameters (TS pre 5.4)' ) return '...parameters: ' + $1 + ' | [boolean]' } ) + .replace( + /\.\.\.parameters: \(Parameters \| \[boolean]\)\[]/, + /** + * @returns {string} + */ + function () { + console.log( + 'Fixed `use` overload with plugin, and *non-optional* parameters (TS 5.5+)' + ) + return '...parameters: Parameters | [boolean]' + } + ) if (file === result) { console.error( From e4cb60ec7d1a364b57d43f7fdc1b9084fd42c2e8 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 8 Aug 2024 14:50:19 +0200 Subject: [PATCH 03/14] Update dev-dependencies --- package.json | 4 ++-- test/run.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7d359e43..6ffd58d9 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@types/extend": "^3.0.0", "@types/hast": "^3.0.0", "@types/mdast": "^4.0.0", - "@types/node": "^20.0.0", + "@types/node": "^22.0.0", "c8": "^10.0.0", "prettier": "^3.0.0", "remark-cli": "^12.0.0", @@ -65,7 +65,7 @@ "tsd": "^0.31.0", "type-coverage": "^2.0.0", "typescript": "^5.0.0", - "xo": "^0.58.0" + "xo": "^0.59.0" }, "scripts": { "build": "tsc --build --clean && tsc --build && node script/fix-types.js && type-coverage && tsd", diff --git a/test/run.js b/test/run.js index 3032fa5b..d9175602 100644 --- a/test/run.js +++ b/test/run.js @@ -165,7 +165,7 @@ test('`run`', async function (t) { unified() .use(function () { return function () { - return new Promise(function (_, reject) { + return new Promise(function (resolve, reject) { reject(givenError) }) } @@ -469,7 +469,7 @@ test('`run`', async function (t) { unified() .use(function () { return function () { - return new Promise(function (_, reject) { + return new Promise(function (resolve, reject) { reject(givenError) }) } From 77364ee43f975bcbc69386226c3cc4a54baa0070 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 8 Aug 2024 14:50:33 +0200 Subject: [PATCH 04/14] Fix typo in example in readme --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d175d7f6..2e91aa3d 100644 --- a/readme.md +++ b/readme.md @@ -1243,7 +1243,7 @@ const preset = { remarkCommentConfig, [remarkToc, {maxDepth: 3, tight: true}], remarkLicense - ] + ], settings: {bullet: '*', emphasis: '*', fences: true}, } From 0f26ecf2f21621413cf5dab00016de8b7dace04f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 8 Aug 2024 14:55:47 +0200 Subject: [PATCH 05/14] Refactor to use `@import` --- lib/index.js | 14 ++++---------- readme.md | 27 ++++++++++++++++++--------- test/freeze.js | 9 +++++++-- test/parse.js | 4 ---- test/process-sync.js | 9 +++++++-- test/stringify.js | 2 +- test/util/simple.js | 3 +-- 7 files changed, 38 insertions(+), 30 deletions(-) diff --git a/lib/index.js b/lib/index.js index c415714e..5e06134c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,14 +1,8 @@ /** - * @typedef {import('trough').Pipeline} Pipeline - * - * @typedef {import('unist').Node} Node - * - * @typedef {import('vfile').Compatible} Compatible - * @typedef {import('vfile').Value} Value - * - * @typedef {import('../index.js').CompileResultMap} CompileResultMap - * @typedef {import('../index.js').Data} Data - * @typedef {import('../index.js').Settings} Settings + * @import {Pipeline} from 'trough' + * @import {CompileResultMap, Data, Settings} from 'unified' + * @import {Node} from 'unist' + * @import {Compatible, Value} from 'vfile' */ /** diff --git a/readme.md b/readme.md index 2e91aa3d..d6a75abb 100644 --- a/readme.md +++ b/readme.md @@ -1129,6 +1129,10 @@ See [`Transformer`][api-transformer] for more info. `move.js`: ```js +/** + * @import {Plugin} from 'unified' + */ + /** * @typedef Options * Configuration (required). @@ -1136,7 +1140,7 @@ See [`Transformer`][api-transformer] for more info. * File extension to use (must start with `.`). */ -/** @type {import('unified').Plugin<[Options]>} */ +/** @type {Plugin<[Options]>} */ export function move(options) { if (!options || !options.extname) { throw new Error('Missing `options.extname`') @@ -1229,13 +1233,17 @@ They can contain plugins and settings. `preset.js`: ```js +/** + * @import {Preset} from 'unified' + */ + import remarkCommentConfig from 'remark-comment-config' import remarkLicense from 'remark-license' import remarkPresetLintConsistent from 'remark-preset-lint-consistent' import remarkPresetLintRecommended from 'remark-preset-lint-recommended' import remarkToc from 'remark-toc' -/** @type {import('unified').Preset} */ +/** @type {Preset} */ const preset = { plugins: [ remarkPresetLintRecommended, @@ -1493,8 +1501,9 @@ node types for the syntax trees provided by our packages (as in, ```js /** - * @typedef {import('hast').Root} HastRoot - * @typedef {import('mdast').Root} MdastRoot + * @import {Root as HastRoot} from 'hast' + * @import {Root as MdastRoot} from 'mdast' + * @import {Plugin} from 'unified' */ /** @@ -1505,14 +1514,14 @@ node types for the syntax trees provided by our packages (as in, */ // To type options: -/** @type {import('unified').Plugin<[(Options | null | undefined)?]>} */ +/** @type {Plugin<[(Options | null | undefined)?]>} */ export function myPluginAcceptingOptions(options) { const settings = options || {} // `settings` is now `Options`. } // To type a plugin that works on a certain tree, without options: -/** @type {import('unified').Plugin<[], MdastRoot>} */ +/** @type {Plugin<[], MdastRoot>} */ export function myRemarkPlugin() { return function (tree, file) { // `tree` is `MdastRoot`. @@ -1520,7 +1529,7 @@ export function myRemarkPlugin() { } // To type a plugin that transforms one tree into another: -/** @type {import('unified').Plugin<[], MdastRoot, HastRoot>} */ +/** @type {Plugin<[], MdastRoot, HastRoot>} */ export function remarkRehype() { return function (tree) { // `tree` is `MdastRoot`. @@ -1529,11 +1538,11 @@ export function remarkRehype() { } // To type a plugin that defines a parser: -/** @type {import('unified').Plugin<[], string, MdastRoot>} */ +/** @type {Plugin<[], string, MdastRoot>} */ export function remarkParse(options) {} // To type a plugin that defines a compiler: -/** @type {import('unified').Plugin<[], HastRoot, string>} */ +/** @type {Plugin<[], HastRoot, string>} */ export function rehypeStringify(options) {} ``` diff --git a/test/freeze.js b/test/freeze.js index 76ba6756..56296c87 100644 --- a/test/freeze.js +++ b/test/freeze.js @@ -1,3 +1,8 @@ +/** + * @import {Plugin} from 'unified' + * @import {Node} from 'unist' + */ + import assert from 'node:assert/strict' import test from 'node:test' import {unified} from 'unified' @@ -217,7 +222,7 @@ test('`freeze`', async function (t) { // `this` in JS is buggy in TS. /** - * @type {import('unified').Plugin<[], string, import('unist').Node>} + * @type {Plugin<[], string, Node>} */ function parse() { this.parser = simpleParser @@ -225,7 +230,7 @@ function parse() { // `this` in JS is buggy in TS. /** - * @type {import('unified').Plugin<[], import('unist').Node, string>} + * @type {Plugin<[], Node, string>} */ function compile() { this.compiler = simpleCompiler diff --git a/test/parse.js b/test/parse.js index b3f2a326..2d1d1698 100644 --- a/test/parse.js +++ b/test/parse.js @@ -1,7 +1,3 @@ -/** - * @typedef {import('unist').Node} Node - */ - import assert from 'node:assert/strict' import test from 'node:test' import {unified} from 'unified' diff --git a/test/process-sync.js b/test/process-sync.js index 2712d68d..6fbdc9c8 100644 --- a/test/process-sync.js +++ b/test/process-sync.js @@ -1,3 +1,8 @@ +/** + * @import {Plugin} from 'unified' + * @import {Node} from 'unist' + */ + import assert from 'node:assert/strict' import test from 'node:test' import {unified} from 'unified' @@ -61,7 +66,7 @@ test('`processSync`', async function (t) { // `this` in JS is buggy in TS. /** - * @type {import('unified').Plugin<[], string, import('unist').Node>} + * @type {Plugin<[], string, Node>} */ function parse() { this.parser = simpleParser @@ -69,7 +74,7 @@ function parse() { // `this` in JS is buggy in TS. /** - * @type {import('unified').Plugin<[], import('unist').Node, string>} + * @type {Plugin<[], Node, string>} */ function compile() { this.compiler = simpleCompiler diff --git a/test/stringify.js b/test/stringify.js index d4a022c1..efe6c54b 100644 --- a/test/stringify.js +++ b/test/stringify.js @@ -1,5 +1,5 @@ /** - * @typedef {import('unist').Node} Node + * @import {Node} from 'unist' */ import assert from 'node:assert/strict' diff --git a/test/util/simple.js b/test/util/simple.js index f0b60f2f..7aed9f2c 100644 --- a/test/util/simple.js +++ b/test/util/simple.js @@ -1,6 +1,5 @@ /** - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Literal} Literal + * @import {Literal, Node} from 'unist' */ // Make references to the above types visible in VS Code. From e41b0c8d0f010d5180a559ee6ffd1d224323e786 Mon Sep 17 00:00:00 2001 From: Titus Date: Thu, 8 Aug 2024 15:17:07 +0200 Subject: [PATCH 06/14] Update Node in Actions Signed-off-by: Titus --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4313899f..d097faf5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: - ubuntu-latest - windows-latest node: - - lts/gallium + - lts/hydrogen - node canary: name: canary / ${{matrix.package}} From 0ab31ad2a71cfc3cbec8de34751d7aa4049b2795 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 14:53:35 +0200 Subject: [PATCH 07/14] Add `.tsbuildinfo` to `.gitignore` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 67c4168d..83d55583 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules/ *.d.ts *.log *.map +*.tsbuildinfo yarn.lock !/index.d.ts !/test/types.d.ts From fadc430d4046fb8bd52a1167141ab00076a7cc62 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 14:53:57 +0200 Subject: [PATCH 08/14] Refactor `.editorconfig` --- .editorconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index c6c8b362..0f178672 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,9 @@ root = true [*] -indent_style = space -indent_size = 2 -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true +end_of_line = lf +indent_size = 2 +indent_style = space insert_final_newline = true +trim_trailing_whitespace = true From 59bb60a7d9815f1964aa190f9525f4f0e17db620 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 14:56:02 +0200 Subject: [PATCH 09/14] Remove license year --- license | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/license b/license index f3722d94..33ab5b08 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ (The MIT License) -Copyright (c) 2015 Titus Wormer +Copyright (c) Titus Wormer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From ea97b00a05879690eb8889bc4ee837aac0dadbdb Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 14:57:35 +0200 Subject: [PATCH 10/14] Refactor Actions --- .github/workflows/bb.yml | 12 +++++----- .github/workflows/main.yml | 48 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/bb.yml b/.github/workflows/bb.yml index 0198fc3f..3dbfce5b 100644 --- a/.github/workflows/bb.yml +++ b/.github/workflows/bb.yml @@ -1,9 +1,3 @@ -name: bb -on: - issues: - types: [opened, reopened, edited, closed, labeled, unlabeled] - pull_request_target: - types: [opened, reopened, edited, closed, labeled, unlabeled] jobs: main: runs-on: ubuntu-latest @@ -11,3 +5,9 @@ jobs: - uses: unifiedjs/beep-boop-beta@main with: repo-token: ${{secrets.GITHUB_TOKEN}} +name: bb +on: + issues: + types: [closed, edited, labeled, opened, reopened, unlabeled] + pull_request_target: + types: [closed, edited, labeled, opened, reopened, unlabeled] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d097faf5..0f1c2033 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,27 +1,4 @@ -name: main -on: - - pull_request - - push jobs: - main: - name: ${{matrix.node}} on ${{matrix.os}} - runs-on: ${{matrix.os}} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{matrix.node}} - - run: npm install - - run: npm test - - uses: codecov/codecov-action@v4 - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - node: - - lts/hydrogen - - node canary: name: canary / ${{matrix.package}} runs-on: ubuntu-latest @@ -34,8 +11,8 @@ jobs: - run: npm run build - uses: actions/checkout@v4 with: - repository: ${{matrix.package}} path: canary/${{matrix.package}} + repository: ${{matrix.package}} - run: npm install && npx rimraf "node_modules/**/unified" && npm test working-directory: canary/${{matrix.package}} strategy: @@ -46,3 +23,26 @@ jobs: - remarkjs/remark - retextjs/retext - unifiedjs/unified-engine + main: + name: ${{matrix.node}} on ${{matrix.os}} + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{matrix.node}} + - run: npm install + - run: npm test + - uses: codecov/codecov-action@v4 + strategy: + matrix: + node: + - lts/hydrogen + - node + os: + - ubuntu-latest + - windows-latest +name: main +on: + - pull_request + - push From aa4448291090209fbf27621bde08138975ca156f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 14:59:41 +0200 Subject: [PATCH 11/14] Refactor `logo.svg` --- logo.svg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/logo.svg b/logo.svg index b9f48ab1..1b09da21 100644 --- a/logo.svg +++ b/logo.svg @@ -1,4 +1,4 @@ - + - - - + + + From b61fd0255297bdc7f8c01123a428ba96c5e4530f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 15:02:38 +0200 Subject: [PATCH 12/14] Refactor `package.json` --- package.json | 96 ++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index 6ffd58d9..62b3f39f 100644 --- a/package.json +++ b/package.json @@ -1,48 +1,13 @@ { - "name": "unified", - "version": "11.0.5", - "description": "parse, inspect, transform, and serialize content through syntax trees", - "license": "MIT", - "keywords": [ - "ast", - "compile", - "content", - "cst", - "parse", - "process", - "rehype", - "remark", - "retext", - "serialize", - "stringify", - "syntax", - "transform", - "tree", - "unified" - ], - "homepage": "https://unifiedjs.com", - "repository": "unifiedjs/unified", - "bugs": "https://github.com/unifiedjs/unified/issues", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - }, "author": "Titus Wormer (https://wooorm.com)", + "bugs": "https://github.com/unifiedjs/unified/issues", "contributors": [ - "Titus Wormer (https://wooorm.com)", - "Junyoung Choi ", - "Hernan Rajchert ", "Christian Murphy ", - "Vse Mozhet Byt ", - "Richard Littauer " - ], - "sideEffects": false, - "type": "module", - "exports": "./index.js", - "files": [ - "lib/", - "index.d.ts", - "index.js" + "Hernan Rajchert ", + "Junyoung Choi ", + "Richard Littauer ", + "Titus Wormer (https://wooorm.com)", + "Vse Mozhet Byt " ], "dependencies": { "@types/unist": "^3.0.0", @@ -53,6 +18,7 @@ "trough": "^2.0.0", "vfile": "^6.0.0" }, + "description": "parse, inspect, transform, and serialize content through syntax trees", "devDependencies": { "@types/extend": "^3.0.0", "@types/hast": "^3.0.0", @@ -67,14 +33,36 @@ "typescript": "^5.0.0", "xo": "^0.59.0" }, - "scripts": { - "build": "tsc --build --clean && tsc --build && node script/fix-types.js && type-coverage && tsd", - "format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix", - "prepack": "npm run build && npm run format", - "test": "npm run build && npm run format && npm run test-coverage", - "test-api": "node --conditions development test/index.js", - "test-coverage": "c8 --100 --check-coverage --reporter lcov npm run test-api" + "exports": "./index.js", + "files": [ + "lib/", + "index.d.ts", + "index.js" + ], + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" }, + "homepage": "https://unifiedjs.com", + "keywords": [ + "ast", + "compile", + "content", + "cst", + "parse", + "process", + "rehype", + "remark", + "retext", + "serialize", + "stringify", + "syntax", + "transform", + "tree", + "unified" + ], + "license": "MIT", + "name": "unified", "prettier": { "bracketSpacing": false, "singleQuote": true, @@ -92,12 +80,24 @@ ] ] }, + "repository": "unifiedjs/unified", + "scripts": { + "build": "tsc --build --clean && tsc --build && node script/fix-types.js && type-coverage && tsd", + "format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix", + "prepack": "npm run build && npm run format", + "test": "npm run build && npm run format && npm run test-coverage", + "test-api": "node --conditions development test/index.js", + "test-coverage": "c8 --100 --check-coverage --reporter lcov npm run test-api" + }, + "sideEffects": false, "typeCoverage": { "atLeast": 100, "detail": true, "ignoreCatch": true, "strict": true }, + "type": "module", + "version": "11.0.5", "xo": { "overrides": [ { From 6838c70bd2b237663f522a0b46fccf7aef8491bc Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 3 Oct 2024 15:04:34 +0200 Subject: [PATCH 13/14] Add square logo --- logo-square.svg | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 logo-square.svg diff --git a/logo-square.svg b/logo-square.svg new file mode 100644 index 00000000..fea879c6 --- /dev/null +++ b/logo-square.svg @@ -0,0 +1,13 @@ + + + + + + From 45d8fa503157d20a656b3fa00e4b010dc0e50748 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 4 Feb 2025 15:22:55 +0100 Subject: [PATCH 14/14] Remove references to twitter --- readme.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/readme.md b/readme.md index d6a75abb..02b718f5 100644 --- a/readme.md +++ b/readme.md @@ -68,7 +68,6 @@ language). These ecosystems can be connected together. * for more about us, see [`unifiedjs.com`][site] -* for updates, see [@unifiedjs][twitter] on Twitter * for questions, see [support][] * to help, see [contribute][] and [sponsor][] below @@ -1713,8 +1712,6 @@ work on [`ware`][ware], as it was a huge initial inspiration. [site]: https://unifiedjs.com -[twitter]: https://twitter.com/unifiedjs - [rehype]: https://github.com/rehypejs/rehype [remark]: https://github.com/remarkjs/remark