Skip to content

Commit

Permalink
fix(no-undefined-types): avoid supress tag type checking in closure;
Browse files Browse the repository at this point in the history
…fixes #815
  • Loading branch information
brettz9 committed Dec 17, 2021
1 parent 03f4ce7 commit fac3f20
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9404,6 +9404,14 @@ function foo (bar) {
};
// Settings: {"jsdoc":{"mode":"closure"}}
// Message: The type 'TEMPLATE_TYPE' is undefined.

/**
* @suppress {visibility}
*/
function foo () {
}
// Settings: {"jsdoc":{"mode":"jsdoc"}}
// Message: The type 'visibility' is undefined.
````

The following patterns are not considered problems:
Expand Down Expand Up @@ -9757,6 +9765,13 @@ class Test {
function quux(foo) {

}

/**
* @suppress {visibility}
*/
function foo () {
}
// Settings: {"jsdoc":{"mode":"closure"}}
````


Expand Down
2 changes: 1 addition & 1 deletion src/rules/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default iterateJsdoc(({
.concat(settings.mode === 'jsdoc' ? [] : closureGenericTypes));

const jsdocTagsWithPossibleType = utils.filterTags(({tag}) => {
return utils.tagMightHaveTypePosition(tag);
return utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
});

for (const tag of jsdocTagsWithPossibleType) {
Expand Down
34 changes: 34 additions & 0 deletions test/rules/assertions/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,26 @@ export default {
},
},
},
{
code: `
/**
* @suppress {visibility}
*/
function foo () {
}
`,
errors: [
{
line: 3,
message: 'The type \'visibility\' is undefined.',
},
],
settings: {
jsdoc: {
mode: 'jsdoc',
},
},
},
],
valid: [
{
Expand Down Expand Up @@ -1070,5 +1090,19 @@ export default {
`,
ignoreReadme: true,
},
{
code: `
/**
* @suppress {visibility}
*/
function foo () {
}
`,
settings: {
jsdoc: {
mode: 'closure',
},
},
},
],
};

0 comments on commit fac3f20

Please sign in to comment.