lit-analyzer icon indicating copy to clipboard operation
lit-analyzer copied to clipboard

Diagnostic idea: error to bind to the same property on the same element twice

Open rictic opened this issue 3 years ago • 1 comments

It's almost definitely a mistake (and it confuses Lit at runtime) to write:

  <div .id=${this.id} .id=${this.id}></div>

Example of one way that it can confuse Lit at runtime:

https://lit.dev/playground/#project=W3sibmFtZSI6InNpbXBsZS1ncmVldGluZy50cyIsImNvbnRlbnQiOiJpbXBvcnQge2h0bWwsIGNzcywgTGl0RWxlbWVudH0gZnJvbSAnbGl0JztcbmltcG9ydCB7Y3VzdG9tRWxlbWVudCwgcHJvcGVydHl9IGZyb20gJ2xpdC9kZWNvcmF0b3JzLmpzJztcblxuQGN1c3RvbUVsZW1lbnQoJ3NpbXBsZS1ncmVldGluZycpXG5leHBvcnQgY2xhc3MgU2ltcGxlR3JlZXRpbmcgZXh0ZW5kcyBMaXRFbGVtZW50IHtcbiAgcmVuZGVyKCkge1xuICAgIHJldHVybiBodG1sYDxwIC5pZD0keydmb28nfSAuaWQ9JHsnYmFkJ30-SGVsbG8gJHsnd29ybGQnfSE8L3A-YDtcbiAgfVxufVxuIn0seyJuYW1lIjoiaW5kZXguaHRtbCIsImNvbnRlbnQiOiI8IURPQ1RZUEUgaHRtbD5cbjxoZWFkPlxuICA8c2NyaXB0IHR5cGU9XCJtb2R1bGVcIiBzcmM9XCIuL3NpbXBsZS1ncmVldGluZy5qc1wiPjwvc2NyaXB0PlxuPC9oZWFkPlxuPGJvZHk-XG4gIDxzaW1wbGUtZ3JlZXRpbmcgbmFtZT1cIldvcmxkXCI-PC9zaW1wbGUtZ3JlZXRpbmc-XG48L2JvZHk-XG4ifV0

rictic avatar Apr 30 '21 20:04 rictic

I can do this, just the same way i did it in eslint-plugin-lit. but that would ideally need #144 first so we stop relying on any and workaround types and can have the missing error handler types to catch duplicate attribute errors

43081j avatar May 06 '21 20:05 43081j