8000 Consider removing empty lines from empty attrset · Issue #299 · NixOS/nixfmt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Consider removing empty lines from empty attrset #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jfly opened this issue Apr 30, 2025 · 2 comments
Open

Consider removing empty lines from empty attrset #299

jfly opened this issue Apr 30, 2025 · 2 comments

Comments

@jfly
Copy link
Collaborator
jfly commented Apr 30, 2025

Description

Originally requested by @mightyiam in #297

Should we ensure that empty attrsets are always formatted the same way?

Small example input

{
  a = {
  };
  b = {

  };
  c = {


  };
}

Expected output

{
  a = { };
  b = { };
  c = { };
}

Actual output

{
  a = {
  };
  b = {

  };
  c = {


  };
}
@MattSturgeon
Copy link

I believe the intention of being somewhat permissive here is to minimise patch differences where entries are frequently added/removed from a set or a list:

E.g.:

 {
   example = {
-    hello = "world";
   };
 }

vs

 {
-  example = {
-    hello = "world";
-  };
+  example = { };
 }

That said, I don't have a strong opinion on whether this is more important than producing a consistent output style.

@piegamesde
Copy link
Member

Negative. Preserving line breaks and preserving newlines are two different things in Nixfmt.

The original issue for which things got implemented was #188, however I don't remember if the wording in the specification was added before that or due to that.

CC @infinisil you implemented this, I'd like to hear your position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

3 participants
0