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

Chore: improve arrow-body-style error message (refs #5498) #9718

Merged
merged 2 commits into from Dec 16, 2017

Conversation

not-an-aardvark
Copy link
Member

@not-an-aardvark not-an-aardvark commented Dec 13, 2017

What is the purpose of this pull request? (put an "X" next to item)

[x] Other, please explain:

What changes did you make? (Give an overview)

#5498 gets more than twice as much traffic as any of our other issues. My interpretation of this fact is that people are often confused by errors from the arrow-body-style rule, and end up searching and finding that issue. This commit updates the error message for arrow-body-style to be more specific about how to fix the problem.

Is there anything you'd like reviewers to focus on?

Any wording suggestions?

#5498 gets more than twice as
much traffic as any of our other issues. My interpretation of this fact
is that people are often confused by errors from the `arrow-body-style`
rule, and end up searching and finding that issue. This commit updates
the error message for `arrow-body-style` to be more specific about how
to fix the problem.
@not-an-aardvark not-an-aardvark added the chore This change is not user-facing label Dec 13, 2017
Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

Left one comment about a message I'm not sure about, but otherwise this is a great change in the right direction. Thanks for your consideration.

let message;

if (blockBody.length === 0) {
message = "Unexpected block statement surrounding arrow body; put `undefined` immediately after the `=>`.";
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I like this message because undefined isn't a keyword and some folks might prefer void 0 or some other equivalent. Is there a way we can improve it? (I haven't got anything concrete now, sorry.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Would something like "move a value of undefined right after the =>" be better?

Alternatively, we could just use the old message for this case rather than adding an additional clause.

Personally, I think that:

  • The error message is only supposed to describe how to fix the arrow-body-style problem; as usual, a fix could conflict with another rule.
  • This is just a message for users and not an autofix, so we can assume users are willing to make some changes to the fix so that it fits within their code style.
  • In a project that doesn't use the undefined identifier, I assume users would be familiar with the alternatives for using the undefined identifier, so they would be able to create an appropriate replacement for the expression.

Copy link
Member

Choose a reason for hiding this comment

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

I like your alternative message suggestion. Ultimately this isn't a hill I want to die on, so just let me know what you decide and if you need me to review again. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to change the message to:

Unexpected block statement surrounding arrow body; put a value of undefined immediately after the =>.

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants