Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions crates/oxc_parser/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,3 +1124,10 @@ pub fn identifier_expected_after_question_dot(span: Span) -> OxcDiagnostic {
.with_label(span)
.with_help("Add an identifier after '?.'")
}

#[cold]
pub fn identifier_expected_jsx_no_hyphen(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Identifiers in JSX cannot contain hyphens")
.with_label(span)
.with_help("Remove the hyphen from the identifier")
}
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/jsx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<'a> ParserImpl<'a> {
let ident = self.parse_jsx_identifier();
// `<foo.bar- />` is a syntax error.
if ident.name.contains('-') {
let error = diagnostics::unexpected_token(ident.span);
let error = diagnostics::identifier_expected_jsx_no_hyphen(ident.span);
return self.fatal_error(error);
}
property = Some(ident);
Expand Down
3 changes: 2 additions & 1 deletion tasks/coverage/snapshots/parser_misc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3494,11 +3494,12 @@ Negative Passed: 120/120 (100.00%)
╰────
help: Remove this `?`

× Unexpected token
× Identifiers in JSX cannot contain hyphens
╭─[misc/fail/oxc-5355.jsx:1:6]
1 │ <Foo.bar-baz />
· ───────
╰────
help: Remove the hyphen from the identifier

× Optional declaration is not allowed here
╭─[misc/fail/oxc-5955-1.ts:1:8]
Expand Down
Loading