Skip to content

New line before '{' option breaks JavaScript #114

Description

@esrat

There is a nasty bug when using the option "New line before '{'"!
This breaks the code being formatted when there are any return statements which do return structured data!
E.g. "return {x:l, y:v}" will become

return
{
  x: l,
  y: v
}

When loading something like this in Firefox there will be an "Uncaught SyntaxError: unexpected token: ':'" for the y-attribute. So, after the format we got an empty return-statement. Changing the code to at least

return {
  x: l,
  y: v
}

will fix this issue. But of course this is no solution to have to search for all broken return-statements after every JSFormat.

So there have to be an exception for opening braces after the keyword return!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions