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

javascript and others: split at dot #146

Open
plexigras opened this issue Nov 11, 2018 · 1 comment
Open

javascript and others: split at dot #146

plexigras opened this issue Nov 11, 2018 · 1 comment

Comments

@plexigras
Copy link

foo.bar(x => x.y).baz
foo
  .bar(x => x.y)
  .baz
@AndrewRadev
Copy link
Owner

Sorry for taking so long to get around to this.

I think I've managed to implement splitting and joining at dot, although I'm worried about priorities.

Basically, this code right now, when split on the "bar", would split the function's arguments:

foo.bar(x => x.y).baz

But with the dot splitter, it would split the dot instead. It'd still be possible to split arguments when inside the function call, which feels quite sensible to me, and consistent with the rest of the plugin, so I guess maybe that's fine. Although when splitting on "foo" instead, it splits the method, which is maybe a bit weird. Still, not terrible.

The rule would be: you have to be on the property/method after the dot to split it. Finding a following dot would be way too complicated with any arbitrary expression being there.

I've created a branch with this new functionality: split-js-at-dot. I'd really appreciate it if you could switch to that branch and use it for a while, and let me know if the splitter is "too powerful", stopping you from using other splitters. But if it turns out okay, I can definitely see this being applied to a lot of other languages.

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

No branches or pull requests

2 participants