Skip to content

Commit

Permalink
fix(prettier-plugin-jsdoc): add an extra case when joining props
Browse files Browse the repository at this point in the history
There was a bug on the function that joined description that were splitted between 'name' and
'description' because the process that formats the block description was already joining any
existing 'description' tag. This commits adds an `elseif` on the evaluation to cover that case.
  • Loading branch information
homer0 committed Oct 26, 2020
1 parent 8b71413 commit 9489967
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/fns/formatTagsDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ const joinProperties = R.curry((propA, propB, prop, tag) => {
* @param {CommentTag} tag The tag to fix.
* @returns {CommentTag}
*/
const addLinkToDescription = (tag) => {
const prop = TAGS_WITH_NAME_AS_DESCRIPTION.includes(tag.tag) ? 'description' : 'name';
return {
...tag,
type: '',
[prop]: `{${tag.type}} ${tag[prop]}`.trimRight(),
};
};
const addLinkToDescription = (tag) => ({
...tag,
type: '',
name: `{${tag.type}} ${tag.name}`.trimRight(),
});

/**
* Formats the descriptions of a list of tags in order to fix those texts the parser may have
Expand Down
11 changes: 11 additions & 0 deletions test/unit/fns/formatTagsDescription.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ describe('formatTagsDescription', () => {
name: 'Some',
description: 'description.',
},
{
tag: 'description',
name: '',
description: 'Some description that was already joined by the block formatter.',
},
{
tag: 'description',
type: '@link OtherType',
Expand Down Expand Up @@ -50,6 +55,12 @@ describe('formatTagsDescription', () => {
description: 'Some description.',
descriptionParagrah: false,
},
{
tag: 'description',
name: '',
description: 'Some description that was already joined by the block formatter.',
descriptionParagrah: false,
},
{
tag: 'description',
type: '',
Expand Down

0 comments on commit 9489967

Please sign in to comment.