Prevent Rubymine from auto-correcting hash and array alignment

RubyMine aggressively enforces the following style for arrays and hashes:

expect(something).to eq({
name: 'John Doe',
email: 'johndoe@example.com'
})

expect(something).to eq([
{
name: 'John Doe'
},
{
name: 'Jacob Lockard'
}
])

I find this to be extremely ugly and hard-to-follow. I much prefer something more like this:

expect(something).to eq({
name: 'John Doe',
email: 'johndoe@example.com'
})

expect(something).to eq([
{
name: 'John Doe'
},
{
name: 'Jacob Lockard'
}
])

However, it is nearly impossible to get RubyMine to allow this. Whenever I hit <enter> it indents the cursor, and whenever I hit <backspace>, it returns all the way to the previous line.

I have set the following in my `.rubocop.yml` to get RuboCop to respect this:

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

RubyMine apparently does not pick up on this, however.

Any suggestions? It seems like there should be a setting under `Editor -> Code Style -> Ruby`, but nothing there seemed to help...

1
3 comments

Hello Jacob,

we have a request for adding more formatting options for hashes, could you please take a look:

https://youtrack.jetbrains.com/issue/RUBY-26542

0

Olga Kuvardina Ah, I see. Is there any way to disable that autocorrect feature altogether then?

0

Please sign in to leave a comment.