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

Update `binding-positions` rule for Lit v2

Open stramel opened this issue 3 years ago • 2 comments

In Lit v2 you can achieve some of these invalid binding positions by using import { html } from 'lit/static-html.js'; .

We should probably warn about the binding positions if they're not utilizing the static html function.

https://lit.dev/docs/api/static-html/ https://lit.dev/docs/templates/expressions/#expression-locations https://lit.dev/docs/templates/expressions/#static-expressions

stramel avatar May 17 '21 20:05 stramel

Same issue with no-invalid-html, when trying to use e.g. the code from the lit docs

  render() {
    return html`
      <${this.tag} ${this.activeAttribute}?=${this.active}>
        <p>${this.caption}</p>
      </${this.tag}>`;
  }

Results in

Template contained invalid HTML syntax, error was: invalid-first-character-of-tag-name eslint lit/no-invalid-html

aboutsimon avatar May 05 '22 11:05 aboutsimon

that one in particular is because our placeholders are currently comments except in the case of attributes, then they are placeholder attributes.

we need to implement better placeholder/substitution to account for tags/attributes/etc.

i was hoping peter on the lit team would finish the analyzer he started building first, so we could just use the same analysis here.

43081j avatar May 06 '22 14:05 43081j