HaxeCheckstyle / haxe-formatter

Haxe code formatter based on tokentree
https://haxecheckstyle.github.io/haxe-formatter-docs/#codesamples.CommonSamples.allman_curlies
MIT License
72 stars 16 forks source link

Add wrapping configuration for comparison operators #678

Open One-Nose opened 7 months ago

One-Nose commented 7 months ago

Describe the Feature
There is no way to configure wrapping for comparison operators, to allow prettier long if conditions. I have this code:

if (this.actionsByPriority.indexOf(action) < this.actionsByPriority.indexOf(availableAction) {}

Desired output

if (
    this.actionsByPriority.indexOf(action) <
    this.actionsByPriority.indexOf(availableAction)
) {}
AlexHaxe commented 7 months ago

can't say I find your desired output easier to read, especially if you had multiple compare operations in a single if condition.

what would look prettier is to extract those terms into variables before comparing, but that is beyond the scope of a formatter.