p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

convert-to-for-of-loop / convert-to-foreach-loop linting and refactoring not working. #9

Closed chandan192 closed 2 years ago

chandan192 commented 2 years ago

Hi @lgrammel, Linting for convert-to-for-of-loop / convert-to-foreach-loop is not showing. Also, no refactoring option is available for to convert simple for loop to for-of loop.

image

lgrammel commented 2 years ago

Hi @chandan192 - thanks for the bug report. I was able to reproduce the issue and will look into a fix.

lgrammel commented 2 years ago

This is because record[i] is inlined. If you extract it into its own variable, the refactoring will become available. I'll look into extending the refactoring, so that the extraction is not necessary.

lgrammel commented 2 years ago

Hey @chandan192 - I finally got around to implementing your idea. It is available in version 1.71.0 and higher. Thanks for the suggestion!