Skip to content

Commit 3cca564

Browse files
authored
Merge pull request gajus#643 from pauliunas/ts-interface
fix(`require-jsdoc`): support `TSInterfaceDeclaration` with `publicOnly`
2 parents 55d70a5 + 3ae8e61 commit 3cca564

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9989,6 +9989,13 @@ export enum testEnum {
99899989
}
99909990
// Options: [{"contexts":["TSEnumDeclaration"],"publicOnly":true}]
99919991
// Message: Missing JSDoc comment.
9992+
9993+
export interface Test {
9994+
aFunc: () => void;
9995+
aVar: string;
9996+
}
9997+
// Options: [{"contexts":["TSInterfaceDeclaration"],"publicOnly":true}]
9998+
// Message: Missing JSDoc comment.
99929999
````
999310000

999410001
The following patterns are not considered problems:

src/exportParser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const getSymbol = function (node, globals, scope, opt) {
8181
/* istanbul ignore next */
8282
return null;
8383
}
84-
case 'TSEnumDeclaration':
84+
case 'TSEnumDeclaration': case 'TSInterfaceDeclaration':
8585
case 'ClassDeclaration': case 'ClassExpression':
8686
case 'FunctionExpression': case 'FunctionDeclaration':
8787
case 'ArrowFunctionExpression': {
@@ -152,6 +152,7 @@ createSymbol = function (node, globals, value, scope, isGlobal) {
152152
switch (node.type) {
153153
case 'TSEnumDeclaration':
154154
case 'FunctionDeclaration':
155+
case 'TSInterfaceDeclaration':
155156

156157
// Fallthrough
157158
case 'ClassDeclaration': {

test/rules/assertions/requireJsdoc.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,39 @@ export default {
25852585
sourceType: 'module',
25862586
},
25872587
},
2588+
{
2589+
code: `
2590+
export interface Test {
2591+
aFunc: () => void;
2592+
aVar: string;
2593+
}
2594+
`,
2595+
errors: [
2596+
{
2597+
line: 2,
2598+
message: 'Missing JSDoc comment.',
2599+
},
2600+
],
2601+
options: [
2602+
{
2603+
contexts: ['TSInterfaceDeclaration'],
2604+
publicOnly: true,
2605+
},
2606+
],
2607+
output: `
2608+
/**
2609+
*
2610+
*/
2611+
export interface Test {
2612+
aFunc: () => void;
2613+
aVar: string;
2614+
}
2615+
`,
2616+
parser: require.resolve('@typescript-eslint/parser'),
2617+
parserOptions: {
2618+
sourceType: 'module',
2619+
},
2620+
},
25882621
],
25892622
valid: [{
25902623
code: `

0 commit comments

Comments
 (0)