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

Enhancement - no-get rule and auto-fix #1840

Closed
ArtixZ opened this issue Apr 20, 2023 · 2 comments · Fixed by #1865
Closed

Enhancement - no-get rule and auto-fix #1840

ArtixZ opened this issue Apr 20, 2023 · 2 comments · Fixed by #1865

Comments

@ArtixZ
Copy link
Contributor

ArtixZ commented Apr 20, 2023

As is mentioned here in the test file, we currently don't identify or auto-fix get on a non-string. This means when the non-string is a variable name, we deem it as valid.

This ticket propose that we identify and auto-fix for those use cases.

Expectations:

obj.get(5) ===> obj[5] // obj.get(5) is legal as I tested.

obj.get(foo) ===> obj[foo]

@ArtixZ ArtixZ changed the title New no-get rule and auto-fix Enhancement - no-get rule and auto-fix Apr 20, 2023
@ArtixZ
Copy link
Contributor Author

ArtixZ commented Apr 20, 2023

Incoporating the bug mentioned in #1835, here is the list of examples of new enhancements should be added:

obj.get(5) ===> obj[5] // obj.get(5) is legal as I tested.

obj.get(foo) ===> obj[foo]

obj.get('firstObject') ===> obj[0]

obj.get('lastObject') ===> obj[obj.length - 1]

foo1 === foo2 ? obj.get('bar') : obj.get('baz') ===> foo1 === foo2 ? obj.bar : obj.baz

@bmish
Copy link
Member

bmish commented Apr 21, 2023

Great, would love to autofix additional cases that we can safely fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants