question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSDoc trailing whitespaces are deleted

See original GitHub issue

Two trailing whitespace in a JSDoc are used to indicate a line break. Prettier keeps deleting them for me. Is there a way to configure it to ignore trailing whitespaces in JSDoc, like in the tslint ("no-trailing-whitespace": [true, "ignore-jsdoc"])?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:15
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
niklasmhcommented, Oct 20, 2020

I stumbled accross the same issue, and having the option to ignore trailing whitespace (or all rules for that matter) in comments would solve the problem. Also, I cannot see why this should not be an option as comments for documentation often use Markdown (I could be wrong, though, but e.g. VSCode uses Markdown comments to generate the Monaco documentation). It may not be a big issue, but I think when it is possible that todays comments may require the correct formatting, opting out of forced formatted comments would be beneficial.

More information about the problem

According to the Markdown specs from Commonmark, Markdown supports two or more spaces to create a newline (or <br />-tag, try it out here). This means that this is a core feature in Markdown. With that out of the way, here is an example:

Small example (JSDoc comment, note the two spaces after Line1): image

Is parsed into this after running Prettier: image

And results in being rendered like this in Markdown: image

With no Prettier (aka with trailing spaces), it looks like this (which is the desired rendering): image

I have also tried singleline and multiline prettier-ignore comments, and they work, except they are included in the rendered version: image

After some tries I found that it was possible for me to use <br /> for newlines which solved my issue, but I still wonder if this could be added as an option to Prettier. I would really prefer to use two trailing spaces instead of HTML-tags.

Also, if someone would help guide me into the right direction, I am more than willing to help solve this issue 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Re: [sonar-dev] [SONARJS] Avoid trailing whitespaces
I have got an issue at the 3 line: Remove the useless trailing whitespaces at the end of this line. Standard JavaScript formatter...
Read more >
no-trailing-spaces - ESLint - Pluggable JavaScript Linter
This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines. Examples of incorrect code for this...
Read more >
Trailing whitespace gets deleted by Webstorm. How to stop it?
I want to make a PR for phaser.io however when i want to commit the file there seems to be changes in all...
Read more >
ServerTools (WTP) » Can the Formatter ... - Eclipse Community Forums
When I use the Save Action's "Remove trailing whitespace" ability, it still leaves a single space on every blank line of a block...
Read more >
Udacity Frontend Nanodegree Style Guide
General Formatting Rules. Trailing Whitespace. Remove trailing white spaces. Trailing white spaces are unnecessary and can complicate diffs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found