ucbi / uniform

Write less boilerplate and reuse more code in your portfolio of Elixir apps
https://hex.pm/packages/uniform
Apache License 2.0
33 stars 1 forks source link

Stop requiring special code fences around deps in mix.exs #34

Closed paulstatezny closed 2 years ago

paulstatezny commented 2 years ago

This PR removes the requirement to add # uniform:deps comments around your deps in mix.exs.

I think some folks could find that requirement off putting. (Some might consider it hacky.) So I think this removes a slight potential barrier of adoption.

Tradeoffs involved

"Keyword format" explanation

Regarding the "Pro" about keyword format, here's what an ejected mix.exs would look like before this PR:

[
  {:foo, "~> 1.0"},
  {:bar, "~> 0.8.5", only: [:dev]},
  {:baz, "~> 1.3.0", runtime: false, override: true},
  qux: "~> 1.1",
  bummer: "~> 1.2"
]

We were using Code.string_to_quoted!, which emits a different form of AST that causes Macro.to_string! to convert {:foo, "bar"} into foo: "bar" in certain places. That's not the typical syntax in mix.exs, so it's probably not preferable.

With this PR, we'll now emit:

[
  {:foo, "~> 1.0"},
  {:bar, "~> 0.8.5", only: [:dev]},
  {:baz, "~> 1.3.0", runtime: false, override: true},
  {:qux, "~> 1.1"},
  {:bummer, "~> 1.2"}
]