Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #635 and added unit tests #686

Merged
merged 3 commits into from
Apr 14, 2022
Merged

Conversation

robminer6
Copy link
Contributor

Previously, the code:

return
   <div>hi</div>

wouldn't report an error. It now correctly reports E0179 when returning an html tag on a new line. I also added unit tests.

@github-actions
Copy link

github-actions bot commented Apr 12, 2022

CLA Assistant Lite bot Thank you for your contribution! Like many free software projects, you must sign our Contributor License Agreement before we can accept your contribution.

EDIT: All contributors have signed quick-lint-js' Contributor License Agreement (CLA-v1.md).

@robminer6
Copy link
Contributor Author

I have read and hereby agree to quick-lint-js' Contributor License Agreement (CLA-v1.md).

Copy link
Collaborator

@strager strager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but the code could be shorter.

Let me know when I should merge.

@@ -375,6 +375,7 @@ bool parser::parse_and_visit_statement(
case token_type::slash_equal: // Regular expression.
case token_type::string:
case token_type::tilde:
case token_type::less:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Sort alphabetically; move above line 371.

Comment on lines 158 to 162
u8"<div>hi</div>",
u8"<a href=\"github.com/quick-lint/quick-lint-js\">link</a>",
u8"<p></p>",
u8"<div>this is <b>bold</b> and <i>italic</i> text</div>",
u8"<head><title>head and title</title></head>",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think we need only one or two examples of JSX, not five.

}) {
{
padded_string code(u8"return\n"s + second_line);
SCOPED_TRACE(code);
spy_visitor v;
parser p(&code, &v);
p.parse_and_visit_module(v);
if (second_line[0] == '<') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's always enable JSX for these tests. Make the test logic simple, not complex.

test/test-parse-statement.cpp Outdated Show resolved Hide resolved
@strager
Copy link
Collaborator

strager commented Apr 14, 2022

The CI failures aren't your fault. If you want to fix the CI errors, rebase or merge.

robminer6 and others added 3 commits April 14, 2022 10:32
Correctly reports E0179 when returning an html tag on a new line. Added unit tests as well.
Co-authored-by: strager <strager.nds@gmail.com>
Fixes the nitpicks strager had and is ready to merge.
Copy link
Collaborator

@strager strager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@strager strager merged commit 9b1fa8e into quick-lint:master Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants