It's funny, I don't think I was initially sold on the premise that aligned properties were easier to scan. But I definitely believe that it's easier to spot problems. Now with it being automatic in VScode, I don't think about it much.
Interesting article, thanks Mike!
Quick question:
What if I also want to assign a hashtable value to a variable?
I don't do it often, but sometimes I need a deep property and like to store it inside, like:
Region = $Region = $_.Foo.bar.barz
ShortRegion = $Region.Substring(0,5)
If I add a new key that has a long name, I will have to re-align the whole hash table which doesn't make a clean diff. That's the only reason I personally avoid alignment but I understand the benefits too👍
If you're using VScode the `powershell.codeFormatting.alignPropertyValuePairs` setting will do it for you automatically. When I was doing it by hand I hated aligning, but once the editor did it automatically I stopped thinking about.
Yea, you can ignore whitespace changes in GitHub. There's a diff tool a teammate shared (that I can't remember) which is supposed to be smart about ignoring stuff like this. But even better then whitespace, it can see that a rename happens and only highlight it once. No PS support yet.
Comments
Quick question:
What if I also want to assign a hashtable value to a variable?
I don't do it often, but sometimes I need a deep property and like to store it inside, like:
Region = $Region = $_.Foo.bar.barz
ShortRegion = $Region.Substring(0,5)
Unless I dreamt that being a thing