Background
instructions/powershell.instructions.md mandates three rules for in-tree code:
- Literal string parameter values are single-quoted
- Cmdlet calls use named parameters (when more than one argument is passed)
- Every function parameter has an appropriate validator
PR #23 brought the template's first-party files into compliance (build.ps1, the example {{Prefix}} module source, scaffold tests, helper modules) but explicitly deferred Initialize-Template.ps1 because it's a one-shot init script with very different shape and risk profile, and folding it into that PR would have ballooned the scope.
This issue tracks closing the gap.
What needs to change
Audit Initialize-Template.ps1 for:
- Unquoted string literals in cmdlet parameter values — e.g.,
-Path foo → -Path 'foo'
- Multi-arg cmdlet calls using positional parameters — e.g.,
Split-Path -Parent $x → Split-Path -Path $x -Parent
param() blocks missing [ValidateNotNull*] / [ValidateRange] / [ValidateSet] validators
Write-Verbose / Write-Output / similar single-arg calls — these can stay positional per the documented rule (only multi-arg calls require naming)
Verification
- Parse-check the file before/after with
[Parser]::ParseFile
- Exercise
Initialize-Template.ps1 end-to-end (clone → run init → confirm a usable scaffolded module) to catch any behavioural regression
- PSScriptAnalyzer should remain clean
Reference
PR #23 (this PR) and tablackburn/JsmOperations#2 show the canonical shape of these changes applied to other code.
Background
instructions/powershell.instructions.mdmandates three rules for in-tree code:PR #23 brought the template's first-party files into compliance (
build.ps1, the example{{Prefix}}module source, scaffold tests, helper modules) but explicitly deferredInitialize-Template.ps1because it's a one-shot init script with very different shape and risk profile, and folding it into that PR would have ballooned the scope.This issue tracks closing the gap.
What needs to change
Audit
Initialize-Template.ps1for:-Path foo→-Path 'foo'Split-Path -Parent $x→Split-Path -Path $x -Parentparam()blocks missing[ValidateNotNull*]/[ValidateRange]/[ValidateSet]validatorsWrite-Verbose/Write-Output/ similar single-arg calls — these can stay positional per the documented rule (only multi-arg calls require naming)Verification
[Parser]::ParseFileInitialize-Template.ps1end-to-end (clone → run init → confirm a usable scaffolded module) to catch any behavioural regressionReference
PR #23 (this PR) and
tablackburn/JsmOperations#2show the canonical shape of these changes applied to other code.