From 4da4aebf35f49b607e32dcfb3142dba812e6d705 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 9 May 2024 07:09:11 -0700 Subject: [PATCH] fix(`valid-types`): disable checking of types/names within `import` tags; fixes #1226 --- docs/rules/valid-types.md | 4 ++++ src/rules/validTypes.js | 6 ++++++ test/rules/assertions/validTypes.js | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/docs/rules/valid-types.md b/docs/rules/valid-types.md index 2c436fe95..2f89e0d96 100644 --- a/docs/rules/valid-types.md +++ b/docs/rules/valid-types.md @@ -880,5 +880,9 @@ function quux() { function quux() { } + +/** + * @import { TestOne, TestTwo } from "./types" + */ ```` diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 2930ed1d3..8c1839bf3 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -212,6 +212,12 @@ export default iterateJsdoc(({ continue; } + if (tag.tag === 'import') { + // A named import will look like a type, but not be valid; we also don't + // need to check the name/namepath + continue; + } + if (tag.tag === 'borrows') { const thisNamepath = /** @type {string} */ ( utils.getTagDescription(tag) diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index ec1cc494b..fb3710bb2 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -1853,5 +1853,12 @@ export default { } ` }, + { + code: ` + /** + * @import { TestOne, TestTwo } from "./types" + */ + `, + } ], };