Skip to content

update ember/no-get fixer to support firstObject/foo.0.bar scenarios #1835

@hmajoros

Description

@hmajoros

when firstObject / lastObject / .0. are part of a string path inside a get, the fixer treats these as properties, where in reality these are ember syntax from array prototype extensions. These paths should either be ignored entirely, or changed to use array access.

// original 
get(this, 'foo.firstObject.bar')

// bad ❌
this.foo.firstObject.bar;

// good ✅
this.foo[0].bar;

Same applies for lastObject and array based access foo.0.bar, which are all ember-specifics.

we have 2 options:

  1. update the fixer to ignore any path containing firstObject / lastObject / .0.
  2. update the fixer to convert these paths into array access like mentioned above.

could even do a combination of the above where they are only fixed if you specify a new configuration option like handleEmberArrayPrototypes

@lin-ll @bmish any thoughts here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions