Skip to content

Escape pipes in symbols in the markdown reporter - #2254

Merged
webpro merged 1 commit into
webpro-nl:mainfrom
NgoQuocViet2001:fix-markdown-reporter-pipes
Oct 29, 2026
Merged

webpro merged 1 commit into
webpro-nl:mainfrom
NgoQuocViet2001:fix-markdown-reporter-pipes

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

Duplicate exports are reported with a symbol like exportedResult|default, and the markdown reporter writes it into the table as is. In GFM an unescaped pipe is a column separator, so the row gets four cells under a three-column header: default ends up under Location, the file path under Severity, and the severity is dropped. Similar to the broken table in #1700.

| exportedResult|default | my-module.ts | error    |
| exportedResult\|default | my-module.ts | error    |

This escapes | in the symbol (before/after above) and uses the escaped value for the Name column width. The new test runs --reporter markdown --include duplicates on the existing exports/basic fixture.

  • Ran: node --test test/cli/cli-reporter*.test.ts, 49 pass; the new test fails without the change
  • Ran: bun test test/cli/cli-reporter-markdown.test.ts, pass
  • Ran: oxlint and oxfmt --check on the changed files, clean
  • Checked: with remark-gfm the row now parses as 3 cells instead of 4

@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@2254
npm i https://pkg.pr.new/@knip/language-server@2254
npm i https://pkg.pr.new/@knip/mcp@2254

commit: 6c01fc9

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request! The premise checks out: a duplicate export puts a pipe in the symbol, GFM reads it as a column separator and the severity cell falls off the row. Escaping it as \| renders the symbol back literally, and the output of every other fixture stays byte-identical, so this is the right size of fix.

@webpro
webpro merged commit 153ba1e into webpro-nl:main Oct 29, 2026
32 checks passed
@webpro

webpro commented Oct 29, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.44.0. See Release 6.44.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants