Skip to content

Multi-line EEX comment causes error #46

@jonleighton

Description

@jonleighton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions