Skip to content

require-computed-property-dependencies mustn't handle assignment #785

@boris-petrov

Description

@boris-petrov

After updating eslint-plugin-ember to 8.3.0, I got a require-computed-property-dependencies error on similar code to this:

class extends Component {
  private fooIndex = -1;

  @computed('bar')
  public get foo(): any {
    this.fooIndex = 5;
    return this.bar;
  }
}

On the this.fooIndex = 5; line. This is wrong as that property must not be put in the computed's dependencies as it leads to an assertion failure:

Error: Assertion Failed: You attempted to update <frontend@component:something::ember1529>.fooIndex to "5", but it is being tracked by a tracking context, such as a template, computed property, or observer. In order to make sure the context updates properly, you must invalidate the property when updating it. You can mark the property as `@tracked`, or use `@ember/object#set` to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions