lint: reduce scope

Fix some lint warnings of kind
```
style (variableScope): The scope of the variable '…' can be reduced
```
In the above code you strip the `else { <code> }` to `<code>`, because the `if (err)` returns anyways if it's true.
For the sake of consistency I'd either do the same here or leave the above `else { <code> }` in.