esformatter icon indicating copy to clipboard operation
esformatter copied to clipboard

Not an issue but a request

Open iamprasad88 opened this issue 7 years ago • 4 comments

I love this tool. It meets almost all of my requirements. I am trying to push my team to use this.

I wanted to know if it is possible to add the following behavior to the formatting.

  • new line before return if it is not the only statement in the block
  • wrapped line (everything after the first part of the line) will be indented once (or [n] times) more than usual to indicate the line is wrapped
  if ( condition-a && condition-b
  && condition-c
  && conditon-d ...) {
}

must become

  if ( condition-a && condition-b
      && condition-c        // <-- Indented twice so that it sticks out as part of another line
      && conditon-d ...) { // <-- Indented twice so that it sticks out as part of another line
}
  • max line length

I am not sure if this is the right place for such a request, correct me if am wrong.

iamprasad88 avatar Aug 18 '16 20:08 iamprasad88

new line before return if it is not the only statement in the block

could easily be done as a plugin. Would be a nice thing to have (I would use this plugin).

max line length

anything related to wrapping and max-line length will be handled by plugins, because there are so many ways to do it, that it would be hard to configure and would increase the complexity of this project drastically. (see: #409 for more details)

millermedeiros avatar Aug 19 '16 21:08 millermedeiros

I looked into making a plugin and gave it a shot

https://github.com/iamprasad88/esformatter-only-return

iamprasad88 avatar Aug 22 '16 10:08 iamprasad88

Thought I'd comment for the wrapped lines: in the #409 that @millermedeiros linked, I commented about the plugin I made for wrapping lines. Get it here https://github.com/pgelinas/esformatter-auto-wrap and feedback very much welcome :smile:

pgelinas avatar Aug 31 '16 19:08 pgelinas

@pgelinas Thank you. I just had a chance to try it out. It works really well.

iamprasad88 avatar Sep 23 '16 21:09 iamprasad88