Stillat / blade-parser-typescript

A Laravel Blade parser, compiler, and static analyzer written in TypeScript.
https://stillat.com
MIT License
82 stars 2 forks source link

Validator issue with email #75

Closed driftingly closed 1 year ago

driftingly commented 1 year ago

I ran into a SyntaxError: Unpaired condition control structure issue while using the prettier plugin:

@if (true)
    test@example.com
@endif
resources/views/test.blade.php
[error] resources/views/test.blade.php: SyntaxError: Unpaired condition control structure
[error] 
[error]  >1| @if (true)
[error]   2|     test@example.com
[error]   3| @endif
[error]   4| 
[error] 
[error]     at Fa.preFormatter (/Users/anthony/Sites/testing/node_modules/prettier-plugin-blade/plugin.js:239:2118)
[error]     at Fa.formatDocument (/Users/anthony/Sites/testing/node_modules/prettier-plugin-blade/plugin.js:239:1002)
[error]     at Object.print (/Users/anthony/Sites/testing/node_modules/prettier-plugin-blade/plugin.js:250:5461)
[error]     at callPluginPrintFunction (/Users/anthony/Sites/testing/node_modules/prettier/index.js:8601:26)
[error]     at mainPrintInternal (/Users/anthony/Sites/testing/node_modules/prettier/index.js:8550:22)
[error]     at mainPrint (/Users/anthony/Sites/testing/node_modules/prettier/index.js:8537:18)
[error]     at printAstToDoc (/Users/anthony/Sites/testing/node_modules/prettier/index.js:8529:18)
[error]     at coreFormat (/Users/anthony/Sites/testing/node_modules/prettier/index.js:8837:20)
[error]     at formatWithCursor2 (/Users/anthony/Sites/testing/node_modules/prettier/index.js:9021:18)
[error]     at Object.formatWithCursor (/Users/anthony/Sites/testing/node_modules/prettier/index.js:38183:12)

I couldn't get many variations to work, but for some reason, this works:

@if (true)
    @foreach (["test@example.com"] as $email)
        {{ $email }}
    @endforeach
@endif
JohnathonKoster commented 1 year ago

Thanks for the report! I've transferred this issue to the correct repository, and will take a look sometime this week :)

driftingly commented 1 year ago

Thank you for all your hard work πŸ™Œ

JohnathonKoster commented 1 year ago

Corrected with the 1.6.11 release πŸ™‚

yaegassy commented 1 year ago

@JohnathonKoster Hi, The version of the stillat-blade-parser package itself, currently published in npm, is version 1.1.11. Could you update this as well?

JohnathonKoster commented 1 year ago

@yaegassy I've tagged a 1.2.0 release and published it that contains all of the changes since the last update πŸ™Œ

yaegassy commented 1 year ago

@JohnathonKoster Thank you. I have one point of concern. The size of the package seems to be very large, is that a problem?

JohnathonKoster commented 1 year ago

there have been quite a few changes since 1.1.11 that have impacted overall size (mainly to resolve formatting issues). I plan to investigate potential ways of splitting the parser and formatters in the future to reduce the bundle πŸ‘

yaegassy commented 1 year ago

Thanks for the reply. Once again, thank you for a great parser.