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

Bug: Missing semicolon after 'echo' (php in jade) #257

Open
phoshenwen opened this issue Jul 21, 2021 · 3 comments
Open

Bug: Missing semicolon after 'echo' (php in jade) #257

phoshenwen opened this issue Jul 21, 2021 · 3 comments

Comments

@phoshenwen
Copy link

phoshenwen commented Jul 21, 2021

Info

Tool Version
Plugin v1.16.1
Prettier v2.3.2
Framework none
Node v16.5
OS win

Prettier config

{
    "endOfLine": "crlf",
    "printWidth": 100,
    "proseWrap": "always",
    "singleQuote": true,
    "tabWidth": 4
}

Input

- echo get_field("hero_content");

Output or Error

missing semicolon after 'echo'

SyntaxError: Missing semicolon. (1:5)
> 1 | echo get_field("hero_content"); 

Expected Output

no error

Additional Context

I don't know if it makes a difference, but I am using this plugin with .jade as the file extension (rather than .pug).

When running npx prettier --write "./_jade/front-page.jade" I am seeing the error. There should NOT be a semicolon after echo.

PS: Same thing happens with '- require ...'

@Shinigami92
Copy link
Member

The pug lexer can parse this somehow and returns

[
  {"type":"code","loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":34}},"val":"echo get_field(\"hero_content\");","mustEscape":false,"buffer":false},
  {"type":"newline","loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}}},
  {"type":"eos","loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}}}
]

As you can see it recognize the hot part as type code
This code is then passed to the babel prettier processor by my plugin. But echo get_field("hero_content"); is not valid JS (as far as I know) 🤔

I think it is maybe a deprecated feature from jade? If so I will not support it 🙁 sorry for that.

Otherwise please provide my

  1. A bit more context about this echo
  2. Some more code examples, so I can harden the test suite with these

Nevertheless, it seems that this just produces a warning and not an error, so I assume the rest of the file gets formatted as wanted? So maybe you need to life with that and just ignore the warnings 🤔

@phoshenwen
Copy link
Author

I'm compiling the jade files to PHP via gulp and gulp-jade-php. The echo statement comes from vanilla PHP and prints the result of the get_field() function which is simply a string. Another equivalent example would be a simple line of - require '/test.php';

But I'm getting the feeling that this wasn't meant for php to begin with

@Shinigami92
Copy link
Member

I am really sad that I cannot help you from my part, cause IMO this is not only the special case of the deprecated usage of jade, but also the assumption that php is involved but js syntax is assumed.
But if you like, you are welcome to try to create a PR on your own. Maybe you can create an option to toggle a flag or something like that 🤔

Feel free to close this issue or discuss further with me about how I can help you 🙂

@Shinigami92 Shinigami92 changed the title Bug: Missing semicolon after 'echo' Bug: Missing semicolon after 'echo' (php in jade) Jul 23, 2021
@Shinigami92 Shinigami92 added wontfix The issue is expected and will not be fixed and removed wontfix The issue is expected and will not be fixed labels Jul 30, 2021
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