millermedeiros / esformatter-semicolon-first

esformatter plugin to add semicolon before `[` and `(` if they are the first things on the line
3 stars 2 forks source link

don't add semicolon before arrow functions #6

Closed carbureted closed 8 years ago

carbureted commented 8 years ago

This is to fix one of the outstanding issues on standard-format which breaks a common react idiom.

<div onSomething={(x) => y(x)}><foo /></div> erroneously becomes <div onSomething={;(x) => y(x)}><foo /></div>

https://github.com/maxogden/standard-format/issues/174 https://github.com/maxogden/standard-format/issues/165 https://github.com/maxogden/standard-format/issues/158

There's probably a cleaner way to write this code, and there may be problems with it that I don't expect - this is my first time working with this sort of thing. Let me know if there's anything I should change!

I haven't updated with a testcase, since the preexisting one failed the first time I ran it and also it doesn't seem to like JSX.

millermedeiros commented 8 years ago

I think it's safe to assume that if the previous token is { we don't need a semicolon. So the logic could be simpler.

I just updated the parser (and fixed the tests) and added a CONTRIBUTING.md explaining how to add new tests and run it.

@carbureted Let me know if you want to fix this or if I should go ahead and do it later today or tomorrow. Thanks a lot for submitting the bug and PR.

millermedeiros commented 8 years ago

@carbureted In fact this was fixed when I replaced the parser! (5c1f475152312a2f8d2db5d71cc594483902c930) - I'll add tests for it now and release a new version.

I decided to replace the parser today because our tests was broken and I wanted to ask you to introduce a test :D (another reason to thank you for the PR!)

Cheers

millermedeiros commented 8 years ago

just released v1.2.0 with the fix!