eslint-plugin-lit icon indicating copy to clipboard operation
eslint-plugin-lit copied to clipboard

False positive when url contains query string

Open bramkragten opened this issue 4 years ago • 4 comments

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)

bramkragten avatar Apr 21 '20 13:04 bramkragten

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

43081j avatar Apr 23 '20 12:04 43081j

+1

danielvanmil avatar Mar 22 '22 15:03 danielvanmil

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

Example in the playground

danielvanmil avatar Mar 22 '22 17:03 danielvanmil

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

43081j avatar Apr 02 '22 09:04 43081j