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

mix needs to use --stdin-filename to support non-elixir files like .heex #319

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LucianoLaratelli
Copy link

Hey, hope all is well.

I was seeing errors formatting .heex files from elixir-mode in *apheleia-apheleia-from-project-root-log*:

$ apheleia-from-project-root .formatter.exs mix format -

mix format failed for stdin
** (SyntaxError) invalid syntax found on stdin.exs:1:1:
    error: syntax error before: '<'
    │
  1 │ <html lang="en" class="[scrollbar-gutter:stable]">
    │ ^
    │
    └─ stdin.exs:1:1
    (elixir 1.17.2) lib/code.ex:999: Code.format_string!/2
    (mix 1.17.2) lib/mix/tasks/format.ex:649: Mix.Tasks.Format.elixir_format/2
    (mix 1.17.2) lib/mix/tasks/format.ex:668: Mix.Tasks.Format.format_file/2
    (elixir 1.17.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.17.2) lib/task/supervised.ex:36: Task.Supervised.reply/4

Looking through the help page for mix format, I saw:

`--stdin-filename' - path to the file being formatted on stdin. This is useful if you are using plugins to support custom filetypes such as .heex. Without passing this flag, it is assumed that the code being passed via stdin is valid Elixir code. Defaults to "stdin.exs".

This makes that change.

…heex`

I was seeing errors formatting `.heex` files from `elixir-mode`: 
```
$ apheleia-from-project-root .formatter.exs mix format -

mix format failed for stdin
** (SyntaxError) invalid syntax found on stdin.exs:1:1:
    error: syntax error before: '<'
    │
  1 │ <html lang="en" class="[scrollbar-gutter:stable]">
    │ ^
    │
    └─ stdin.exs:1:1
    (elixir 1.17.2) lib/code.ex:999: Code.format_string!/2
    (mix 1.17.2) lib/mix/tasks/format.ex:649: Mix.Tasks.Format.elixir_format/2
    (mix 1.17.2) lib/mix/tasks/format.ex:668: Mix.Tasks.Format.format_file/2
    (elixir 1.17.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.17.2) lib/task/supervised.ex:36: Task.Supervised.reply/4
```
Looking through the help page for `mix format`, I saw:
> `--stdin-filename' - path to the file being formatted on stdin. This is useful if you are using plugins to support custom filetypes such as .heex. Without passing this flag, it is assumed that the code being passed via stdin is valid Elixir code. Defaults to "stdin.exs".

This makes that change.
@LucianoLaratelli LucianoLaratelli changed the title mix needs to use --stdin-filename to support non-elixir files like …heex mix needs to use --stdin-filename to support non-elixir files like .heex Sep 18, 2024
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.

1 participant