Skip to content

Commit

Permalink
add a suggestion for incorrect jsx closing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 26, 2022
1 parent f93f488 commit a1ff9d1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/js_parser/js_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4765,8 +4765,13 @@ func (p *parser) parseJSXElement(loc logger.Loc) js_ast.Expr {
p.lexer.NextInsideJSXElement()
endRange, endText, _ := p.parseJSXTag()
if startText != endText {
p.log.AddWithNotes(logger.Error, &p.tracker, endRange, fmt.Sprintf("Expected closing tag %q to match opening tag %q", endText, startText),
[]logger.MsgData{p.tracker.MsgData(startRange, fmt.Sprintf("The opening tag %q is here:", startText))})
msg := logger.Msg{
Kind: logger.Error,
Data: p.tracker.MsgData(endRange, fmt.Sprintf("Expected closing tag %q to match opening tag %q", endText, startText)),
Notes: []logger.MsgData{p.tracker.MsgData(startRange, fmt.Sprintf("The opening tag %q is here:", startText))},
}
msg.Data.Location.Suggestion = startText
p.log.AddMsg(msg)
}
if p.lexer.Token != js_lexer.TGreaterThan {
p.lexer.Expected(js_lexer.TGreaterThan)
Expand Down

0 comments on commit a1ff9d1

Please sign in to comment.