Skip to content

Commit

Permalink
fix: should apply corrected parse description for all rules as may ot…
Browse files Browse the repository at this point in the history
…herwise parse previous tags differently
  • Loading branch information
brettz9 committed Dec 4, 2019
1 parent 373fb43 commit d6ccd45
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/iterateJsdoc.js
Expand Up @@ -40,37 +40,35 @@ const parseComment = (commentNode, indent, trim = true) => {
return commentParser.PARSERS.parse_name(str, data);
},
),
trim ?
commentParser.PARSERS.parse_description :

// parse_description
(str, data) => {
// Only expected throw in previous step is if bad name (i.e.,
// missing end bracket on optional name), but `@example`
// skips name parsing
/* istanbul ignore next */
if (data.errors && data.errors.length) {
return null;
}
// parse_description
(str, data) => {
// Only expected throw in previous step is if bad name (i.e.,
// missing end bracket on optional name), but `@example`
// skips name parsing
/* istanbul ignore next */
if (data.errors && data.errors.length) {
return null;
}

// Tweak original regex to capture only single optional space
const result = str.match(/^ ?((.|\s)+)?/u);

// Always has at least whitespace due to `indent` we've added
/* istanbul ignore next */
if (result) {
return {
data: {
description: result[1] === undefined ? '' : result[1],
},
source: result[0],
};
}
// Tweak original regex to capture only single optional space
const result = str.match(/^ ?((.|\s)+)?/u);

// Always has at least whitespace due to `indent` we've added
/* istanbul ignore next */
if (result) {
return {
data: {
description: result[1] === undefined ? '' : result[1],
},
source: result[0],
};
}

// Always has at least whitespace due to `indent` we've added
/* istanbul ignore next */
return null;
},
// Always has at least whitespace due to `indent` we've added
/* istanbul ignore next */
return null;
},
],
trim,
})[0] || {};
Expand Down

0 comments on commit d6ccd45

Please sign in to comment.