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

Disallow or enforce spaces inside of curly braces in objects? #802

Closed
deep-c opened this issue Feb 12, 2016 · 28 comments · Fixed by #2047
Closed

Disallow or enforce spaces inside of curly braces in objects? #802

deep-c opened this issue Feb 12, 2016 · 28 comments · Fixed by #2047

Comments

@deep-c
Copy link

deep-c commented Feb 12, 2016

A lot of the linting configs i have tried use a 1 char space at the beginning and end within objects. Would be great if we were able to get this simple setting.

I use eslint with eslint-config-airbnb and this is the most frequent issue I have when attempting to beatify my code.

http://eslint.org/docs/rules/object-curly-spacing

Thanks

@prettydiff
Copy link
Collaborator

Pretty Diff has an option for this: prettydiff.com/documentation.xhtml#bracepadding

It seems the option has been poorly maintained and is currently broken though. I have already written a fix and it will be published with the next patch: prettydiff/prettydiff#266

Currently, it seems this Pretty Diff option is not supported by Atom Beautify, so I need it add it in. There is a JS Beautify option for brace-style which takes a value of expand, which is supported by Atom Beautify. It should get you what you need.

@deep-c
Copy link
Author

deep-c commented Feb 21, 2016

Hi thanks for the quick reply. What is the turn around for patches like this both on your end and for it to be supported in atom-beautify?

@prettydiff
Copy link
Collaborator

I typically publish resolutions to defect between an hour and two weeks depending upon the defect and what other items are in process. Atom Beautify publishes changes a bit more slowly because it has a wider distribution of dependencies and potential problem states to consider.

@djbobbydrake
Copy link

+1

@prettydiff
Copy link
Collaborator

Launched in v1.16.15 of Pretty Diff 24 days ago.

@cortopy
Copy link

cortopy commented Sep 14, 2016

@prettydiff Brace style options do not seem to have any effect with Pretty Diff. Was this fixed?

@prettydiff
Copy link
Collaborator

Should be fixed. The comment above says it was fixed with version 1.16.15 and Atom Beautify uses version 1.16.17.

@cortopy
Copy link

cortopy commented Sep 15, 2016

In that case I think there has been a regression either in Pretty Diff or Atom Beautify. Using Atom Beautify 0.29.11 and Pretty Diff, Brace Style settings have no effect at all

I've tried using "bracepadding" in .jsbeautifyrc but I don't think that setting is ever parsed

@Glavin001
Copy link
Owner

Correct, bracepadding option is not yet supported. Waiting on PR: #1193
See #1191 (comment) for some more info on this. #524 has a list of unsupported options, although there are likely more now.

@ElegantSudo
Copy link

What's going on with this?

@Glavin001
Copy link
Owner

Pull Request #1193 was merged. Published to v0.29.12

@ElegantSudo
Copy link

@Glavin001 how would I use this in my config file? I'm not seeing anything in the docs about bracepadding property.

@ElegantSudo
Copy link

@Glavin001 let me know when you get the chance! :)

@Glavin001
Copy link
Owner

@ElegantSudo
Copy link

@Glavin001 Thanks, but I'm talking about things like this: import { example } from './example'. So basically just curly brackets, not parentheses.

@spo
Copy link

spo commented Feb 7, 2017

Any updates on this? Thanks

@yurikilian
Copy link

waiting for this option too

@Glavin001
Copy link
Owner

For those waiting for this option:

  1. What beautifier are you using? Likely one of the following:
  1. Ensure the beautifier has the option you want
  • If not, go to the respective GitHub Issues page and create an Issue! Provide a link back to here for other users to follow.
  1. Ensure the option is available on Atom-Beautify

@derwaldgeist
Copy link

derwaldgeist commented Aug 12, 2017

I got the space_in_paren option working now. This turns imports like

import {Dimensions} from 'react-native';

into

import { Dimensions } from 'react-native';

Great. However, it also applies spaces to regular parens, like function calls:

Math.floor( height * 0.3 ),

and even arrow functions:

const test = ( ) => {}

which eslint doesn't like. Is there a chance to configure beautification in a way that spaces only apply to object literals?

If you're developing React with eslint and atom-beautify, it's pretty hard to keep both in sync and in sync with the numerous code samples you can find on the web. It would be awesome if there was a kind of recommended configuration file setup for this.

@Glavin001
Copy link
Owner

If you're developing React with eslint and atom-beautify, it's pretty hard to keep both in sync and in sync with the numerous code samples you can find on the web. It would be awesome if there was a kind of recommended configuration file setup for this.

This idea was brought up with #286 and has since moved to #299 . I plan on developing https://github.com/Unibeautify/unibeautify-options-importer to solve this problem by adapting technologies like eslint with Unibeautify's (formerly Atom-Beautify) configuration format.

@derwaldgeist
Copy link

Sounds great!

@jordangarside
Copy link

Just to confirm:
There is no way to add spaces just between brackets atm?

@Glavin001
Copy link
Owner

Glavin001 commented Feb 16, 2018

@jordangarside You can take a look at available Javascript (and other languages) options here: https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md#javascript

Looks like the closest options: space_in_paren.

Check out the docs for Unibeautify (rewrite of Atom-Beautify):

Option object_curly_spacing may be what you are looking for, however not yet released in Atom-Beautify. Let me know what you think! 😃

@jordangarside
Copy link

@Glavin001 the space_in_paren has the problem that it adds spaces to parens and brackets.

That Unibeautify option looks like what I want. 👍
I'll give it a try soon.

Thanks!

@Glavin001
Copy link
Owner

Unfortunately, Unibeautify is not released yet. @szeck87 is making great strides with #1935 . I recommend you subscribe to #1174 for updates to Atom-Beautify.

Also, please star and/or watch https://github.com/Unibeautify/unibeautify for updates for Unibeautify. Thank you for your interest!!

@Glavin001
Copy link
Owner

If I am not mistaken, the original goal of this issue was to add support for object-curly-spacing rule from ESLint.

Pretty Diff has a bracepadding option however this does not give desired results.
I am going to reopen this issue and welcome Pull Requests adding support for specifically object_curly_spacing. Please let me know if you have any questions!

@Glavin001 Glavin001 reopened this Feb 16, 2018
@Glavin001 Glavin001 self-assigned this Feb 16, 2018
@jordangarside
Copy link

Thanks for the info @Glavin001 !

For the time being I just ended up going with Prettier.

@Glavin001
Copy link
Owner

@szeck87 is working on adding Prettier support to Atom-Beautify as part of #1497

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

Successfully merging a pull request may close this issue.