deno icon indicating copy to clipboard operation
deno copied to clipboard

fmt option to allow consecutive blank lines

Open csvn opened this issue 1 year ago • 2 comments

I know this issue may be closed, since Deno seems to have a similar opinionated philosophy as Prettier, but I'll give it a try since I could not find any docs discouraging feature requests for the formatter.

We have large amounts of code that often uses more than 1 blank line for separating content. Adding two instead of one blank line helps group content together visually (like having paragraphs in a book). They are not everywhere, but to our team they help improve readability of the code.

It would be awesome if there was a config option to allow multiple blank lines:

// deno.jsonc
{
  "fmt": {
    "maxConsecutiveLinebreaks": 2
  }
}

I agree with having great defaults for code formatting, but less flexibility also blocks adoption. This would be one of bigger blockers for formatting our code currently.

csvn avatar Oct 13 '24 15:10 csvn

I think this is too specific of a feature to be in deno fmt.

We have large amounts of code that often uses more than 1 blank line for separating content. Adding two instead of one blank line helps group content together visually (like having paragraphs in a book). They are not everywhere, but to our team they help improve readability of the code.

It might be better to use a comment or split up the code into smaller functions.

dsherret avatar Oct 14 '24 00:10 dsherret

It doesn't always make sense to e.g. split Angular components into smaller parts. Having more than one blank line is sometimes very helpful to group interfaces together visually. So far for Deno code, it's not a big issue, even if we prefer to have 2 lines separating imports from code in modules.

If it's not a feature you want to support in deno fmt, I understand. Oxc seems to intend to create a more flexible formatter, but it's not ready yet. All formatters we've tried so far are too opinionated, so we've stuck with ESLint + style rules.

csvn avatar Oct 14 '24 08:10 csvn

We're not going to do this. deno fmt is opinionated - prettier also doesn't have this option.

lucacasonato avatar Oct 21 '24 09:10 lucacasonato

Thanks for the consideration anyway. I'll put my hopes on Oxc for formatting our Angular codebase in the future. 🙂

csvn avatar Oct 21 '24 10:10 csvn