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

Hybrid space_in_paren option, e.g. "});" rather than "} );" #373

Open
sbking opened this issue Dec 27, 2013 · 5 comments
Open

Hybrid space_in_paren option, e.g. "});" rather than "} );" #373

sbking opened this issue Dec 27, 2013 · 5 comments

Comments

@sbking
Copy link

sbking commented Dec 27, 2013

Some JavaScript style guides, including idiomatic.js and the jQuery style guide, recommend a hybrid form of the spaces in brackets style. To summarize:

Function with a callback, object, or array as the sole argument. No space on either side of the argument:

foo(function() {
  // ...
});

foo({
  a: "alpha",
  b: "beta"
});

foo([ "alpha", "beta" ]);

Function with a callback, object, or array as the first argument. No space before the first argument:

foo(function() {
  // ...
}, options );

foo({
  a: "alpha",
  b: "beta"
}, options );

foo([ "alpha", "beta" ], options );

Function with a callback, object, or array as the last argument. No space after the last argument:

foo( "bar", function() {
  // ...
});

foo( "bar", {
  a: "alpha",
  b: "beta"
});

foo( "bar", [ "alpha", "beta" ]);

Is there any way we could get a "hybrid" mode for the space_in_paren option that implements these rules?

Also, the space_in_paren name is a bit misleading, as spaces are added to all brackets. space_in_brackets would be a more accurate name, but that's not a big deal.

@nemoDreamer
Copy link

Any news on this?
This is also a tricky one, as I like

[ "alpha", "beta" ];

but don't want

my_list[ i ];

@bitwiseman
Copy link
Member

Absolutely no news. You are welcome to submit a pull request or to fork. There are a number of higher priority features to be done before anyone on the project gets down to this one.

I will point out that the beautifier project has generally made "tricky" a non-goal, partly because the design make it very difficult (see #200). There are other projects that aim to handle any and all formatting settings you might like.

@nemoDreamer
Copy link

... My comment was not meant as an attack ...

@bitwiseman
Copy link
Member

👍 Sorry, didn't mean to come of defensive. 😄
Here is an additional retroactive smiley: 😃

@nemoDreamer
Copy link

Thanks 😍
To clarify: jsbeautify has always had all the options i needed, but now i'm working w/ a team that likes to space their array's brackets... I might convince them to run a more standard setup, i hope 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants