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

fix(js/ts) Prevent while/if/switch from falsly matching as functions #2803

Merged
merged 5 commits into from Nov 2, 2020

Conversation

joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented Oct 30, 2020

When adding support for detecting what appear to be class functions:

class Dog {
  bark(args) {
    loud = true
  }
}

...we seem to have missed that this also matches if, while, switch, etc... so those need to be coded as exceptions to the rule.

Changes

Adds an exception mode to catch these first before the function rule matches them.

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md
  • Added myself to AUTHORS.txt, under Contributors

@joshgoebel joshgoebel requested review from egor-rogov and allejo Oct 30, 2020
@joshgoebel joshgoebel added this to the 10.4 milestone Oct 31, 2020
Copy link
Member

@allejo allejo left a comment

  • You're missing for
    image

  • Do we want to account for the following?
    image

@joshgoebel
Copy link
Member Author

@joshgoebel joshgoebel commented Nov 2, 2020

Do we want to account for the following?

Is that even possible? If so that is DUMB. I don't think there is any way we can account for it. The whole point here is we don't have access to the context... we have to behave the same inside or outside of a class.

allejo
allejo approved these changes Nov 2, 2020
Copy link
Member

@allejo allejo left a comment

should the changelog entry and unit tests be updated as well before this is merged? otherwise, this looks good to me

@joshgoebel joshgoebel merged commit bfbaa08 into highlightjs:master Nov 2, 2020
1 check was pending
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.

None yet

2 participants