diff --git a/rust/src/parse.rs b/rust/src/parse.rs index cb20b4b..b5778f6 100644 --- a/rust/src/parse.rs +++ b/rust/src/parse.rs @@ -68,6 +68,7 @@ fn collect_comments(source: &str, program: &oxc::ast::ast::Program<'_>, include_ kind: match comment.kind { CommentKind::Line => "Line", CommentKind::SingleLineBlock | CommentKind::MultiLineBlock => "Block", + CommentKind::HtmlOpen | CommentKind::HtmlClose => "Line", }, value: comment.content_span().source_text(source).to_string(), start: comment.span.start, diff --git a/rust/tests/parse_test.rs b/rust/tests/parse_test.rs index f95b185..2ed8f13 100644 --- a/rust/tests/parse_test.rs +++ b/rust/tests/parse_test.rs @@ -46,6 +46,34 @@ fn parse_leaves_the_ast_out_when_it_was_only_asked_to_read() { ); } +#[test] +fn parse_treats_html_comments_as_line_comments() { + let (code, answer) = parse("\nfoo()", r#"{"ast":false,"source_type":"script"}"#); + + assert_eq!(code, OxcErrorCode::None); + + let payload: serde_json::Value = serde_json::from_str(&answer).unwrap(); + let comments = payload["comments"].as_array().unwrap(); + + assert_eq!(comments.len(), 1); + assert_eq!(comments[0]["type"], "Line"); + assert_eq!(comments[0]["value"], ""); +} + #[test] fn parse_answers_what_it_could_not_read_inside_the_result() { let (code, answer) = parse("const x = ;", r#"{"ast":false}"#);