jwarby / i18n-lint

`i18n-lint` is a tool for detecting possible hardcoded strings in HTML and HTML-based template source files. It can be used a CLI utility, a library or a Grunt plugin.
http://jwarby.github.io/i18n-lint/
MIT License
50 stars 20 forks source link

Cant lint angular template wrapped in Script tag #5

Open achintverma opened 6 years ago

achintverma commented 6 years ago

It's not working with code like

<script type='ng-template'>
<h1>Heading Here</h1>
<a href='/about' title='About Us'>About</a>
</script>
achintverma commented 6 years ago

When I tried with --ignore-tags 'script' option then it shows weird output

jwarby commented 6 years ago

Hi @achintverma, script tags are ignored anyway by default, but in your case you actually want it to process script tags. However, the output will not be correct because the HTML parser will treat the script's content as text, not HTML. This is the output I get if I run without ignoring any tags (--ignore-tags "") on your provided sample:


  /tmp/test.html
     2 | <h1>Heading Here</h1>
         ^ Hardcoded <script> tag
     3 | <a href='/about' title='About Us'>About</a>
         ^ Hardcoded <script> tag (continued)

Although it looks like it's kind of working from the above output, I think it will actually report a problem for any tags it sees inside the script block.

To fix this, you would have to make it parse the script contents as HTML and run the linter over it - if you'd like to have a go at creating a pull request for this, please feel free to :) It's unlikely I will have any time to look at this for a while. Thanks!

achintverma commented 6 years ago

Thanks for the swift reply. I saw the similar output when I ignored script tags. Your explanation makes sense, can see why the output was like that. I'll Work on the solution and will submit PR in coming weeks. Thanks again!!

jwarby commented 6 years ago

@achintverma that would be awesome, thank you! :+1: