Skip to content

Commit

Permalink
fix(no-undefined-types): handle missing comment nodes on ancestors; f…
Browse files Browse the repository at this point in the history
…ixes #561
  • Loading branch information
brettz9 committed Jun 4, 2020
1 parent eb2c2b7 commit 0bc67fc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6224,6 +6224,16 @@ function example(arg) {
}
}
// Settings: {"jsdoc":{"mode":"closure"}}
const init = () => {
/**
* Makes request
* @returns {Promise}
*/
function request() {
return Promise.resolve('success');
}
};
````
Expand Down
3 changes: 3 additions & 0 deletions src/rules/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export default iterateJsdoc(({

let templateTags = _(ancestorNodes).flatMap((ancestorNode) => {
const commentNode = getJSDocComment(sourceCode, ancestorNode, settings);
if (!commentNode) {
return [];
}

const jsdoc = parseComment(commentNode, '');

Expand Down
16 changes: 16 additions & 0 deletions test/rules/assertions/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,5 +724,21 @@ export default {
},
},
},
{
code: `
const init = () => {
/**
* Makes request
* @returns {Promise}
*/
function request() {
return Promise.resolve('success');
}
};
`,
env: {
es6: true,
},
},
],
};

0 comments on commit 0bc67fc

Please sign in to comment.