43081j / eslint-plugin-lit

lit-html support for ESLint
115 stars 20 forks source link

fix(no-this-assign-in-render): explicit left hand side traversal #185

Closed 43081j closed 8 months ago

43081j commented 8 months ago

The esquery we were using was too wide in that it would match a .left at any level.

This meant the following code would match:

render() {
  x = this.foo || 123;
}

As a LogicalExpression has a left just like an AssignmentExpression.

Since esquery doesn't support relative direct child selection (i.e. using :has(> foo)), we are now selecting the left side node and reporting on the parent instead.