BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
430 stars 51 forks source link

PHP opening tag inside javaScript script tags results in parse error. #75

Closed wowcut closed 7 years ago

wowcut commented 7 years ago

I have some code that looks like this:

<body>
  <script>
<?php 
...

which will produce parse errors with this plugin: Parsing error: Unexpected token ?

Yes, I know that is very ugly code and a bad practice, this is some abandoned legacy code and that is the reason why I really would love to use this plugin to check all the files with that ugly code without touching manually. Would be ignoring everything <?php ?> tags a good thing?

BenoitZugmeyer commented 7 years ago

It is not necessary a bad practice, don't worry! Just make sure to sanitize the generated script. Since it is a popular issue, I added a Troubleshooting section in the README. Sadly, you will have to edit the files manually. I can't blindly remove PHP tags, because: