Commit dba6ce7
Kapil Borle
Apply NewLineAfter option only for if-else clause
This constrains the behavior of PlaceCloseBrace rule when NewLineAfter option is set to true. Previously, if this option is set to true, the rule will trigger on any close brace that is not followed by a new line except if the close brace is part of a command element AND script block expression. This caused the rule to be too aggressive. We illustrate two such instances.
In the following instance the rule would add a new line between the close brace and the comma following it, which makes the command expression invalid.
```powershell
Some-Command -Param1 @{
key="value"
},@{
key="value"
}
```
would get formatted to
```powershell
Some-Command -Param1 @{
key="value"
}
,@{
key="value"
}
```
In the following instance the rule would add a new line between the close brace and the parameter following it, which again makes the command expression invalid.
```powershell
Some-Command -Param1 @{
key="value"
} -Param2
```
would get formatted to
```powershell
Some-Command -Param1 @{
key="value"
}
-Param2
```1 parent 8e3e68a commit dba6ce7
1 file changed
+2
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
318 | | - | |
319 | | - | |
| 317 | + | |
| 318 | + | |
320 | 319 | | |
321 | | - | |
322 | 320 | | |
323 | 321 | | |
324 | 322 | | |
| |||
0 commit comments