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

Unexpected end of input while parsing echo #99

Closed csoutham closed 4 months ago

csoutham commented 4 months ago

Linting seems to be tripping up over any translatable output that has HTML in it, for instance:

{!! __('I agree with the <a href="https://domain.com/privacy-policy">privacy policy</a>.') !!}

It seems to be specifically the unescaped tag {!! !!} as switching the above to {{ }} passes without failure. Additionally switching quotes for single quotes also fails.

{!! __("I agree with the <a href='https://domain.com/privacy-policy'>privacy policy</a>.") !!}

Would appreciate some feedback if this is just a configuration issue?

.prettierrc

{
  "printWidth": 160,
  "semi": true,
  "singleQuote": true,
  "tabWidth": 4,
  "trailingComma": "all",
  "htmlWhitespaceSensitivity": "ignore",
  "plugins": [
    "prettier-plugin-blade",
    "prettier-plugin-tailwindcss"
  ],
  "overrides": [
    {
      "files": [
        "*.blade.php"
      ],
      "options": {
        "parser": "blade"
      }
    }
  ]
}

.blade.format.json

{
  "useLaravelPint": true,
  "spacesAfterDirective": 1,
  "spacesAfterControlDirective": 1,
  "phpOptions": {
    "singleQuote": true,
    "phpVersion": "8.3"
  }
}
JohnathonKoster commented 4 months ago

Thanks for the report! You're configuration is fine. The root cause was a parser error seeing the // in the URL and assuming it was the start of a PHP comment and getting itself confused.

This has ben corrected in 2.1.13 👍