Closed Standard8 closed 6 years ago
As each <script>...code...</script>
is linted separately, considered as a separate file, so I can't insert comments anywhere.
A quirky solution could be to patch the context object to add a method .getOriginalHTMLMarkup()
?
Thanks for the comment, I'll take a look. It might be that I can actually use just context.getFilename() and load/parse myself. I'll poke around a bit.
I've had a look, and I've got something working based on context.getFilename(), and scanning the file just for the script tags. That's simple enough that I'm happy. Thank you for the idea to look at context a bit more.
Nice! sorry for the answer delay.
For a rule I'm working on, I'd like to be able to detect imported scripts, so that I can go and look them (mainly for working out about globals, unfortunately we don't yet have a proper module import system in use). We have a work around, but that involves manually duplicating the items imported via the scripts tags into comments.
Unfortunately, eslint-plugin-html strips out all the useful html code before I get to it (context.getSourceCode().getText() just returns the javascript), and I'd rather not go and open the file again.
Would it be possible to get a comment inserted in the code passed to ESLint? e.g.
// script src="..." type="..."
I took a very brief look, but haven't yet worked out if/how this could be done.