Skip to content

Commit baab7eb

Browse files
fix(semantic): fix quote handling in jsdoc parser(#13776) (#14561)
Fixed #13776 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 6bf785b commit baab7eb

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

crates/oxc_linter/src/rules/jsdoc/require_returns.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,19 @@ fn test() {
11091109
None,
11101110
None,
11111111
),
1112+
(
1113+
"
1114+
/**
1115+
* Has single quote ' in comment.
1116+
* @returns Foo.
1117+
*/
1118+
function quux () {
1119+
return foo;
1120+
}
1121+
",
1122+
None,
1123+
None,
1124+
),
11121125
];
11131126

11141127
let fail = vec![

crates/oxc_semantic/src/jsdoc/parser/jsdoc_tag.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ mod test {
229229
"@k3 c3\n ",
230230
),
231231
("/** single line @k4 c4 */", "@k4 c4 "),
232+
(
233+
"
234+
/**
235+
* Has single quote ' in comment
236+
* @k5 c5
237+
*/",
238+
"@k5 c5\n ",
239+
),
240+
(
241+
"
242+
/**
243+
* @import {T} from '@k6'
244+
*/",
245+
"@import {T} from '@k6'\n ",
246+
),
232247
] {
233248
let allocator = Allocator::default();
234249
let semantic = build_semantic(&allocator, source_text);

crates/oxc_semantic/src/jsdoc/parser/parse.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub fn parse_jsdoc(
7878
}
7979
'"' => in_double_quotes = !in_double_quotes,
8080
'\'' => in_single_quotes = !in_single_quotes,
81+
'\n' => {
82+
in_double_quotes = false;
83+
in_single_quotes = false;
84+
}
8185
'{' => curly_brace_depth += 1,
8286
'}' => curly_brace_depth = curly_brace_depth.saturating_sub(1),
8387
'(' => brace_depth += 1,

0 commit comments

Comments
 (0)