BenoitZugmeyer / eslint-plugin-html

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

may you add .jsp ? #67

Closed biehu closed 7 years ago

biehu commented 7 years ago

code: <%-- --%> error: error Parsing error: Unexpected token %

BenoitZugmeyer commented 7 years ago

I can't, in fact. There is no way to support template tags in JS code. For example:

<script>
var foo = <%= bar %>;
</script>

To make sure that "bar" is a valid JS expression, we have to evaluate the JSP code. My advice is to cheat a little bit, like this:

<script>
var foo;
// <%= "\nfoo = " + bar %>
</script>

Or if you want a comment

<script>
// <%-- This is a comment --%>
</script>

(This is probably not valid JSP code, but I hope you get the idea)