43081j / eslint-plugin-lit

lit-html support for ESLint
120 stars 22 forks source link

False positive when url contains query string #66

Closed bramkragten closed 2 years ago

bramkragten commented 4 years ago

When you have a template like:

html`<a href="/?query=${query}">Link</a>`

It will give the following errors:

Template contained invalid HTML syntax, error was: missing-whitespace-between-attributes eslint(lit/no-invalid-html)

Template contained invalid HTML syntax, error was: unexpected-character-in-attribute-name eslint(lit/no-invalid-html)
43081j commented 4 years ago

You should probably be doing:

html`<a href=${`/?query=${query}`}>Link</a>`;

so lit understands you're interpolating a value. im not sure how lit deals with trying to interpolate part of a value like that, maybe it understands it fine..

as for the error though regardless, its the html parser we use giving that. ill take a look either way when i get chance

danielvanmil commented 2 years ago

+1

danielvanmil commented 2 years ago

It looks like lit-html/element allows this and so it seems correct:

Example in the playground

43081j commented 2 years ago

yup sorry i took so long to get back to this, ill try have a look into this weekend.

you're right, it should work fine