Closed tphecca closed 7 years ago
@tphecca, I'm glad you found our offside parser. We've been really enjoying it, but I haven't made the time to spread the word about it.
It looks like the generated code from babel-preset-latest
triggers the linting I enabled by default for offside-js. You can turn this setting off using {"keyword_blocks": false}
— see example package.json
The reason I added this default setting is the following (bad) pattern:
if (condition)
doFirstThing()
doSecondThing()
Which, of course, should actually be:
if (condition) ::
doFirstThing()
doSecondThing()
So I added the linting to make sure control flows were properly followed by ::
or {}
. I'll put some more thought into this to improve compatibility. Thanks for the feedback!
-Shane
Your question inspired me to removing the linting solution in favor of ensuring that elements of the body have matching indentation levels. The current version of babel-plugin-offside-js
is 0.6.3
. That version compiles your example without additional settings.
I've also put together a composite preset that uses babel-plugin-offside-js
you might be interested in — shanewholloway/babel-preset-jsy
Thanks! Glad I can continue to use this plugin, it's awesome.
What does the preset-jsy adds over this plugin ?
babel-preset-jsy
is a simple convenience package that bundles together:
lean
packaging.Thanks for clarification. I think I don't need any of those, so I'll stick to the plugin
Regards
I used this code:
When I try to build using gulp:
My babel presets and plugins:
Creating only the constructor (no other methods) does work with no errors: