We can discuss long time about good coding practices.
I think most important to know is what you scripted yourself and how it works.
Maybe rarely I would also declare a variable in a If/EndIf. But I would avoid reuse of that same variable name outside this If/EndIf, or shift the declaration one stage higher.