adobe / elixir-styler

An @elixir-lang code-style enforcer that will just FIFY instead of complaining
Apache License 2.0
627 stars 26 forks source link

`mix style` crashes with Surface formatter plugins and sigil #47

Closed mhanberg closed 1 year ago

mhanberg commented 1 year ago

Elixir / OTP Version

use elixir --version

Details

Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] Elixir 1.14.3 (compiled with Erlang/OTP 23)

Example Input

https://github.com/mhanberg/styler_boo_boo

defmodule StylerBooBooWeb.Demo do
  @moduledoc false
  use StylerBooBooWeb, :surface_live_view

  alias StylerBooBooWeb.Components.Card

  def mount(_, _, socket) do
    {:ok, assign(socket, foo: %{bar: "hi greg"})}
  end

  def render(assigns) do
    ~F"""
    <style>
      .tag {
      @apply bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2;
      }
    </style>

    <div class="flex justify-center mt-12">
      <Card max_width="lg" rounded>
        <:header>
          Surface UI {@foo.bar}
        </:header>

        Start building rich interactive user-interfaces, writing minimal custom Javascript.
        Built on top of Phoenix LiveView, <strong>Surface</strong> leverages the amazing
        <strong>Phoenix Framework</strong> to provide a fast and productive solution to
        build modern web applications.

        <:footer>
          <span class="tag">#surface</span>
          <span class="tag">#phoenix</span>
          <span class="tag">#tailwindcss</span>
        </:footer>
      </Card>
    </div>
    """
  end
end
novaugust commented 1 year ago

hello dear motch, hello and thank you for your issue

novaugust commented 1 year ago

anyways, surprised this is kabooming. AST should just be a sigil which is a function call and a string 🤔 i'll take your repo for a drive when i'm home tonight and see what's up

novaugust commented 1 year ago

ah, so this is something weird between mix style and mix format. if you use mix format did it work? i was about to write "i couldn't reproduce your bug" until i thought to try mix style i'm about ready to pull mix style out of the codebase, it's doing too much weird stuff ;)

novaugust commented 1 year ago

yeah, that's it. mix style doesn't play well with plugins please just use mix format instead =) (don't forget to add it to your plugins there per the readme)