Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/oxc_parser/src/lexer/trivia_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,19 @@ impl TriviaBuilder {
if rest.starts_with(b"PURE__") {
comment.content = CommentContent::Pure;
self.has_pure_comment = true;
return;
} else if rest.starts_with(b"NO_SIDE_EFFECTS__") {
comment.content = CommentContent::NoSideEffects;
self.has_no_side_effects_comment = true;
return;
}
}

// Fallback: check for @license or @preserve anywhere in the comment
// This handles cases like /* @foo @preserve */ where the first @ doesn't match known patterns
if contains_license_or_preserve_comment(s) {
comment.content = CommentContent::Legal;
}
}
}

Expand Down Expand Up @@ -504,6 +512,8 @@ token /* Trailing 1 */
("/* @license */", CommentContent::Legal),
("/* foo @preserve */", CommentContent::Legal),
("/* foo @license */", CommentContent::Legal),
("/* @foo @preserve */", CommentContent::Legal),
("/* @foo @license */", CommentContent::Legal),
("/** foo @preserve */", CommentContent::JsdocLegal),
("/** foo @license */", CommentContent::JsdocLegal),
("/** jsdoc */", CommentContent::Jsdoc),
Expand Down
Loading