JSDoc trailing whitespaces are deleted
See original GitHub issueTwo 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:
- Created 4 years ago
- Reactions:15
- Comments:15 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have run into this issue with TypeScript, which can show these comments when hovering on objects, functions, properties, etc. I would like an option to leave trailing whitespace alone.
Repro: https://www.typescriptlang.org/play?#code/PTAEAkHsDcFMCdQwaAsgTwGIFcB2BjAFwEtJdQBDXAE1HUm1HytAGdZZRCALCwr7p2qxW+eMQAOJMqF6tQAG2K5OAI3iwKAa1YAoXcABUh3aEOgAKt2LyblUADNsRUuR58AXKFCnz3gIIAdKAahNjwuPI8nLjYALaqKA7EcN6+3qAAQsEAcrBwiKHhkZS46DzKAOagsArsaWbAuvhkrPwYOATS5AC8oAAUAJSgPQB8oACsANz6IGhYeC5kAEyg1JAioLiQ-LypSiqg6po6s8bpVnZ2FI7O3QKe6QHBRRFRglvxiYjJcE9ZuXyKFeJSo5WsuGqtXYviaLUi7QWXVcqz6QxG42muiAA
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):
Is parsed into this after running Prettier:
And results in being rendered like this in Markdown:
With no Prettier (aka with trailing spaces), it looks like this (which is the desired rendering):
I have also tried singleline and multiline prettier-ignore comments, and they work, except they are included in the rendered version:
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 😃