Skip to content

Commit 668ea89

Browse files
committed
Add couple more tests and reuse some utilites to fix coverage
1 parent b897250 commit 668ea89

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7514,6 +7514,14 @@ function quux() {
75147514

75157515
}
75167516

7517+
/**
7518+
* @callback foo
7519+
*/
7520+
function quux() {
7521+
7522+
}
7523+
// Options: [{"allowEmptyNamepaths":true}]
7524+
75177525
/**
75187526
* @class
75197527
*/
@@ -7562,6 +7570,11 @@ function quux() {
75627570
*/
75637571
const FOO = 'foo';
75647572

7573+
/**
7574+
* @constant {string} FOO
7575+
*/
7576+
const FOO = 'foo';
7577+
75657578
/**
75667579
* @extends Foo
75677580
*/

src/rules/validTypes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ export default iterateJsdoc(({
6161
return true;
6262
};
6363

64-
const hasType = Boolean(tag.type);
64+
const hasType = utils.tagMightHaveType(tag.tag) && Boolean(tag.type);
6565
const mustHaveType = utils.tagMustHaveType(tag.tag);
6666

67-
const hasNamePath = Boolean(tag.name) && !(tag.tag === 'see' && !checkSeesForNamepaths);
67+
const hasNamePath = utils.tagMightHaveNamepath(tag.tag) && Boolean(tag.name) && !(tag.tag === 'see' && !checkSeesForNamepaths);
6868
const mustHaveNamepath = utils.tagMustHaveNamepath(tag.tag) && !allowEmptyNamepaths;
6969

70-
const hasEither = hasType || hasNamePath;
70+
const hasEither = utils.tagMightHaveEitherTypeOrNamepath(tag.tag) && hasType || hasNamePath;
7171
const mustHaveEither = utils.tagMustHaveEitherTypeOrNamepath(tag.tag);
7272

7373
if (tag.tag === 'borrows') {

test/rules/assertions/validTypes.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,19 @@ export default {
336336
}
337337
`,
338338
},
339+
{
340+
code: `
341+
/**
342+
* @callback foo
343+
*/
344+
function quux() {
345+
346+
}
347+
`,
348+
options: [{
349+
allowEmptyNamepaths: true,
350+
}],
351+
},
339352
{
340353
code: `
341354
/**
@@ -405,6 +418,14 @@ export default {
405418
const FOO = 'foo';
406419
`,
407420
},
421+
{
422+
code: `
423+
/**
424+
* @constant {string} FOO
425+
*/
426+
const FOO = 'foo';
427+
`,
428+
},
408429
{
409430
code: `
410431
/**

0 commit comments

Comments
 (0)