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

Error message on wrong usage of macro #40

Merged
merged 7 commits into from
Oct 19, 2017

Conversation

maurobringolf
Copy link
Contributor

What:
Error message when macro is used in wrong way (not tagged template literal, function call or JSX).

Why:
Was a TODO in the source and improves developer experience and I wanted to look into how this thing and babel-macros works.

How:
Throw a new error and add additional branch for JSXClosingElement (otherwise each JSXElement will be prevaled twice)

Couple of open questions from my side:

  • Commit messages in this branch dont follow a standard and need to be cleaned up. How do you go about this? I tried getting pre-commit hook to work, but somehow it (or I 😁 ) didnt.
  • Should the error be a MacroError? Im not sure about the difference.
  • In documentation I could only find a reference for tagged template literal macro, not function call or JSX. I was looking for a link to attach to the error message. Should I add this under babel-macros section??

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

This is super great. Thank you so much!

Could you add a test for this? Should hopefully be pretty straightforward :) You can use the error function. Let me know if you need a hand.

Oh, and if you'd like you can add yourself to the contributors table with npm run add-contributor 👍

Thanks so much!

@codecov
Copy link

codecov bot commented Oct 19, 2017

Codecov Report

Merging #40 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #40   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           4      4           
  Lines          98    100    +2     
  Branches       20     21    +1     
=====================================
+ Hits           98    100    +2
Impacted Files Coverage Δ
src/macro.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4517d0e...8ab4245. Read the comment docs.

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Perfect. Thank you!

@kentcdodds kentcdodds merged commit df57424 into kentcdodds:master Oct 19, 2017
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