dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
fix: preserve jsdoc markdown hard breaks
Refs denoland/deno#31831.
JSDoc is commonly rendered as Markdown, but the TypeScript formatter currently trims two trailing spaces from non-final JSDoc lines. That removes Markdown hard line breaks. The Markdown plugin normalizes the same input to a backslash hard break, so this applies the same normalization to JSDoc lines while keeping non-JSDoc block comments on the existing trimming behavior.
The regression coverage also guards the main edge cases from the narrower behavior:
- converts a JSDoc Markdown hard break when another content line follows
- does not convert a hard break on the last meaningful JSDoc content line
- does not convert trailing spaces inside a fenced JSDoc code block
- does not convert hard breaks in non-JSDoc block comments
Tests:
cargo test --test specs issue031831cargo test --test specs JSDocComments_Allcargo test --test specs CommentBlocks_Allcargo test