diff --git a/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs b/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs index 33cb6191d4a56..42147102dd089 100644 --- a/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs +++ b/crates/oxc_linter/src/rules/jsdoc/check_tag_names.rs @@ -606,6 +606,17 @@ fn test() { ", Some(serde_json::json!([ { "definedTags": [] } ])), None, + ), + // https://github.com/oxc-project/oxc/issues/13570 + ( + " + /** + * @import { Page } from '@playwright/test'; + */ + function quux (foo) { } + ", + Some(serde_json::json!([ { "definedTags": [] } ])), + None, ), ( " diff --git a/crates/oxc_semantic/src/jsdoc/parser/parse.rs b/crates/oxc_semantic/src/jsdoc/parser/parse.rs index 38d0c4448fe38..d54e2fdbee93d 100644 --- a/crates/oxc_semantic/src/jsdoc/parser/parse.rs +++ b/crates/oxc_semantic/src/jsdoc/parser/parse.rs @@ -38,6 +38,11 @@ pub fn parse_jsdoc( // This includes inline code blocks or markdown-style code inside comments. let mut in_backticks = false; + // Track whether we're currently inside quotes '...' or "..." + // This includes package names when doing a @import + let mut in_double_quotes = false; + let mut in_single_quotes = false; + // This flag tells us if we have already found the main comment block. // The first part before any @tags is considered the comment. Everything after is a tag. let mut comment_found = false; @@ -52,8 +57,12 @@ pub fn parse_jsdoc( while let Some(ch) = chars.next() { // A `@` is only considered the start of a tag if we are not nested inside // braces, square brackets, or backtick-quoted sections - let can_parse = - curly_brace_depth == 0 && square_brace_depth == 0 && brace_depth == 0 && !in_backticks; + let can_parse = curly_brace_depth == 0 + && square_brace_depth == 0 + && brace_depth == 0 + && !in_backticks + && !in_double_quotes + && !in_single_quotes; match ch { // NOTE: For now, only odd backtick(s) are handled. @@ -67,6 +76,8 @@ pub fn parse_jsdoc( in_backticks = !in_backticks; } } + '"' => in_double_quotes = !in_double_quotes, + '\'' => in_single_quotes = !in_single_quotes, '{' => curly_brace_depth += 1, '}' => curly_brace_depth = curly_brace_depth.saturating_sub(1), '(' => brace_depth += 1,