Js-beautify: Space before function arguments (space-after-function) (space-after-named-function)

Created on 27 Jan 2015  Â·  16Comments  Â·  Source: beautify-web/js-beautify

There should be flag to force a space before the function arguments like this:

function foo (bar, baz) {
    // …
}

maybe: {"space_before_arguments": true}

good first issue help wanted enhancement

Most helpful comment

+1
i do really hope this gets some more attention as 'javascript standard style' is getting more popular.

All 16 comments

There's a --space-after-anon-function. Probably call this --space-after-function.

:+1:

Yes, please.

so?

It's an enhancement. I'm fixing higher priority issues. Pull requests are welcome.

Can somebody please point me in a direction on how to hack this into /js/lib/beautify.js myself? In line 681 I found the statement handling anon_functions. I couldn't get anything going by fiddling with different kinds of statements, e.g.: if (current_token.text === '(' && last_last_word === 'function') ...

@bitwiseman I think calling it --space-after-named-function would be the most clear, yes? Like @atrioom, I'm interested to work on this. Where do I start?

@atrioom I don't really know what I'm looking at, but maybe here's a good place to look?

@jsejcksn - Name sounds fine.
And you're in the right area, but you'll want to separate else if with last_type === 'TK_WORD'.

Please also consider async functions

const a = async () {...}
async function b () {...}

--space-after-named-function is a good name

+1
i do really hope this gets some more attention as 'javascript standard style' is getting more popular.

@zekida And it should, it's "standard"! 😄

NOTE: When implemented this will need to not break "dynamic import()" - #1393

Not to sound mean, but given this is a specification of js standard it's kind of surprising it hasn't been a higher priority. I imagine most of us lint with standard these days, heck, most Vue frameworks have it by default. It kind of renders the whole thing pretty redundant if you have to go back and tidy up the spaces.

@jaysaurus
The existence of this project (and its ever growing list of requests for different formatting options) is one more living proof that formatting wars are alive and well in the land of JavaScript. Your "standard" is an other developer's "never-doing-it-that-way".

You are absolutely right: it would be great if there were more people willing to spend the time to implement features for this widely used library. If only there were more contributors...

Was this page helpful?
0 / 5 - 0 ratings