ruby-syntax-tree / syntax_tree

Interact with the Ruby syntax tree
https://ruby-syntax-tree.github.io/syntax_tree/
MIT License
563 stars 54 forks source link

Empty hash literal should be kept on one line #406

Open maxnotarangelo opened 1 year ago

maxnotarangelo commented 1 year ago

Empty hash literals get expanded to multiple lines, which is hard to read. Empty arrays don't do this, which is (in my opinion) the correct behavior:

Original:

nested_with_empty_hash = {
  a: {
    b: {},
    c: [],
    d: [{}, stuff, [], other_stuff]
  }
}

After formatting:

nested_with_empty_hash = {
  a: {
    b: {
    },
    c: [],
    d: [{}, stuff, [], other_stuff]
  }
}