Open phoshenwen opened 3 years ago
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) :thinking:
I think it is maybe a deprecated feature from jade? If so I will not support it :slightly_frowning_face: sorry for that.
Otherwise please provide my
echo
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 :thinking:
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
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 :thinking:
Feel free to close this issue or discuss further with me about how I can help you :slightly_smiling_face:
Info
Prettier config
Input
Output or Error
missing semicolon after 'echo'
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 ...'