rufo 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -838
- data/lib/rufo/formatter/settings.rb +198 -0
- data/lib/rufo/formatter.rb +80 -297
- data/lib/rufo/version.rb +1 -1
- data/lib/rufo.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb66c78ddab7f72ff2c62ea1a6c8d268ee07871a
|
4
|
+
data.tar.gz: cdb227d8ae51899ffe33bf2468f7dccbe95f5b2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bebee1f9ef22fa4a3589cf0000f187e94da9f0224819922ca48cc13dbccd0c5349756956626c02230cda2e0f4fd4f91b7c2db1c287f5421d92c78151a5d0046
|
7
|
+
data.tar.gz: d7485eaa65ed1783c83f8134f5f97b298380f969c0600490d9d5f6e697f4ef3ff3fa5f32b2de5661823a5910fb21ba4e1c56fab5b2b65db4dab810a3c1de4024
|
data/README.md
CHANGED
@@ -145,7 +145,7 @@ according to **rufo**, and will exit with exit code 1.
|
|
145
145
|
## Editor support
|
146
146
|
|
147
147
|
- Atom: [rufo-atom](https://github.com/bmulvihill/rufo-atom) :construction:
|
148
|
-
- Emacs [emacs-rufo](https://github.com/aleandros/emacs-rufo) :construction: or [rufo
|
148
|
+
- Emacs [emacs-rufo](https://github.com/aleandros/emacs-rufo) :construction: or [rufo.el](https://github.com/danielma/rufo.el)
|
149
149
|
- Sublime Text: [sublime-rufo](https://github.com/asterite/sublime-rufo)
|
150
150
|
- Vim: [rufo-vim](https://github.com/splattael/rufo-vim)
|
151
151
|
- Visual Studio Code: [rufo-vscode](https://marketplace.visualstudio.com/items?itemName=siliconsenthil.rufo-vscode)
|
@@ -177,843 +177,7 @@ To configure Rufo, place a `.rufo` file in your project. When formatting a file
|
|
177
177
|
via the `rufo` program, a `.rufo` file will try to be found in that directory or parent directories.
|
178
178
|
|
179
179
|
The `.rufo` file is a Ruby file that is evaluated in the context of the formatter.
|
180
|
-
The available
|
181
|
-
|
182
|
-
### indent_size
|
183
|
-
|
184
|
-
Sets the indent size. Default: 2
|
185
|
-
|
186
|
-
### spaces_inside_hash_brace
|
187
|
-
|
188
|
-
Allow spaces inside hash braces?
|
189
|
-
|
190
|
-
- `:dynamic`: (default) if there's a space, keep it. Otherwise don't add it.
|
191
|
-
- `:always`: always add a space
|
192
|
-
- `:never`: never add a space
|
193
|
-
- `:match`: if there's a leading space, keep it (just one) and match the closing brace with one space before it
|
194
|
-
|
195
|
-
With `:always`, hashes will look like this:
|
196
|
-
|
197
|
-
```ruby
|
198
|
-
{ :foo => 1, :bar => 2 }
|
199
|
-
```
|
200
|
-
|
201
|
-
With `:never`, hashes will look like this:
|
202
|
-
|
203
|
-
```ruby
|
204
|
-
{:foo => 1, :bar => 2}
|
205
|
-
```
|
206
|
-
|
207
|
-
With `:match`, hashes will look like any of these:
|
208
|
-
|
209
|
-
```ruby
|
210
|
-
{ :foo => 1, :bar => 2 }
|
211
|
-
{:foo => 1, :bar => 2}
|
212
|
-
```
|
213
|
-
|
214
|
-
With `:dynamic`, any of the above choices is fine, and any amount of space (or zero) is preserved.
|
215
|
-
|
216
|
-
### spaces_inside_array_bracket
|
217
|
-
|
218
|
-
Allow spaces inside array brackets?
|
219
|
-
|
220
|
-
- `:dynamic`: (default) if there's a space, keep it. Otherwise don't add it.
|
221
|
-
- `:always`: always add a space
|
222
|
-
- `:never`: never add a space
|
223
|
-
- `:match`: if there's a leading space, keep it (just one) and match the closing bracket with one space before it
|
224
|
-
|
225
|
-
With `:always`, arrays will look like this:
|
226
|
-
|
227
|
-
```ruby
|
228
|
-
[ 1, 2 ]
|
229
|
-
```
|
230
|
-
|
231
|
-
With `:never`, arrays will look like this:
|
232
|
-
|
233
|
-
```ruby
|
234
|
-
[1, 2]
|
235
|
-
```
|
236
|
-
|
237
|
-
With `:match`, arrays will look like any of these:
|
238
|
-
|
239
|
-
```ruby
|
240
|
-
[ 1, 2 ]
|
241
|
-
[1, 2]
|
242
|
-
```
|
243
|
-
|
244
|
-
With `:dynamic`, any of the above choices is fine.
|
245
|
-
|
246
|
-
### spaces_around_equal
|
247
|
-
|
248
|
-
How to format spaces around an equal (`=`) sign?
|
249
|
-
|
250
|
-
- `:dynamic`: (default) allow any number of spaces (even zero) around the equal sign
|
251
|
-
- `:one`: always use one space before and after the equal sign
|
252
|
-
|
253
|
-
Given this code:
|
254
|
-
|
255
|
-
```ruby
|
256
|
-
a=1
|
257
|
-
b = 2
|
258
|
-
```
|
259
|
-
|
260
|
-
With `:one` the formatter will change it to:
|
261
|
-
|
262
|
-
```ruby
|
263
|
-
a = 1
|
264
|
-
b = 2
|
265
|
-
```
|
266
|
-
|
267
|
-
With `:dynamic` it won't modify it.
|
268
|
-
|
269
|
-
If `align_assignments` is `true`, then this setting has no effect and `:one`
|
270
|
-
will be used when no other assignments are above/below an assignment.
|
271
|
-
|
272
|
-
### spaces_in_ternary
|
273
|
-
|
274
|
-
How to format spaces around a ternary (`cond ? then : else`) operator?
|
275
|
-
|
276
|
-
- `:dynamic`: (default) allow any number of spaces (even zero) around `?` and `:`
|
277
|
-
- `:one`: always use one space before and after `?` and `:`
|
278
|
-
|
279
|
-
Given this code:
|
280
|
-
|
281
|
-
```ruby
|
282
|
-
a?b:c
|
283
|
-
a ? b : c
|
284
|
-
```
|
285
|
-
|
286
|
-
With `:one` the formatter will change it to:
|
287
|
-
|
288
|
-
```ruby
|
289
|
-
a ? b : c
|
290
|
-
a ? b : c
|
291
|
-
```
|
292
|
-
|
293
|
-
With `:dynamic` it won't modify it.
|
294
|
-
|
295
|
-
### spaces_in_suffix
|
296
|
-
|
297
|
-
How to format spaces around a suffix `if`, `unless`, etc?
|
298
|
-
|
299
|
-
- `:dynamic`: (default) allow any number of spaces (even zero) around `if`
|
300
|
-
- `:one`: always use one space before and after `if`
|
301
|
-
|
302
|
-
Given this code:
|
303
|
-
|
304
|
-
```ruby
|
305
|
-
a if b
|
306
|
-
```
|
307
|
-
|
308
|
-
With `:one` the formatter will change it to:
|
309
|
-
|
310
|
-
```ruby
|
311
|
-
a if b
|
312
|
-
```
|
313
|
-
|
314
|
-
With `:dynamic` it won't modify it.
|
315
|
-
|
316
|
-
### spaces_in_commands
|
317
|
-
|
318
|
-
How to format spaces after command names (a command is a call without parentheses)?
|
319
|
-
|
320
|
-
- `:dynamic`: (default) allow any number of spaces after a command name
|
321
|
-
- `:one`: always use one space after a command name
|
322
|
-
|
323
|
-
Given this code:
|
324
|
-
|
325
|
-
```ruby
|
326
|
-
include Foo
|
327
|
-
extend Bar
|
328
|
-
```
|
329
|
-
|
330
|
-
With `:one` the formatter will change it to:
|
331
|
-
|
332
|
-
```ruby
|
333
|
-
include Foo
|
334
|
-
extend Bar
|
335
|
-
```
|
336
|
-
|
337
|
-
With `:dynamic` it won't modify it.
|
338
|
-
|
339
|
-
### spaces_around_block_brace
|
340
|
-
|
341
|
-
How to format spaces around block braces?
|
342
|
-
|
343
|
-
- `:dynamic`: (default) allow any number of spaces around block braces
|
344
|
-
- `:one`: always use one space around block braces
|
345
|
-
|
346
|
-
Given this code:
|
347
|
-
|
348
|
-
```ruby
|
349
|
-
foo{|x|1}
|
350
|
-
foo {|x|1}
|
351
|
-
foo { |x|1}
|
352
|
-
foo { |x| 1}
|
353
|
-
```
|
354
|
-
|
355
|
-
With `:one` the formatter will change it to:
|
356
|
-
|
357
|
-
```ruby
|
358
|
-
foo { |x| 1 }
|
359
|
-
foo { |x| 1 }
|
360
|
-
foo { |x| 1 }
|
361
|
-
foo { |x| 1 }
|
362
|
-
```
|
363
|
-
|
364
|
-
With `:dynamic` it won't modify it.
|
365
|
-
|
366
|
-
### spaces_after_comma
|
367
|
-
|
368
|
-
How to format spaces after commas?
|
369
|
-
|
370
|
-
- `:dynamic`: (default) allow any number of spaces around block braces
|
371
|
-
- `:one`: always use one space after a comma
|
372
|
-
|
373
|
-
Given this code:
|
374
|
-
|
375
|
-
```ruby
|
376
|
-
foo 1, 2, 3
|
377
|
-
[1, 2, 3]
|
378
|
-
```
|
379
|
-
|
380
|
-
With `:one` the formatter will change it to:
|
381
|
-
|
382
|
-
```ruby
|
383
|
-
foo 1, 2, 3
|
384
|
-
[1, 2, 3]
|
385
|
-
```
|
386
|
-
|
387
|
-
With `:dynamic` it won't modify it.
|
388
|
-
|
389
|
-
### spaces_around_hash_arrow
|
390
|
-
|
391
|
-
How to format spaces around a hash arrow or keyword argument?
|
392
|
-
|
393
|
-
- `:dynamic`: (default) allow any number of spaces around hash arrows
|
394
|
-
- `:one`: always use one space around hash arrows
|
395
|
-
|
396
|
-
Given this code:
|
397
|
-
|
398
|
-
```ruby
|
399
|
-
{ 1 => 2, 3 => 4 }
|
400
|
-
{ foo: 1, bar: 2 }
|
401
|
-
```
|
402
|
-
|
403
|
-
With `:one` the formatter will change it to:
|
404
|
-
|
405
|
-
```ruby
|
406
|
-
{ 1 => 2, 3 => 4 }
|
407
|
-
{ foo: 1, bar: 2}
|
408
|
-
```
|
409
|
-
|
410
|
-
With `:dynamic` it won't modify it.
|
411
|
-
|
412
|
-
If `align_hash_keys` is `true`, then this setting has no effect and `:one`
|
413
|
-
will be used when no other hash keys are above/below.
|
414
|
-
|
415
|
-
### spaces_around_when
|
416
|
-
|
417
|
-
How to format spaces around a case when and then?
|
418
|
-
|
419
|
-
- `:dynamic`: (default) allow any number of spaces around a case when and then
|
420
|
-
- `:one`: always use one space around a case when and then
|
421
|
-
|
422
|
-
Given this code:
|
423
|
-
|
424
|
-
```ruby
|
425
|
-
case foo
|
426
|
-
when 1 then 2
|
427
|
-
end
|
428
|
-
```
|
429
|
-
|
430
|
-
With `:one` the formatter will change it to:
|
431
|
-
|
432
|
-
```ruby
|
433
|
-
case foo
|
434
|
-
when 1 then 2
|
435
|
-
end
|
436
|
-
```
|
437
|
-
|
438
|
-
With `:dynamic` it won't modify it.
|
439
|
-
|
440
|
-
If `align_case_when` is `true`, then this setting has no effect and `:one`
|
441
|
-
will be used when no other case when are above/below.
|
442
|
-
|
443
|
-
### spaces_around_dot
|
444
|
-
|
445
|
-
How to format spaces around a call dot?
|
446
|
-
|
447
|
-
- `:dynamic`: (default) allow any number of spaces around a call dot
|
448
|
-
- `:no`: no spaces around a call dot
|
449
|
-
|
450
|
-
Given this code:
|
451
|
-
|
452
|
-
```ruby
|
453
|
-
foo . bar
|
454
|
-
foo :: bar
|
455
|
-
foo &. bar
|
456
|
-
```
|
457
|
-
|
458
|
-
With `:no` the formatter will change it to:
|
459
|
-
|
460
|
-
```ruby
|
461
|
-
foo.bar
|
462
|
-
foo::bar
|
463
|
-
foo&.bar
|
464
|
-
```
|
465
|
-
|
466
|
-
With `:dynamic` it won't modify it.
|
467
|
-
|
468
|
-
### spaces_after_lambda_arrow
|
469
|
-
|
470
|
-
How to format spaces after a lambda arrow?
|
471
|
-
|
472
|
-
- `:dynamic`: (default) allow any number of spaces after a lambda arrow
|
473
|
-
- `:no`: no spaces after a lambda arrow
|
474
|
-
|
475
|
-
Given this code:
|
476
|
-
|
477
|
-
```ruby
|
478
|
-
->{ 1 }
|
479
|
-
-> { 2 }
|
480
|
-
```
|
481
|
-
|
482
|
-
With `:no` the formatter will change it to:
|
483
|
-
|
484
|
-
```ruby
|
485
|
-
->{ 1 }
|
486
|
-
->{ 2 }
|
487
|
-
```
|
488
|
-
|
489
|
-
With `:dynamic` it won't modify it.
|
490
|
-
|
491
|
-
For spaces inside the braces, the `spaces_around_block_brace` setting is used.
|
492
|
-
|
493
|
-
### spaces_around_unary
|
494
|
-
|
495
|
-
How to format spaces around a unary operator?
|
496
|
-
|
497
|
-
- `:dynamic`: (default) allow any number of spaces around a unary operator
|
498
|
-
- `:no`: no spaces around a unary operator
|
499
|
-
|
500
|
-
Given this code:
|
501
|
-
|
502
|
-
```ruby
|
503
|
-
+1
|
504
|
-
- 2
|
505
|
-
! x
|
506
|
-
```
|
507
|
-
|
508
|
-
With `:no` the formatter will change it to:
|
509
|
-
|
510
|
-
```ruby
|
511
|
-
+1
|
512
|
-
-2
|
513
|
-
!x
|
514
|
-
```
|
515
|
-
|
516
|
-
With `:dynamic` it won't modify it.
|
517
|
-
|
518
|
-
### spaces_around_binary
|
519
|
-
|
520
|
-
How to format spaces around a binary operator?
|
521
|
-
|
522
|
-
- `:dynamic`: (default) allow any number of spaces around a binary operator
|
523
|
-
- `:one`: at most one space around a binary operator
|
524
|
-
|
525
|
-
Given this code:
|
526
|
-
|
527
|
-
```ruby
|
528
|
-
1+2
|
529
|
-
1 +2
|
530
|
-
1+ 2
|
531
|
-
1 + 2
|
532
|
-
```
|
533
|
-
|
534
|
-
With `:one` the formatter will change it to:
|
535
|
-
|
536
|
-
```ruby
|
537
|
-
1+2
|
538
|
-
1 + 2
|
539
|
-
1+2
|
540
|
-
1 + 2
|
541
|
-
```
|
542
|
-
|
543
|
-
Note that with `:one` the spaces are kept balanced: if there's no space
|
544
|
-
before the operator, no space is kept after it. If there's a space
|
545
|
-
before the operator, a space is added after it.
|
546
|
-
|
547
|
-
With `:dynamic` it won't modify it.
|
548
|
-
|
549
|
-
### spaces_after_method_name
|
550
|
-
|
551
|
-
How to format spaces after a method name?
|
552
|
-
|
553
|
-
- `:dynamic`: (default) allow any number of spaces
|
554
|
-
- `:no`: no spaces after a method name
|
555
|
-
|
556
|
-
Given this code:
|
557
|
-
|
558
|
-
```ruby
|
559
|
-
def plus_one (x) x + 1 end
|
560
|
-
def plus_twenty(x) x + 20 end
|
561
|
-
```
|
562
|
-
|
563
|
-
With `:no` the formatter will change it to:
|
564
|
-
|
565
|
-
```ruby
|
566
|
-
def plus_one(x) x + 1 end
|
567
|
-
def plus_twenty(x) x + 20 end
|
568
|
-
```
|
569
|
-
|
570
|
-
With `:dynamic` it won't modify it.
|
571
|
-
|
572
|
-
### parens_in_def
|
573
|
-
|
574
|
-
Use parentheses in defs?
|
575
|
-
|
576
|
-
- `:dynamic`: (default) don't modify existing methods parentheses choice
|
577
|
-
- `:yes`: always use parentheses (add them if they are not there)
|
578
|
-
|
579
|
-
Given this code:
|
580
|
-
|
581
|
-
```ruby
|
582
|
-
def foo x, y
|
583
|
-
end
|
584
|
-
|
585
|
-
def bar(x, y)
|
586
|
-
end
|
587
|
-
```
|
588
|
-
|
589
|
-
With `:yes` the formatter will change it to:
|
590
|
-
|
591
|
-
```ruby
|
592
|
-
def foo(x, y)
|
593
|
-
end
|
594
|
-
|
595
|
-
def bar(x, y)
|
596
|
-
end
|
597
|
-
```
|
598
|
-
|
599
|
-
With `:dynamic` it won't modify it.
|
600
|
-
|
601
|
-
### double_newline_inside_type
|
602
|
-
|
603
|
-
Allow an empty line inside a type declaration?
|
604
|
-
|
605
|
-
- `:dynamic`: (default) allow at most one empty newline
|
606
|
-
- `:no`: no empty newlines inside type declarations
|
607
|
-
|
608
|
-
Given this code:
|
609
|
-
|
610
|
-
```ruby
|
611
|
-
class Foo
|
612
|
-
|
613
|
-
CONST = 1
|
614
|
-
|
615
|
-
end
|
616
|
-
|
617
|
-
class Bar
|
618
|
-
CONST = 2
|
619
|
-
end
|
620
|
-
```
|
621
|
-
|
622
|
-
With `:no` the formatter will change it to:
|
623
|
-
|
624
|
-
```ruby
|
625
|
-
class Foo
|
626
|
-
CONST = 1
|
627
|
-
end
|
628
|
-
|
629
|
-
class Bar
|
630
|
-
CONST = 2
|
631
|
-
end
|
632
|
-
```
|
633
|
-
|
634
|
-
With `:dynamic` it won't modify it.
|
635
|
-
|
636
|
-
### visibility_indent
|
637
|
-
|
638
|
-
How to indent code after a visibility method (`public`, `protected`, `private`)?
|
639
|
-
|
640
|
-
- `:dynamic`: (default) keep the current code's choice according to the first expression that follows
|
641
|
-
- `:indent`: indent code after the visibility method
|
642
|
-
- `:align`: align code at the same column as the visibility method
|
643
|
-
|
644
|
-
Given this code:
|
645
|
-
|
646
|
-
```ruby
|
647
|
-
class Foo
|
648
|
-
private
|
649
|
-
|
650
|
-
def foo
|
651
|
-
end
|
652
|
-
|
653
|
-
def bar
|
654
|
-
end
|
655
|
-
end
|
656
|
-
|
657
|
-
class Bar
|
658
|
-
private
|
659
|
-
|
660
|
-
def foo
|
661
|
-
end
|
662
|
-
|
663
|
-
def bar
|
664
|
-
end
|
665
|
-
end
|
666
|
-
```
|
667
|
-
|
668
|
-
With `:dynamic`, the formatter will change it to:
|
669
|
-
|
670
|
-
```ruby
|
671
|
-
class Foo
|
672
|
-
private
|
673
|
-
|
674
|
-
def foo
|
675
|
-
end
|
676
|
-
|
677
|
-
def bar
|
678
|
-
end
|
679
|
-
end
|
680
|
-
|
681
|
-
class Bar
|
682
|
-
private
|
683
|
-
|
684
|
-
def foo
|
685
|
-
end
|
686
|
-
|
687
|
-
def bar
|
688
|
-
end
|
689
|
-
end
|
690
|
-
```
|
691
|
-
|
692
|
-
Note that the formatter unified the indentation choice according to the first
|
693
|
-
expression. It makes no sense to keep two choices together inside a same type
|
694
|
-
declaration.
|
695
|
-
|
696
|
-
With `:align`, the formatter will change it to:
|
697
|
-
|
698
|
-
```ruby
|
699
|
-
class Foo
|
700
|
-
private
|
701
|
-
|
702
|
-
def foo
|
703
|
-
end
|
704
|
-
|
705
|
-
def bar
|
706
|
-
end
|
707
|
-
end
|
708
|
-
|
709
|
-
class Bar
|
710
|
-
private
|
711
|
-
|
712
|
-
def foo
|
713
|
-
end
|
714
|
-
|
715
|
-
def bar
|
716
|
-
end
|
717
|
-
end
|
718
|
-
```
|
719
|
-
|
720
|
-
With `:indent`, the formatter will change it to:
|
721
|
-
|
722
|
-
```ruby
|
723
|
-
class Foo
|
724
|
-
private
|
725
|
-
|
726
|
-
def foo
|
727
|
-
end
|
728
|
-
|
729
|
-
def bar
|
730
|
-
end
|
731
|
-
end
|
732
|
-
|
733
|
-
class Bar
|
734
|
-
private
|
735
|
-
|
736
|
-
def foo
|
737
|
-
end
|
738
|
-
|
739
|
-
def bar
|
740
|
-
end
|
741
|
-
end
|
742
|
-
```
|
743
|
-
|
744
|
-
**NOTE:** There's another commonly used indentation style which is `:dedent`:
|
745
|
-
|
746
|
-
```ruby
|
747
|
-
class Foo
|
748
|
-
def foo
|
749
|
-
end
|
750
|
-
|
751
|
-
private
|
752
|
-
|
753
|
-
def bar
|
754
|
-
end
|
755
|
-
end
|
756
|
-
```
|
757
|
-
|
758
|
-
Rufo currently doesn't support it, but in the future it might.
|
759
|
-
|
760
|
-
### align_comments
|
761
|
-
|
762
|
-
Align successive comments?
|
763
|
-
|
764
|
-
- `false`: (default) don't align comments (preserve existing code)
|
765
|
-
- `true`: align successive comments
|
766
|
-
|
767
|
-
Given this code:
|
768
|
-
|
769
|
-
```ruby
|
770
|
-
foo = 1 # some comment
|
771
|
-
barbaz = 2 # some other comment
|
772
|
-
```
|
773
|
-
|
774
|
-
With `true`, the formatter will change it to:
|
775
|
-
|
776
|
-
```ruby
|
777
|
-
foo = 1 # some comment
|
778
|
-
barbaz = 2 # some other comment
|
779
|
-
```
|
780
|
-
|
781
|
-
With `false` it won't modify it.
|
782
|
-
|
783
|
-
### align_assignments
|
784
|
-
|
785
|
-
Align successive assignments?
|
786
|
-
|
787
|
-
- `false`: (default) don't align assignments (preserve existing code)
|
788
|
-
- `true`: align successive assignments
|
789
|
-
|
790
|
-
Given this code:
|
791
|
-
|
792
|
-
```ruby
|
793
|
-
foo = 1
|
794
|
-
barbaz = 2
|
795
|
-
```
|
796
|
-
|
797
|
-
With `true`, the formatter will change it to:
|
798
|
-
|
799
|
-
```ruby
|
800
|
-
foo = 1
|
801
|
-
barbaz = 2
|
802
|
-
```
|
803
|
-
|
804
|
-
With `false` it won't modify it.
|
805
|
-
|
806
|
-
### align_hash_keys
|
807
|
-
|
808
|
-
Align successive hash keys?
|
809
|
-
|
810
|
-
- `false`: (default) don't align hash keys (preserve existing code)
|
811
|
-
- `true`: align successive hash keys
|
812
|
-
|
813
|
-
Given this code:
|
814
|
-
|
815
|
-
```ruby
|
816
|
-
{
|
817
|
-
foo: 1,
|
818
|
-
barbaz: 2,
|
819
|
-
}
|
820
|
-
|
821
|
-
{
|
822
|
-
:foo => 1,
|
823
|
-
:barbaz => 2,
|
824
|
-
}
|
825
|
-
|
826
|
-
method foo: 1,
|
827
|
-
barbaz: 2
|
828
|
-
```
|
829
|
-
|
830
|
-
With `true`, the formatter will change it to:
|
831
|
-
|
832
|
-
```ruby
|
833
|
-
{
|
834
|
-
foo: 1,
|
835
|
-
barbaz: 2,
|
836
|
-
}
|
837
|
-
|
838
|
-
{
|
839
|
-
:foo => 1,
|
840
|
-
:barbaz => 2,
|
841
|
-
}
|
842
|
-
|
843
|
-
method foo: 1,
|
844
|
-
barbaz: 2
|
845
|
-
```
|
846
|
-
|
847
|
-
With `false` it won't modify it.
|
848
|
-
|
849
|
-
### align_case_when
|
850
|
-
|
851
|
-
Align successive case when?
|
852
|
-
|
853
|
-
- `false`: (default) don't align case when (preserve existing code)
|
854
|
-
- `true`: align successive case when
|
855
|
-
|
856
|
-
Given this code:
|
857
|
-
|
858
|
-
```ruby
|
859
|
-
case exp
|
860
|
-
when foo then 2
|
861
|
-
when barbaz then 3
|
862
|
-
end
|
863
|
-
```
|
864
|
-
|
865
|
-
With `true`, the formatter will change it to:
|
866
|
-
|
867
|
-
```ruby
|
868
|
-
case exp
|
869
|
-
when foo then 2
|
870
|
-
when barbaz then 3
|
871
|
-
end
|
872
|
-
```
|
873
|
-
|
874
|
-
With `false` it won't modify it.
|
875
|
-
|
876
|
-
### align_chained_calls
|
877
|
-
|
878
|
-
Align chained calls to the dot?
|
879
|
-
|
880
|
-
- `false`: (default) don't align chained calls to the dot (preserve existing code)
|
881
|
-
- `true`: align chained calls to the dot
|
882
|
-
|
883
|
-
Given this code:
|
884
|
-
|
885
|
-
```ruby
|
886
|
-
foo.bar
|
887
|
-
.baz
|
888
|
-
|
889
|
-
foo.bar
|
890
|
-
.baz
|
891
|
-
```
|
892
|
-
|
893
|
-
With `true`, the formatter will change it to:
|
894
|
-
|
895
|
-
```ruby
|
896
|
-
foo.bar
|
897
|
-
.baz
|
898
|
-
|
899
|
-
foo.bar
|
900
|
-
.baz
|
901
|
-
```
|
902
|
-
|
903
|
-
With `false` it won't modify it.
|
904
|
-
|
905
|
-
Note that with `false` it will keep it aligned to the dot if it's already like that.
|
906
|
-
|
907
|
-
### trailing_commas
|
908
|
-
|
909
|
-
Use trailing commas in array and hash literals, and keyword arguments?
|
910
|
-
|
911
|
-
- `:dynamic`: (default) if there's a trailing comma, keep it. Otherwise, don't remove it
|
912
|
-
- `:always`: always put a trailing comma
|
913
|
-
- `:never`: never put a trailing comma
|
914
|
-
|
915
|
-
Given this code:
|
916
|
-
|
917
|
-
```ruby
|
918
|
-
[
|
919
|
-
1,
|
920
|
-
2
|
921
|
-
]
|
922
|
-
|
923
|
-
[
|
924
|
-
1,
|
925
|
-
2,
|
926
|
-
]
|
927
|
-
|
928
|
-
{
|
929
|
-
foo: 1,
|
930
|
-
bar: 2
|
931
|
-
}
|
932
|
-
|
933
|
-
{
|
934
|
-
foo: 1,
|
935
|
-
bar: 2,
|
936
|
-
}
|
937
|
-
|
938
|
-
foo(
|
939
|
-
x: 1,
|
940
|
-
y: 2
|
941
|
-
)
|
942
|
-
|
943
|
-
foo(
|
944
|
-
x: 1,
|
945
|
-
y: 2,
|
946
|
-
)
|
947
|
-
```
|
948
|
-
|
949
|
-
With `:always`, the formatter will change it to:
|
950
|
-
|
951
|
-
```ruby
|
952
|
-
[
|
953
|
-
1,
|
954
|
-
2,
|
955
|
-
]
|
956
|
-
|
957
|
-
[
|
958
|
-
1,
|
959
|
-
2,
|
960
|
-
]
|
961
|
-
|
962
|
-
{
|
963
|
-
foo: 1,
|
964
|
-
bar: 2,
|
965
|
-
}
|
966
|
-
|
967
|
-
{
|
968
|
-
foo: 1,
|
969
|
-
bar: 2,
|
970
|
-
}
|
971
|
-
|
972
|
-
foo(
|
973
|
-
x: 1,
|
974
|
-
y: 2,
|
975
|
-
)
|
976
|
-
|
977
|
-
foo(
|
978
|
-
x: 1,
|
979
|
-
y: 2,
|
980
|
-
)
|
981
|
-
```
|
982
|
-
With `:never`, the formatter will change it to:
|
983
|
-
|
984
|
-
```ruby
|
985
|
-
[
|
986
|
-
1,
|
987
|
-
2
|
988
|
-
]
|
989
|
-
|
990
|
-
[
|
991
|
-
1,
|
992
|
-
2
|
993
|
-
]
|
994
|
-
|
995
|
-
{
|
996
|
-
foo: 1,
|
997
|
-
bar: 2
|
998
|
-
}
|
999
|
-
|
1000
|
-
{
|
1001
|
-
foo: 1,
|
1002
|
-
bar: 2
|
1003
|
-
}
|
1004
|
-
|
1005
|
-
foo(
|
1006
|
-
x: 1,
|
1007
|
-
y: 2
|
1008
|
-
)
|
1009
|
-
|
1010
|
-
foo(
|
1011
|
-
x: 1,
|
1012
|
-
y: 2
|
1013
|
-
)
|
1014
|
-
```
|
1015
|
-
|
1016
|
-
With `:dynamic` it won't modify it.
|
180
|
+
The available settings are listed [here](https://github.com/asterite/rufo/wiki/Settings).
|
1017
181
|
|
1018
182
|
## How it works
|
1019
183
|
|