Skip to content

Commit ffecc96

Browse files
authored
Merge pull request #282 from interfaced/master
feat(require-returns-check): Skip interface class methods
2 parents 4ac598c + d520daa commit ffecc96

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5054,6 +5054,15 @@ const language = {
50545054
}
50555055
}
50565056
// Message: JSDoc @returns declaration present but return expression not available in function.
5057+
5058+
class Foo {
5059+
/**
5060+
* @returns {string}
5061+
*/
5062+
bar () {
5063+
}
5064+
}
5065+
// Message: JSDoc @returns declaration present but return expression not available in function.
50575066
````
50585067

50595068
The following patterns are not considered problems:
@@ -5142,6 +5151,17 @@ function quux () {
51425151
function quux () {
51435152
}
51445153

5154+
/**
5155+
* @interface
5156+
*/
5157+
class Foo {
5158+
/**
5159+
* @returns {string}
5160+
*/
5161+
bar () {
5162+
}
5163+
}
5164+
51455165
/**
51465166
* @returns {undefined} Foo.
51475167
*/

src/rules/requireReturnsCheck.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const canSkip = (utils) => {
1515
'class',
1616
'constructor',
1717
'interface'
18-
]) || utils.isConstructor();
18+
]) || utils.isConstructor() || utils.classHasTag('interface');
1919
};
2020

2121
export default iterateJsdoc(({

test/rules/assertions/requireReturnsCheck.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ export default {
8989
message: 'JSDoc @returns declaration present but return expression not available in function.'
9090
}
9191
]
92+
},
93+
{
94+
code: `
95+
class Foo {
96+
/**
97+
* @returns {string}
98+
*/
99+
bar () {
100+
}
101+
}
102+
`,
103+
errors: [
104+
{
105+
line: 3,
106+
message: 'JSDoc @returns declaration present but return expression not available in function.'
107+
}
108+
]
92109
}
93110
],
94111
valid: [
@@ -223,6 +240,20 @@ export default {
223240
}
224241
`
225242
},
243+
{
244+
code: `
245+
/**
246+
* @interface
247+
*/
248+
class Foo {
249+
/**
250+
* @returns {string}
251+
*/
252+
bar () {
253+
}
254+
}
255+
`
256+
},
226257
{
227258
code: `
228259
/**

0 commit comments

Comments
 (0)