Skip to content

Commit

Permalink
fix(prettier-plugin-jsdoc): avoid formatting examples into sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
homer0 committed Oct 27, 2020
1 parent 0f58b54 commit 4f3d162
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fns/prepareTagDescription.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const R = require('ramda');
const { ensureSentence, hasValidProperty } = require('./utils');
const { ensureSentence, hasValidProperty, isTag } = require('./utils');

/**
* @typedef {import('../types').CommentTag} CommentTag
Expand All @@ -12,7 +12,7 @@ const { ensureSentence, hasValidProperty } = require('./utils');
* @returns {CommentTag}
*/
const prepareTagDescription = (tag) => R.when(
hasValidProperty('description'),
R.allPass([hasValidProperty('description'), R.complement(isTag(['example', 'examples']))]),
R.compose(
R.assoc('description', R.__, tag),
ensureSentence,
Expand Down
11 changes: 11 additions & 0 deletions test/unit/fns/prepareTagDescription.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ describe('prepareTagDescription', () => {
description: ' Something else. ',
},
},
{
it: 'should ignore an @example tag',
input: {
tag: 'example',
description: ' something else ',
},
output: {
tag: 'example',
description: ' something else ',
},
},
];

it.each(cases)('should correctly format the case %#', (caseInfo) => {
Expand Down

0 comments on commit 4f3d162

Please sign in to comment.