Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive when using static expressions #211

Open
hampoelz opened this issue Aug 22, 2024 · 3 comments
Open

False positive when using static expressions #211

hampoelz opened this issue Aug 22, 2024 · 3 comments

Comments

@hampoelz
Copy link

hampoelz commented Aug 22, 2024

The following minimal code triggers the rules "lit/binding-positions" and "lit/no-invalid-html", although it should be completely valid according to the lit documentation (https://lit.dev/docs/templates/expressions/#static-expressions).

import { html, literal, StaticValue } from 'lit/static-html.js';

const tag: StaticValue = literal`header`;
return html`<${tag} class="classes">Content</${tag}>`
@43081j
Copy link
Owner

43081j commented Aug 24, 2024

good catch

we explicitly don't allow tag bindings (from before lit allowed them)

this is a tough one to fix though. if we remove that, we'll be allowing all tag name bindings even though lit only supports ones which use literal

we can't easily detect if you're using literal either since we're only linting syntax, i.e. we don't have hold of the type checker etc. we could, but it'd then make this rule a typed rule (requires typescript to run)

would be good to get some opinions on this. i'd be tempted to just allow them all and hope the user knows what they're doing

@hampoelz
Copy link
Author

hampoelz commented Sep 1, 2024

The best solution would of course be to add typescript support as an optional config (for example lit/typescript), especially if there are other rules that would benefit from typescript.

Otherwise it would probably be enough to add a note to the docs stating that in this case the rules can be ignored and can be configured as warning.

@43081j
Copy link
Owner

43081j commented Sep 2, 2024

I agree

I wonder how easy it will be to check for the existence of tseslint in the parser services. Then if it exists, we do a more thorough check. Otherwise we allow all tag bindings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants