BenoitZugmeyer / eslint-plugin-html

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

Script tags embedded in strings cause parsing errors #115

Closed Standard8 closed 5 years ago

Standard8 commented 5 years ago

Description

Run eslint on a test html file:

<html>
  <head>
    <script>
    function test() {
      document.write('<script>test();</script>');
    }
    </script>
  </head>
</html>

ESLint fails with:

docshell/test/mochitest/file_bug540462.html
  5:22  error  Parsing error: Unterminated string constant  (eslint)

It should pass (or at least report "normal" errors).

Setup configuration

BenoitZugmeyer commented 5 years ago

This is not valid HTML/JS. See this codepen: the output shows whats after the end of the script tag instead of running the document.write. Either use XML + CDATA or replace the script end tag with something like '</scr'+'ipt>'

Standard8 commented 5 years ago

Oh yes, sorry I forgot about that.