Forced newlines in formatter

It seems that some AI’s love writing very dense code, and it makes things rather unreadable. It would be amazing if we could print in a way that adds white-spacing / makes the formatting consistent. Just like we remove double white-spacing in the formatter.

  module Details = {
    @react.component
    let make = (~input as {filePath}: input) => React.string(filePath)
  }
  module Body = {
    @react.component
    let make = (~input as {filePath, oldString, newString, replaceAll}: input) => <>
      <ToolView.Field label="file" value=filePath />
      <ToolView.Text
        label={replaceAll->Option.getOr(false) ? "replace all" : "replace"} text=oldString
      />
      {newString == ""
        ? <ToolView.Field label="with" value="(nothing)" />
        : <ToolView.Text label="with" text=newString />}
    </>
  }
  module Output = Tool.TextResult.Output
  let failed = Tool.TextResult.failed

I opened an issue / PR for this, but would love to hear from you all wether this is something you experience, and wether changing the formatter for this is worth it for you all.

  • No, keep as is!
  • Yes please!
  • Behind some flag (--strict or something similar)
  • Other (reply)

0 voters

1 Like

I would have loved to have this even before AI but found it too invasive. It still is but maybe we have a stronger argument now in favor of it. And I hope we can do without a flag. There might be some valid use-cases where you want no new lines between multi-line expressions though, but even then, those could be ignored if we can identify them.