Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hmajoros opened this issue Apr 17, 2023 · 1 comment · Fixed by #1841
Closed

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

hmajoros opened this issue Apr 17, 2023 · 1 comment · Fixed by #1841
Labels

Comments

@hmajoros
Copy link
Contributor

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?

@bmish bmish added the Bug label Apr 17, 2023
@bmish
Copy link
Member

bmish commented Apr 17, 2023

Yeah I think we can update the fixer to properly fix this without the deprecated Ember array syntax.

hmajoros pushed a commit to hmajoros/eslint-plugin-ember that referenced this issue Apr 18, 2023
hmajoros pushed a commit to hmajoros/eslint-plugin-ember that referenced this issue Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants