Skip to content

Commit 14d7f22

Browse files
bary12gajus
authored andcommitted
fix: no-undefined-types crashing on type syntax error (#68)
1 parent 323a133 commit 14d7f22

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/rules/noUndefinedTypes.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ export default iterateJsdoc(({
3535
.concat(typedefDeclarations);
3636

3737
_.forEach(jsdoc.tags, (tag) => {
38-
const parsedType = parseType(tag.type);
38+
let parsedType;
39+
40+
try {
41+
parsedType = parseType(tag.type);
42+
} catch (error) {
43+
// On syntax error, will be handled by valid-types.
44+
return;
45+
}
3946

4047
traverse(parsedType, (node) => {
4148
if (node.type === 'NAME') {

test/rules/assertions/noUndefinedTypes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ export default {
104104
*/
105105
function quux(foo) {
106106
107+
}
108+
`
109+
},
110+
{
111+
code: `
112+
/**
113+
* @param {Array<syntaxError} foo
114+
*/
115+
function quux(foo) {
116+
107117
}
108118
`
109119
}

0 commit comments

Comments
 (0)