Skip to content

Ensure no double newlines in files generated by "mix new" - #15711

Merged
josevalim merged 2 commits into
elixir-lang:mainfrom
praialabs:refute-double-newlines-mix-new
Aug 3, 2026
Merged

Ensure no double newlines in files generated by "mix new"#15711
josevalim merged 2 commits into
elixir-lang:mainfrom
praialabs:refute-double-newlines-mix-new

Conversation

@rhcarvalho

Copy link
Copy Markdown
Contributor

Add assertions to Mix.Tasks.NewTest to refute consecutive empty lines ("\n\n\n") in generated README.md and .gitignore files for both standard and umbrella projects, preventing accidental regression of template formatting issues (such as fixed in 7a7d7d9).

Add assertions to Mix.Tasks.NewTest to refute consecutive empty lines
("\n\n\n") in generated README.md and .gitignore files for both standard
and umbrella projects, preventing accidental regression of template formatting
issues (such as fixed in 7a7d7d9).
Replicate the approach from phoenixframework/phoenix#6781, since clearly
the Phoenix installer and `mix new` share the `assert_file/1` and
`assert_file/2` helpers.

All generated files are candidates for these two rules:
1. Every file must end with a single trailing newline.
2. No file may contain consecutive blank lines.

Instead of updating lots of tests (which would cause a lot of churn and
be a future maintenance burden, easy to miss in new tests), update the
helpers to enforce these rules on every file. Exceptions can be easily
added in the future if needed.
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

When working on a related PR for Phoenix, I realized we could do better and update the assert_file/1 and assert_file/2 helpers instead of adding the same repetitive checks in multiple places.

Sent as a separate commit to keep it easy to revert/drop.

@josevalim
josevalim merged commit 44405c3 into elixir-lang:main Aug 3, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants