Skip to content

Commit

Permalink
chore: update jsdoccomment, comment-parser and update API accordingly
Browse files Browse the repository at this point in the history
Also updates lint-staged devDep.
  • Loading branch information
brettz9 committed Jul 25, 2021
1 parent 1059e9e commit 2ab93a6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"url": "http://gajus.com"
},
"dependencies": {
"@es-joy/jsdoccomment": "0.9.0-alpha.5",
"comment-parser": "1.1.6-beta.2",
"@es-joy/jsdoccomment": "0.9.0-alpha.6",
"comment-parser": "1.1.6-beta.3",
"debug": "^4.3.2",
"esquery": "^1.4.0",
"jsdoc-type-pratt-parser": "^1.0.4",
Expand Down Expand Up @@ -36,7 +36,7 @@
"gitdown": "^3.1.4",
"glob": "^7.1.7",
"husky": "^7.0.1",
"lint-staged": "^11.1.0",
"lint-staged": "^11.1.1",
"mocha": "^9.0.2",
"nyc": "^15.1.0",
"open-editor": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/alignTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const alignTransform = ({

if (!intoTags) {
if (tokens.description === '') {
tokens.postDelimiter = tokens.postDelimiter === '\r' ? '\r' : '';
tokens.postDelimiter = '';
} else if (!preserveMainDescriptionPostDelimiter) {
tokens.postDelimiter = ' ';
}
Expand Down
8 changes: 5 additions & 3 deletions src/iterateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ const getUtils = (
utils.getTagDescription = (tg) => {
const descriptions = [];
tg.source.some(({
tokens: {end, postDelimiter, tag, postTag, name, type, description},
tokens: {end, lineEnd, postDelimiter, tag, postTag, name, type, description},
}) => {
const desc = (
tag && postTag ||
!tag && !name && !type && postDelimiter || ''

// Remove space
).slice(1) +
(description || '');
(description || '') + (lineEnd || '');

if (end) {
if (desc) {
Expand Down Expand Up @@ -258,6 +258,7 @@ const getUtils = (
'postName',
'description',
'end',
'lineEnd',
].forEach((prop) => {
tokens[prop] = '';
});
Expand Down Expand Up @@ -319,7 +320,7 @@ const getUtils = (

utils.makeMultiline = () => {
const {source: [{tokens}]} = jsdoc;
const {postDelimiter, description, tag, name, type} = tokens;
const {postDelimiter, description, lineEnd, tag, name, type} = tokens;

let {tokens: {
postName, postTag, postType,
Expand All @@ -345,6 +346,7 @@ const getUtils = (
// If a description were present, it may have whitespace attached
// due to being at the end of the single line
description: description.trimEnd(),
lineEnd,
name,
postDelimiter,
postName,
Expand Down
3 changes: 2 additions & 1 deletion src/rules/checkLineAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const checkNotAlignedPerTag = (utils, tag, customSpacings) => {
name +
postName +
description +
end
end +
lineEnd
*/
let spacerProps;
let contentProps;
Expand Down
4 changes: 3 additions & 1 deletion src/rules/multilineBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default iterateJsdoc(({
'postDelimiter',
'tag',
'type',
'lineEnd',
'postType',
'postTag',
'name',
Expand Down Expand Up @@ -155,7 +156,7 @@ export default iterateJsdoc(({
tokens: jsdoc.source.reduce((obj, {
tokens: {
description: desc, tag: tg, type: typ, name: nme,
postType, postName, postTag,
lineEnd, postType, postName, postTag,
},
}) => {
if (typ) {
Expand All @@ -178,6 +179,7 @@ export default iterateJsdoc(({
) {
obj.description += ' ';
}
obj.lineEnd = lineEnd;

// Already filtered for multiple tags
obj.tag += tg;
Expand Down
1 change: 1 addition & 0 deletions src/rules/requireParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export default iterateJsdoc(({
delimiter: '*',
description: '',
end: '',
lineEnd: '',
name: functionParameterName,
newAdd: true,
postDelimiter: ' ',
Expand Down
3 changes: 3 additions & 0 deletions test/iterateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('iterateJsdoc', () => {
delimiter: '',
description: 'desc',
end: '',
lineEnd: '',
name: 'name',
postDelimiter: '',
postName: ' ',
Expand All @@ -86,6 +87,7 @@ describe('iterateJsdoc', () => {
delimiter: '',
description: '',
end: '*/',
lineEnd: '',
name: '',
postDelimiter: '',
postName: '',
Expand All @@ -110,6 +112,7 @@ describe('iterateJsdoc', () => {
delimiter: '/**',
description: 'SomeDescription',
end: '',
lineEnd: '',
name: '',
postDelimiter: ' ',
postName: '',
Expand Down

0 comments on commit 2ab93a6

Please sign in to comment.