Skip to content

Commit

Permalink
fix(valid-types): ensure reporting "must have a type" when type is …
Browse files Browse the repository at this point in the history
…known to be required
  • Loading branch information
brettz9 committed Dec 1, 2019
1 parent b6e2699 commit b36053e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -9065,6 +9065,13 @@ function quux () {}
function quux () {}
// Settings: {"jsdoc":{"mode":"closure"}}
// Message: Tag @define must have a type
/**
* @this
*/
let foo;
// Settings: {"jsdoc":{"mode":"closure"}}
// Message: Tag @this must have a type
````
The following patterns are not considered problems:
Expand Down
2 changes: 1 addition & 1 deletion src/rules/validTypes.js
Expand Up @@ -97,7 +97,7 @@ export default iterateJsdoc(({
validNamepathParsing(thatNamepath);
}
} else {
if (mustHaveEither && !hasEither) {
if (mustHaveEither && !hasEither && !mustHaveTypePosition) {
report(`Tag @${tag.tag} must have either a type or namepath`, null, tag);

return;
Expand Down
19 changes: 19 additions & 0 deletions test/rules/assertions/validTypes.js
Expand Up @@ -323,6 +323,25 @@ export default {
},
},
},
{
code: `
/**
* @this
*/
let foo;
`,
errors: [
{
line: 3,
message: 'Tag @this must have a type',
},
],
settings: {
jsdoc: {
mode: 'closure',
},
},
},
],
valid: [
{
Expand Down

0 comments on commit b36053e

Please sign in to comment.