43081j / eslint-plugin-lit

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

no-property-change-update is incorrect #62

Closed LarsDenBakker closed 1 year ago

LarsDenBakker commented 4 years ago

no-property-change-update states that changing properties will not trigger a re-render. This is incorrect, as long as you're calling super last it works fine.

This change will be taken along properly:

class MyElement extends LitElement {
  update(changed) {
    this.foo = 'bar';
    super.update(changed);
  }
}

This won't:

class MyElement extends LitElement {
  update(changed) {
    super.update(changed);
    this.foo = 'bar';
  }
}

This is a prime use case for creating computed properties. Doing this in updated will trigger two renders for a single change. As it is I don't think it should be a linting rule, especially not a recommended one, because it will confuse developers.

Is it possible to detect the call to super? Then the rule would make sense.