Add support for empty lines inside jsdoc comment blocks #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adjusts normalisation logic so that empty lines in the middle of a comment aren't considered when calculating the indent.
Previously, the regex for
SPACE_UNTIL_CONTENT
would fail to include the '*' on an empty block comment line, as the * would meet the condition for the look-ahead(?=\S)
. This would give an inaccurate measure of the smallest indent.For example, in this example:
The matches on SPACE_UNTIL_CONTENT would be:
[" * "]
[" "]
[" * "]
The shortest indent value would be length 1, and the '*'s on each line wouldn't be stripped out, leading to the output:
My current solution in this PR is to ignore empty lines when calculating the indent. Keen for feedback if there's a good way to adjust the SPACE_UNTIL_CONTENT regex to handle empty lines.
This was caught while debugging an issue in extract-react-types, where empty lines in JSDoc comments was breaking comment formatting.