diff --git a/docs/rules/check-tag-names.md b/docs/rules/check-tag-names.md index 5aef2ab34..192404234 100644 --- a/docs/rules/check-tag-names.md +++ b/docs/rules/check-tag-names.md @@ -722,7 +722,7 @@ function quux (foo) {} */ function quux (foo) {} // Settings: {"jsdoc":{"mode":"jsdoc"}} -// Message: Invalid JSDoc tag name "internal". +// Message: Invalid JSDoc tag name "import". /** * @externs diff --git a/docs/rules/valid-types.md b/docs/rules/valid-types.md index 5b0f61cfa..19bcf6c99 100644 --- a/docs/rules/valid-types.md +++ b/docs/rules/valid-types.md @@ -877,5 +877,15 @@ function quux() { /** * An inline {@link text} tag with content. */ + +/** + * @param typeof + * @param readonly + * @param import + * @param is + */ +function quux() { + +} ```` diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index f8620da42..2930ed1d3 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -10,6 +10,13 @@ const inlineTags = new Set([ 'tutorial', ]); +const jsdocTypePrattKeywords = new Set([ + 'typeof', + 'readonly', + 'import', + 'is', +]); + const asExpression = /as\s+/u; const suppressTypes = new Set([ @@ -107,7 +114,10 @@ export default iterateJsdoc(({ * @returns {boolean} */ const validNamepathParsing = function (namepath, tagName) { - if (tryParsePathIgnoreError(namepath)) { + if ( + tryParsePathIgnoreError(namepath) || + jsdocTypePrattKeywords.has(namepath) + ) { return true; } diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index c201e9486..11bf9a131 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -1856,5 +1856,18 @@ export default { */ `, }, + { + code: ` + /** + * @param typeof + * @param readonly + * @param import + * @param is + */ + function quux() { + + } + ` + }, ], };