Skip to content
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

Formatting and check-formatted still not always consistent #3590

Closed
dfalling opened this issue Dec 20, 2024 · 1 comment
Closed

Formatting and check-formatted still not always consistent #3590

dfalling opened this issue Dec 20, 2024 · 1 comment

Comments

@dfalling
Copy link
Contributor

Environment

  • Elixir version (elixir -v): 1.17.1
  • Phoenix version (mix deps): 1.7.18
  • Phoenix LiveView version (mix deps): 1.0.1
  • Operating system: macOS 15.0
  • Browsers you attempted to reproduce this bug on (the more the merrier): n/a
  • Does the problem persist after removing "assets/node_modules" and trying again? Yes/no: yes

Actual behavior

Formatter should format all code in a single pass that will then be accepted by mix format --check-formatted

(related to #3544)

Expected behavior

Formatter has to be run twice to get code to a state where it passes the check.

Example

starting code:

  def input(%{type: "select"} = assigns) do
    ~H"""
    <select>
      <option :if={@prompt} value="" class="dark:!text-white">{@prompt}</option>
      <!-- TODO: set color to below options somehow -->
      {IdoWeb.SlimSelectForm.options_for_select(@options, @value, "dark:!text-white")}
    </select>
    """
  end

with mix.format:

  def input(%{type: "select"} = assigns) do
    ~H"""
    <select>
      <option :if={@prompt} value="" class="dark:!text-white">{@prompt}</option>
      <!-- TODO: set color to below options somehow -->
      {IdoWeb.SlimSelectForm.options_for_select(@options, @value, "dark:!text-white")}

    </select>
    """
  end

(and mix format --check-formatted will error:

 396  396  |      {IdoWeb.SlimSelectForm.options_for_select(@options, @value, "dark:!text-white")}
 397  397  |
      398 +|
      399 +|
 398  400  |    </select>
 399  401  |    """
           |

If I run mix.format again, it will add those two extra lines that the check-formatted wants, and then everything passes.

If I remove the line with the TODO comment, the formatting works (and the blank lines before the </select> are removed.

@SteffenDE
Copy link
Collaborator

cc @josevalim (and maybe @feliperenan)

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

No branches or pull requests

2 participants