Skip to content

Commit ef02d5b

Browse files
committed
fix: description retrieval logic was problematic for single line tags; fixes #1036
1 parent 131454f commit ef02d5b

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12329,6 +12329,9 @@ export default (foo) => {
1232912329
/** @file To learn more,
1233012330
* see: https://github.com/d3/d3-ease. */
1233112331

12332+
/** To learn more,
12333+
* see: https://github.com/d3/d3-ease. */
12334+
1233212335
/**
1233312336
* This is a complete sentence...
1233412337
*/
@@ -23488,6 +23491,15 @@ function processSass (input) {
2348823491
function updateIconButton () {
2348923492
}
2349023493
// "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":1}]
23494+
23495+
/** A class. */
23496+
class _Foo {
23497+
/** @param arg Argument. */
23498+
conststructor(arg: string) {
23499+
console.log(arg);
23500+
}
23501+
}
23502+
// "jsdoc/tag-lines": ["error"|"warn", "any",{"startLines":1}]
2349123503
````
2349223504

2349323505

src/iterateJsdoc.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,28 @@ const getUtils = (
229229
utils.getDescription = () => {
230230
const descriptions = [];
231231
let lastDescriptionLine = 0;
232+
let tagsBegun = false;
232233
jsdoc.source.some(({
233234
tokens: {
234235
description,
235236
tag,
236237
end,
237238
},
238239
}, idx) => {
240+
if (tag) {
241+
tagsBegun = true;
242+
}
243+
239244
if (idx && (tag || end)) {
240245
lastDescriptionLine = idx - 1;
241-
if (!tag && description) {
246+
if (!tagsBegun && description) {
242247
descriptions.push(description);
243248
}
244249

245250
return true;
246251
}
247252

248-
if (idx || description) {
253+
if (!tagsBegun && (idx || description)) {
249254
descriptions.push(description || (descriptions.length ? '' : '\n'));
250255
}
251256

test/rules/assertions/requireDescriptionCompleteSentence.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,12 @@ export default {
14861486
* see: https://github.com/d3/d3-ease. */
14871487
`,
14881488
},
1489+
{
1490+
code: `
1491+
/** To learn more,
1492+
* see: https://github.com/d3/d3-ease. */
1493+
`,
1494+
},
14891495
{
14901496
code: `
14911497
/**

test/rules/assertions/tagLines.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,5 +1139,23 @@ export default {
11391139
},
11401140
],
11411141
},
1142+
{
1143+
code: `
1144+
/** A class. */
1145+
class _Foo {
1146+
/** @param arg Argument. */
1147+
conststructor(arg: string) {
1148+
console.log(arg);
1149+
}
1150+
}
1151+
`,
1152+
options: [
1153+
'any',
1154+
{
1155+
startLines: 1,
1156+
},
1157+
],
1158+
parser: require.resolve('@typescript-eslint/parser'),
1159+
},
11421160
],
11431161
};

0 commit comments

Comments
 (0)