Skip to content

Add a lint rule specifically for ember-modifier modifiers to not destructure arguments, as they can lead to backtracking re-render assertions #2346

@NullVoxPopuli

Description

@NullVoxPopuli

We want tracked property access to be as lazy as possible, and typically when we're using modifiers that add event listeners, we don't care to consume that tracked data until much later -- like when the listened events fire -- so consuming the tracked data should be held off until then.

Example (bad):

modifier((element, [text]) => {
  element.addEventListener('hover', () => console.log(text));
});

Example (good):

modifier((element, positional) => {
  element.addEventListener('hover', () => console.log(positional[0]))
});

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