From 4748a1936f9bead75e9249a34434152fd8b5db8b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:24:01 +0100 Subject: [PATCH 01/13] Update dev-dependencies --- package.json | 15 +++--- readme.md | 142 +++++++++++++++++++++++++------------------------- test/index.js | 6 +-- 3 files changed, 83 insertions(+), 80 deletions(-) diff --git a/package.json b/package.json index f167cdf..87fd903 100644 --- a/package.json +++ b/package.json @@ -45,18 +45,18 @@ "unified": "^11.0.0" }, "devDependencies": { - "@types/node": "^20.0.0", - "c8": "^8.0.0", + "@types/node": "^22.0.0", + "c8": "^10.0.0", "is-hidden": "^2.0.0", "prettier": "^3.0.0", "remark": "^15.0.0", - "remark-cli": "^11.0.0", - "remark-preset-wooorm": "^9.0.0", + "remark-cli": "^12.0.0", + "remark-preset-wooorm": "^10.0.0", "string-width": "^6.0.0", "to-vfile": "^8.0.0", "type-coverage": "^2.0.0", "typescript": "^5.0.0", - "xo": "^0.56.0" + "xo": "^0.60.0" }, "scripts": { "build": "tsc --build --clean && tsc --build && type-coverage", @@ -96,6 +96,9 @@ } } ], - "prettier": true + "prettier": true, + "rules": { + "logical-assignment-operators": "off" + } } } diff --git a/readme.md b/readme.md index aed6f26..e45de61 100644 --- a/readme.md +++ b/readme.md @@ -13,28 +13,28 @@ strikethrough, tables, tasklists). ## Contents -* [What is this?](#what-is-this) -* [When should I use this?](#when-should-i-use-this) -* [Install](#install) -* [Use](#use) -* [API](#api) - * [`unified().use(remarkGfm[, options])`](#unifieduseremarkgfm-options) - * [`Options`](#options) -* [Examples](#examples) - * [Example: `singleTilde`](#example-singletilde) - * [Example: `stringLength`](#example-stringlength) -* [Bugs](#bugs) -* [Authoring](#authoring) -* [HTML](#html) -* [CSS](#css) -* [Syntax](#syntax) -* [Syntax tree](#syntax-tree) -* [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) + * [`unified().use(remarkGfm[, options])`](#unifieduseremarkgfm-options) + * [`Options`](#options) +* [Examples](#examples) + * [Example: `singleTilde`](#example-singletilde) + * [Example: `stringLength`](#example-stringlength) +* [Bugs](#bugs) +* [Authoring](#authoring) +* [HTML](#html) +* [CSS](#css) +* [Syntax](#syntax) +* [Syntax tree](#syntax-tree) +* [Types](#types) +* [Compatibility](#compatibility) +* [Security](#security) +* [Related](#related) +* [Contribute](#contribute) +* [License](#license) ## What is this? @@ -206,8 +206,8 @@ tasklists). ###### Parameters -* `options` ([`Options`][api-options], optional) - — configuration +* `options` ([`Options`][api-options], optional) + — configuration ###### Returns @@ -219,16 +219,16 @@ Configuration (TypeScript type). ###### Fields -* `stringLength` (`((value: string) => number)`, default: `d => d.length`) - — detect the size of table cells, used when aligning cells -* `singleTilde` (`boolean`, default: `true`) - — whether to support strikethrough with a single tilde; - single tildes work on github.com, but are technically prohibited by GFM; - you can always use 2 or more tildes for strikethrough -* `tablePipeAlign` (`boolean`, default: `true`) - — whether to align table pipes -* `tableCellPadding` (`boolean`, default: `true`) - — whether to add a space of padding between table pipes and cells +* `stringLength` (`((value: string) => number)`, default: `d => d.length`) + — detect the size of table cells, used when aligning cells +* `singleTilde` (`boolean`, default: `true`) + — whether to support strikethrough with a single tilde; + single tildes work on github.com, but are technically prohibited by GFM; + you can always use 2 or more tildes for strikethrough +* `tablePipeAlign` (`boolean`, default: `true`) + — whether to align table pipes +* `tableCellPadding` (`boolean`, default: `true`) + — whether to add a space of padding between table pipes and cells ## Examples @@ -321,21 +321,21 @@ The output of our code with these changes is as follows: For bugs present in GFM but not here, or other peculiarities that are supported, see each corresponding readme: -* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#bugs) -* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#bugs) -* strikethrough: n/a -* [table](https://github.com/micromark/micromark-extension-gfm-table#bugs) -* tasklists: n/a +* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#bugs) +* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#bugs) +* strikethrough: n/a +* [table](https://github.com/micromark/micromark-extension-gfm-table#bugs) +* tasklists: n/a ## Authoring For recommendations on how to author GFM, see each corresponding readme: -* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#authoring) -* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#authoring) -* [strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough#authoring) -* [table](https://github.com/micromark/micromark-extension-gfm-table#authoring) -* [tasklists](https://github.com/micromark/micromark-extension-gfm-task-list-item#authoring) +* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#authoring) +* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#authoring) +* [strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough#authoring) +* [table](https://github.com/micromark/micromark-extension-gfm-table#authoring) +* [tasklists](https://github.com/micromark/micromark-extension-gfm-task-list-item#authoring) ## HTML @@ -346,31 +346,31 @@ See [`remark-rehype`][remark-rehype] for how that happens and how to change it. For info on how GitHub styles these features, see each corresponding readme: -* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#css) -* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#css) -* [strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough#css) -* [table](https://github.com/micromark/micromark-extension-gfm-table#css) -* [tasklists](https://github.com/micromark/micromark-extension-gfm-task-list-item#css) +* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#css) +* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#css) +* [strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough#css) +* [table](https://github.com/micromark/micromark-extension-gfm-table#css) +* [tasklists](https://github.com/micromark/micromark-extension-gfm-task-list-item#css) ## Syntax For info on the syntax of these features, see each corresponding readme: -* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#syntax) -* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#syntax) -* [strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough#syntax) -* [table](https://github.com/micromark/micromark-extension-gfm-table#syntax) -* [tasklists](https://github.com/micromark/micromark-extension-gfm-task-list-item#syntax) +* [autolink literal](https://github.com/micromark/micromark-extension-gfm-autolink-literal#syntax) +* [footnote](https://github.com/micromark/micromark-extension-gfm-footnote#syntax) +* [strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough#syntax) +* [table](https://github.com/micromark/micromark-extension-gfm-table#syntax) +* [tasklists](https://github.com/micromark/micromark-extension-gfm-task-list-item#syntax) ## Syntax tree For info on the syntax tree of these features, see each corresponding readme: -* [autolink literal](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal#syntax-tree) -* [footnote](https://github.com/syntax-tree/mdast-util-gfm-footnote#syntax-tree) -* [strikethrough](https://github.com/syntax-tree/mdast-util-gfm-strikethrough#syntax-tree) -* [table](https://github.com/syntax-tree/mdast-util-gfm-table#syntax-tree) -* [tasklists](https://github.com/syntax-tree/mdast-util-gfm-task-list-item#syntax-tree) +* [autolink literal](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal#syntax-tree) +* [footnote](https://github.com/syntax-tree/mdast-util-gfm-footnote#syntax-tree) +* [strikethrough](https://github.com/syntax-tree/mdast-util-gfm-strikethrough#syntax-tree) +* [table](https://github.com/syntax-tree/mdast-util-gfm-table#syntax-tree) +* [tasklists](https://github.com/syntax-tree/mdast-util-gfm-task-list-item#syntax-tree) ## Types @@ -404,18 +404,18 @@ attacks. ## Related -* [`remark-github`][remark-github] - — link references to commits, issues, PRs, and users -* [`remark-breaks`][remark-breaks] - — support breaks without needing spaces or escapes (enters to `
`) -* [`remark-frontmatter`][remark-frontmatter] - — support frontmatter (YAML, TOML, and more) -* [`remark-directive`](https://github.com/remarkjs/remark-directive) - — support directives -* [`remark-math`](https://github.com/remarkjs/remark-math) - — support math -* [`remark-mdx`](https://github.com/mdx-js/mdx/tree/main/packages/remark-mdx) - — support MDX (ESM, JSX, expressions) +* [`remark-github`][remark-github] + — link references to commits, issues, PRs, and users +* [`remark-breaks`][remark-breaks] + — support breaks without needing spaces or escapes (enters to `
`) +* [`remark-frontmatter`][remark-frontmatter] + — support frontmatter (YAML, TOML, and more) +* [`remark-directive`](https://github.com/remarkjs/remark-directive) + — support directives +* [`remark-math`](https://github.com/remarkjs/remark-math) + — support math +* [`remark-mdx`](https://github.com/mdx-js/mdx/tree/main/packages/remark-mdx) + — support MDX (ESM, JSX, expressions) ## Contribute diff --git a/test/index.js b/test/index.js index e0f3581..41d0ef1 100644 --- a/test/index.js +++ b/test/index.js @@ -61,8 +61,8 @@ test('fixtures', async function (t) { config = {stringLength: stringWidth} } - const proc = remark().use(remarkGfm, config) - const actual = proc.parse(input) + const processor = remark().use(remarkGfm, config) + const actual = processor.parse(input) try { output = String(await fs.readFile(outputUrl)) @@ -85,7 +85,7 @@ test('fixtures', async function (t) { assert.deepEqual(actual, expected) - assert.equal(String(await proc.process(input)), String(output)) + assert.equal(String(await processor.process(input)), String(output)) }) } }) From b250e1513533499426b0409f08816567573f9395 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:24:21 +0100 Subject: [PATCH 02/13] Add `.tsbuildinfo` to `.gitignore` --- .gitignore | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 53a29e3..b976b9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -coverage/ -node_modules/ -.DS_Store *.d.ts *.log +*.tsbuildinfo +.DS_Store +coverage/ +node_modules/ yarn.lock From 798ebbca76890e90378e20372cc5e310ecc070cc Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:24:46 +0100 Subject: [PATCH 03/13] Update Actions --- .github/workflows/bb.yml | 12 ++++++------ .github/workflows/main.yml | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/bb.yml b/.github/workflows/bb.yml index 0198fc3..3dbfce5 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 fb63387..ade3921 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,21 +1,21 @@ -name: main -on: - - pull_request - - push jobs: main: 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@v5 strategy: matrix: node: - - lts/gallium + - lts/hydrogen - node +name: main +on: + - pull_request + - push From 4e1d55f3202a9bda07e02e271860719c813bd4f5 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:25:09 +0100 Subject: [PATCH 04/13] Refactor `.editorconfig` --- .editorconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index c6c8b36..b368786 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 insert_final_newline = true +indent_size = 2 +indent_style = space +trim_trailing_whitespace = true From a5e8993994a569ab8508daddbc5b982399804392 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:25:26 +0100 Subject: [PATCH 05/13] Remove license year --- license | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/license b/license index 3937235..bc8f165 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ (The MIT License) -Copyright (c) 2020 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 From da382350ccbf4902572ea46dd6a6ebd839e50433 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:29:03 +0100 Subject: [PATCH 06/13] Refactor `package.json` --- .prettierignore | 3 +- package.json | 82 +++++++++---------- .../strikethrough-not-one/config.json | 2 +- test/fixtures/table-no-align/config.json | 2 +- test/fixtures/table-no-align/tree.json | 7 +- test/fixtures/table-no-padding/config.json | 2 +- test/fixtures/table-no-padding/tree.json | 7 +- test/fixtures/table-string-length/config.json | 2 +- test/fixtures/table-string-length/tree.json | 6 +- test/fixtures/table/tree.json | 7 +- 10 files changed, 49 insertions(+), 71 deletions(-) diff --git a/.prettierignore b/.prettierignore index e7939c4..8d01c59 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,2 @@ -coverage/ -*.json *.md +coverage/ diff --git a/package.json b/package.json index 87fd903..596e81a 100644 --- a/package.json +++ b/package.json @@ -1,41 +1,9 @@ { - "name": "remark-gfm", - "version": "4.0.0", - "description": "remark plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists)", - "license": "MIT", - "keywords": [ - "autolink", - "footnote", - "gfm", - "github", - "markdown", - "mdast", - "plugin", - "remark", - "remark-plugin", - "strikethrough", - "table", - "tasklist", - "unified" - ], - "repository": "remarkjs/remark-gfm", - "bugs": "https://github.com/remarkjs/remark-gfm/issues", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - }, "author": "Titus Wormer (https://wooorm.com)", + "bugs": "https://github.com/remarkjs/remark-gfm/issues", "contributors": [ "Titus Wormer (https://wooorm.com)" ], - "sideEffects": false, - "type": "module", - "exports": "./index.js", - "files": [ - "lib/", - "index.d.ts", - "index.js" - ], "dependencies": { "@types/mdast": "^4.0.0", "mdast-util-gfm": "^3.0.0", @@ -44,6 +12,7 @@ "remark-stringify": "^11.0.0", "unified": "^11.0.0" }, + "description": "remark plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists)", "devDependencies": { "@types/node": "^22.0.0", "c8": "^10.0.0", @@ -58,14 +27,33 @@ "typescript": "^5.0.0", "xo": "^0.60.0" }, - "scripts": { - "build": "tsc --build --clean && tsc --build && type-coverage", - "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 --reporter lcov npm run test-api" + "exports": "./index.js", + "files": [ + "index.d.ts", + "index.js", + "lib/" + ], + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" }, + "keywords": [ + "autolink", + "footnote", + "gfm", + "github", + "markdown", + "mdast", + "plugin", + "remark", + "remark-plugin", + "strikethrough", + "table", + "tasklist", + "unified" + ], + "license": "MIT", + "name": "remark-gfm", "prettier": { "bracketSpacing": false, "singleQuote": true, @@ -79,12 +67,22 @@ "remark-preset-wooorm" ] }, + "repository": "remarkjs/remark-gfm", + "scripts": { + "build": "tsc --build --clean && tsc --build && type-coverage", + "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 --reporter lcov npm run test-api" + }, + "sideEffects": false, "typeCoverage": { "atLeast": 100, - "detail": true, - "ignoreCatch": true, "strict": true }, + "type": "module", + "version": "4.0.0", "xo": { "overrides": [ { diff --git a/test/fixtures/strikethrough-not-one/config.json b/test/fixtures/strikethrough-not-one/config.json index f9ccf43..9ebe776 100644 --- a/test/fixtures/strikethrough-not-one/config.json +++ b/test/fixtures/strikethrough-not-one/config.json @@ -1,3 +1,3 @@ { "singleTilde": false -} \ No newline at end of file +} diff --git a/test/fixtures/table-no-align/config.json b/test/fixtures/table-no-align/config.json index 79510c8..eeaeb82 100644 --- a/test/fixtures/table-no-align/config.json +++ b/test/fixtures/table-no-align/config.json @@ -1,3 +1,3 @@ { "tablePipeAlign": false -} \ No newline at end of file +} diff --git a/test/fixtures/table-no-align/tree.json b/test/fixtures/table-no-align/tree.json index 7ccf685..eebf698 100644 --- a/test/fixtures/table-no-align/tree.json +++ b/test/fixtures/table-no-align/tree.json @@ -3,12 +3,7 @@ "children": [ { "type": "table", - "align": [ - null, - "left", - "right", - "center" - ], + "align": [null, "left", "right", "center"], "children": [ { "type": "tableRow", diff --git a/test/fixtures/table-no-padding/config.json b/test/fixtures/table-no-padding/config.json index 589c52b..08e3189 100644 --- a/test/fixtures/table-no-padding/config.json +++ b/test/fixtures/table-no-padding/config.json @@ -1,3 +1,3 @@ { "tableCellPadding": false -} \ No newline at end of file +} diff --git a/test/fixtures/table-no-padding/tree.json b/test/fixtures/table-no-padding/tree.json index 7ccf685..eebf698 100644 --- a/test/fixtures/table-no-padding/tree.json +++ b/test/fixtures/table-no-padding/tree.json @@ -3,12 +3,7 @@ "children": [ { "type": "table", - "align": [ - null, - "left", - "right", - "center" - ], + "align": [null, "left", "right", "center"], "children": [ { "type": "tableRow", diff --git a/test/fixtures/table-string-length/config.json b/test/fixtures/table-string-length/config.json index 31778c8..49fffba 100644 --- a/test/fixtures/table-string-length/config.json +++ b/test/fixtures/table-string-length/config.json @@ -1,3 +1,3 @@ { "stringLength": "this is overwritten in `test/index.js`" -} \ No newline at end of file +} diff --git a/test/fixtures/table-string-length/tree.json b/test/fixtures/table-string-length/tree.json index 554d233..c00e2a5 100644 --- a/test/fixtures/table-string-length/tree.json +++ b/test/fixtures/table-string-length/tree.json @@ -3,11 +3,7 @@ "children": [ { "type": "table", - "align": [ - null, - null, - null - ], + "align": [null, null, null], "children": [ { "type": "tableRow", diff --git a/test/fixtures/table/tree.json b/test/fixtures/table/tree.json index 4c9482c..088dc63 100644 --- a/test/fixtures/table/tree.json +++ b/test/fixtures/table/tree.json @@ -3,12 +3,7 @@ "children": [ { "type": "table", - "align": [ - null, - "left", - "right", - "center" - ], + "align": [null, "left", "right", "center"], "children": [ { "type": "tableRow", From 76559f9e0509a53589879622baeb0d31ea1f5369 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:31:24 +0100 Subject: [PATCH 07/13] Refactor to use `@import`s --- lib/index.js | 15 +++++++-------- test/index.js | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2ab204a..2205580 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,10 @@ -/// -/// - /** - * @typedef {import('mdast').Root} Root - * @typedef {import('mdast-util-gfm').Options} MdastOptions - * @typedef {import('micromark-extension-gfm').Options} MicromarkOptions - * @typedef {import('unified').Processor} Processor + * @import {Options as MdastOptions} from 'mdast-util-gfm' + * @import {Root} from 'mdast' + * @import {Options as MicromarkOptions} from 'micromark-extension-gfm' + * @import {} from 'remark-parse' + * @import {} from 'remark-stringify' + * @import {Processor} from 'unified' */ /** @@ -31,7 +30,7 @@ const emptyOptions = {} export default function remarkGfm(options) { // @ts-expect-error: TS is wrong about `this`. // eslint-disable-next-line unicorn/no-this-assignment - const self = /** @type {Processor} */ (this) + const self = /** @type {Processor} */ (this) const settings = options || emptyOptions const data = self.data() diff --git a/test/index.js b/test/index.js index 41d0ef1..5accbf6 100644 --- a/test/index.js +++ b/test/index.js @@ -1,6 +1,6 @@ /** - * @typedef {import('mdast').Root} Root - * @typedef {import('remark-gfm').Options} Options + * @import {Root} from 'mdast' + * @import {Options} from 'remark-gfm' */ import assert from 'node:assert/strict' From 3a57a5bc3cb6a7f9c1f8ac17257f598c20d60397 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:31:51 +0100 Subject: [PATCH 08/13] Add declaration maps --- .gitignore | 1 + package.json | 1 + tsconfig.json | 1 + 3 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b976b9c..388388c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.d.ts *.log +*.map *.tsbuildinfo .DS_Store coverage/ diff --git a/package.json b/package.json index 596e81a..306d906 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ }, "exports": "./index.js", "files": [ + "index.d.ts.map", "index.d.ts", "index.js", "lib/" diff --git a/tsconfig.json b/tsconfig.json index 82cc749..fc3d1e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "checkJs": true, "customConditions": ["development"], + "declarationMap": true, "declaration": true, "emitDeclarationOnly": true, "exactOptionalPropertyTypes": true, From 4af823a56b4aab629a2558b347030c9648c0968e Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jan 2025 10:36:12 +0100 Subject: [PATCH 09/13] Refactor to use `interface` for exposed types --- .gitignore | 1 + index.d.ts | 13 +++++++++++++ index.js | 5 +---- lib/index.js | 8 +------- package.json | 24 +++++++++++++++++++++++- tsconfig.json | 2 +- 6 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 index.d.ts diff --git a/.gitignore b/.gitignore index 388388c..8123c9e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ coverage/ node_modules/ yarn.lock +!/index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..0f75a31 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,13 @@ +import type {Options as MicromarkOptions} from 'micromark-extension-gfm' +import type {Options as MdastOptions} from 'mdast-util-gfm' + +export {default} from './lib/index.js' + +/** + * Configuration for `remark-gfm`. + * + * Currently supports `singleTilde` as a parse option and + * `tableCellPadding`, `tablePipeAlign`, and `stringLength` as + * a serialization option. + */ +export interface Options extends MicromarkOptions, MdastOptions {} diff --git a/index.js b/index.js index a49a278..6a4c25d 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,2 @@ -/** - * @typedef {import('./lib/index.js').Options} Options - */ - +// Note: types exposed from `index.d.ts`. export {default} from './lib/index.js' diff --git a/lib/index.js b/lib/index.js index 2205580..ee1cca2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,17 +1,11 @@ /** - * @import {Options as MdastOptions} from 'mdast-util-gfm' * @import {Root} from 'mdast' - * @import {Options as MicromarkOptions} from 'micromark-extension-gfm' + * @import {Options} from 'remark-gfm' * @import {} from 'remark-parse' * @import {} from 'remark-stringify' * @import {Processor} from 'unified' */ -/** - * @typedef {MicromarkOptions & MdastOptions} Options - * Configuration. - */ - import {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm' import {gfm} from 'micromark-extension-gfm' diff --git a/package.json b/package.json index 306d906..17831d7 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "exports": "./index.js", "files": [ - "index.d.ts.map", "index.d.ts", "index.js", "lib/" @@ -86,6 +85,29 @@ "version": "4.0.0", "xo": { "overrides": [ + { + "files": [ + "**/*.d.ts" + ], + "rules": { + "@typescript-eslint/array-type": [ + "error", + { + "default": "generic" + } + ], + "@typescript-eslint/ban-types": [ + "error", + { + "extendDefaults": true + } + ], + "@typescript-eslint/consistent-type-definitions": [ + "error", + "interface" + ] + } + }, { "files": [ "test/**/*.js" diff --git a/tsconfig.json b/tsconfig.json index fc3d1e4..c3e0c82 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,5 @@ "target": "es2022" }, "exclude": ["coverage/", "node_modules/"], - "include": ["**/*.js"] + "include": ["**/*.js", "index.d.ts"] } From 21cae6ac8b33d98ad8a944023443a1f99f6727f0 Mon Sep 17 00:00:00 2001 From: Leandro Facchinetti Date: Thu, 6 Feb 2025 09:24:26 +0000 Subject: [PATCH 10/13] Fix typo Closes GH-73. Reviewed-by: Titus Wormer --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e45de61..e292379 100644 --- a/readme.md +++ b/readme.md @@ -398,7 +398,7 @@ this functionality, which defaulted to true. ## Security -Use of `remark-frontmatter` does not involve **[rehype][]** ([hast][]) or user +Use of `remark-gfm` does not involve **[rehype][]** ([hast][]) or user content so there are no openings for [cross-site scripting (XSS)][wiki-xss] attacks. From 030dd8d53490ffef21ead3420d3e75028aff511f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 10 Feb 2025 13:38:04 +0100 Subject: [PATCH 11/13] Update dev-dependencies --- package.json | 2 +- readme.md | 60 ++++++++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 17831d7..2b1a764 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "prettier": "^3.0.0", "remark": "^15.0.0", "remark-cli": "^12.0.0", - "remark-preset-wooorm": "^10.0.0", + "remark-preset-wooorm": "^11.0.0", "string-width": "^6.0.0", "to-vfile": "^8.0.0", "type-coverage": "^2.0.0", diff --git a/readme.md b/readme.md index e292379..5c2bd0c 100644 --- a/readme.md +++ b/readme.md @@ -433,54 +433,48 @@ abide by its terms. -[build-badge]: https://github.com/remarkjs/remark-gfm/workflows/main/badge.svg - -[build]: https://github.com/remarkjs/remark-gfm/actions +[api-options]: #options -[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-gfm.svg +[api-remark-gfm]: #unifieduseremarkgfm-options -[coverage]: https://codecov.io/github/remarkjs/remark-gfm +[author]: https://wooorm.com -[downloads-badge]: https://img.shields.io/npm/dm/remark-gfm.svg +[backers-badge]: https://opencollective.com/unified/backers/badge.svg -[downloads]: https://www.npmjs.com/package/remark-gfm +[build]: https://github.com/remarkjs/remark-gfm/actions -[size-badge]: https://img.shields.io/bundlejs/size/remark-gfm +[build-badge]: https://github.com/remarkjs/remark-gfm/workflows/main/badge.svg -[size]: https://bundlejs.com/?q=remark-gfm +[chat]: https://github.com/remarkjs/remark/discussions -[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg +[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg -[backers-badge]: https://opencollective.com/unified/backers/badge.svg +[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md [collective]: https://opencollective.com/unified -[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg +[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md -[chat]: https://github.com/remarkjs/remark/discussions +[coverage]: https://codecov.io/github/remarkjs/remark-gfm -[npm]: https://docs.npmjs.com/cli/install +[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-gfm.svg + +[downloads]: https://www.npmjs.com/package/remark-gfm + +[downloads-badge]: https://img.shields.io/npm/dm/remark-gfm.svg [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c [esmsh]: https://esm.sh -[health]: https://github.com/remarkjs/.github - -[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md +[gfm]: https://github.github.com/gfm/ -[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md +[hast]: https://github.com/syntax-tree/hast -[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md +[health]: https://github.com/remarkjs/.github [license]: license -[author]: https://wooorm.com - -[gfm]: https://github.github.com/gfm/ - -[hast]: https://github.com/syntax-tree/hast - [mdast-util-from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown [mdast-util-gfm]: https://github.com/syntax-tree/mdast-util-gfm @@ -489,8 +483,12 @@ abide by its terms. [micromark-extension-gfm]: https://github.com/micromark/micromark-extension-gfm +[npm]: https://docs.npmjs.com/cli/install + [rehype]: https://github.com/rehypejs/rehype +[rehype-slug]: https://github.com/rehypejs/rehype-slug + [remark]: https://github.com/remarkjs/remark [remark-breaks]: https://github.com/remarkjs/remark-breaks @@ -501,16 +499,18 @@ abide by its terms. [remark-rehype]: https://github.com/remarkjs/remark-rehype -[rehype-slug]: https://github.com/rehypejs/rehype-slug +[size]: https://bundlejs.com/?q=remark-gfm + +[size-badge]: https://img.shields.io/bundlejs/size/remark-gfm + +[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg [string-width]: https://github.com/sindresorhus/string-width +[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md + [typescript]: https://www.typescriptlang.org [unified]: https://github.com/unifiedjs/unified [wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting - -[api-options]: #options - -[api-remark-gfm]: #unifieduseremarkgfm-options From 173394d37359ac3b193a39832fdf0babadd39d40 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 10 Feb 2025 13:40:43 +0100 Subject: [PATCH 12/13] Add docs on footnote option --- index.d.ts | 4 ++-- readme.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 0f75a31..094e9ae 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,7 +7,7 @@ export {default} from './lib/index.js' * Configuration for `remark-gfm`. * * Currently supports `singleTilde` as a parse option and - * `tableCellPadding`, `tablePipeAlign`, and `stringLength` as - * a serialization option. + * `firstLineBlank`, `stringLength`, `tableCellPadding`, and `tablePipeAlign` + * as serialization options. */ export interface Options extends MicromarkOptions, MdastOptions {} diff --git a/readme.md b/readme.md index 5c2bd0c..98ca7de 100644 --- a/readme.md +++ b/readme.md @@ -219,6 +219,8 @@ Configuration (TypeScript type). ###### Fields +* `firstLineBlank` (`boolean`, default: `false`) + — serialize with a blank line for the first line of footnote definitions * `stringLength` (`((value: string) => number)`, default: `d => d.length`) — detect the size of table cells, used when aligning cells * `singleTilde` (`boolean`, default: `true`) From 109972e8a773bf5dac1d6d2da0776557f36971aa Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 10 Feb 2025 13:43:04 +0100 Subject: [PATCH 13/13] 4.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b1a764..bb536e5 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "strict": true }, "type": "module", - "version": "4.0.0", + "version": "4.0.1", "xo": { "overrides": [ {