Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Multi-line EEX comment causes error #46

Open
jonleighton opened this issue May 11, 2021 · 1 comment
Open

Multi-line EEX comment causes error #46

jonleighton opened this issue May 11, 2021 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@jonleighton
Copy link

This works fine:

<%# This works %>

This causes an error:

<%#
This fails
%>

With this error:

Checking formatting...
path/to/test.html.eex** (SyntaxError) nofile:1: syntax error before: fails
    (elixir) lib/code.ex:538: Code.format_string!/2
    (prettier_eex_formatter) lib/CLI.ex:103: PrettierEexFormatter.CLI.run_formatter/2
    (elixir) lib/enum.ex:1327: Enum."-map/2-lists^map/1-0-"/2
    (prettier_eex_formatter) lib/CLI.ex:14: PrettierEexFormatter.CLI.main/1
    (elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2
[error] path/to/test.html.eex: Error: Command failed: [snip]/assets/node_modules/prettier-plugin-eex/prettier_eex_formatter_release ClRoaXMgZmFpbHM= --line-length=98
[error] ** (SyntaxError) nofile:1: syntax error before: fails
[error]     (elixir) lib/code.ex:538: Code.format_string!/2
[error]     (prettier_eex_formatter) lib/CLI.ex:103: PrettierEexFormatter.CLI.run_formatter/2
[error]     (elixir) lib/enum.ex:1327: Enum."-map/2-lists^map/1-0-"/2
[error]     (prettier_eex_formatter) lib/CLI.ex:14: PrettierEexFormatter.CLI.main/1
[error]     (elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2
[error]
[error]     at checkExecSyncError (child_process.js:616:11)
[error]     at execSync (child_process.js:652:15)
[error]     at formatEex ([snip]/assets/node_modules/prettier-plugin-eex/lib/formatter.js:35:5)
[error]     at Object.print ([snip]/assets/node_modules/prettier-plugin-eex/lib/printers.js:23:27)
[error]     at callPluginPrintFunction ([snip]/assets/node_modules/prettier/index.js:14718:18)
[error]     at [snip]/assets/node_modules/prettier/index.js:14649:47
[error]     at Object.printComments ([snip]/assets/node_modules/prettier/index.js:14305:19)
[error]     at printGenerically ([snip]/assets/node_modules/prettier/index.js:14649:22)
[error]     at printAstToDoc ([snip]/assets/node_modules/prettier/index.js:14659:13)
[error]     at coreFormat ([snip]/assets/node_modules/prettier/index.js:14910:15)
All matched files use Prettier code style!

Also, "All matched files use Prettier code style!" is incorrectly outputted. However since 0.5.0 there is now a non-zero exit code after this error, which is correct.

Decoding the base64 string gives:

\nThis fails

So I think the comment text is getting interpreted as Elixir code.

@jonleighton
Copy link
Author

A workaround seems to be to prepend a # onto the line:

<%#
# This works
%>

@adamzapasnik adamzapasnik added bug Something isn't working enhancement New feature or request labels May 11, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants