Skip to content

Commit f652d08

Browse files
golopotbrettz9
authored andcommitted
fix: Stop warning missing param and returns tags if @type is present
1 parent 0f54957 commit f652d08

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,6 +4252,9 @@ function quux (foo) {
42524252
// issue 182: optional chaining
42534253
/** @const {boolean} test */
42544254
const test = something?.find(_ => _)
4255+
4256+
/** @type {RequestHandler} */
4257+
function foo(req, res, next) {}
42554258
````
42564259

42574260

@@ -4857,6 +4860,11 @@ function quux () {
48574860
}
48584861
// Settings: {"jsdoc":{"forceRequireReturn":true}}
48594862

4863+
/** @type {RequestHandler} */
4864+
function quux (req, res , next) {
4865+
return;
4866+
}
4867+
48604868
/** foo class */
48614869
class foo {
48624870
/** foo constructor */

src/rules/requireParam.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export default iterateJsdoc(({
1212
return;
1313
}
1414

15+
// Param type is specified by type in @type
16+
if (utils.hasTag('type')) {
17+
return;
18+
}
19+
1520
functionParameterNames.some((functionParameterName, index) => {
1621
const jsdocParameterName = jsdocParameterNames[index];
1722

src/rules/requireReturns.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const canSkip = (utils) => {
2626
'class',
2727
'constructor',
2828

29+
// Return type is specified by type in @type
30+
'type',
31+
2932
// This seems to imply a class as well
3033
'interface'
3134
]) ||

test/rules/assertions/requireParam.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ export default {
567567
const test = something?.find(_ => _)
568568
`,
569569
parser: 'babel-eslint'
570+
},
571+
{
572+
code: `
573+
/** @type {RequestHandler} */
574+
function foo(req, res, next) {}
575+
`
570576
}
571577
]
572578
};

test/rules/assertions/requireReturns.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,14 @@ export default {
487487
}
488488
}
489489
},
490+
{
491+
code: `
492+
/** @type {RequestHandler} */
493+
function quux (req, res , next) {
494+
return;
495+
}
496+
`
497+
},
490498
{
491499
code: `
492500
/** foo class */

0 commit comments

Comments
 (0)