Skip to content

Commit 08ec735

Browse files
Derive PSScriptAnalyzer settings from PowerShell standard; document GitHub Actions linters
1 parent 88a0715 commit 08ec735

5 files changed

Lines changed: 84 additions & 12 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# PSScriptAnalyzer settings — the enforcement mechanism for the PowerShell coding
2+
# standard (src/docs/Coding-Standards/PowerShell/index.md). The standard is the
3+
# source of truth; every rule configured here is derived from it. Change a rule by
4+
# changing the standard first, then reflect it here — never the other way around.
5+
#
6+
# super-linter discovers this file automatically as POWERSHELL_CONFIG_FILE
7+
# (.powershell-psscriptanalyzer.psd1) under .github/linters.
8+
@{
9+
# Run the full default rule set — approved verbs, singular nouns, alias bans,
10+
# $null-on-the-left comparisons, Invoke-Expression, unused variables, and the
11+
# rest — then tighten the formatting rules below to match the standard.
12+
IncludeDefaultRules = $true
13+
14+
# Gate on errors and warnings; both map to rules the standard requires.
15+
Severity = @('Error', 'Warning')
16+
17+
Rules = @{
18+
# One True Brace Style: opening brace on the statement line, closing brace
19+
# on its own line with no blank line before it. NewLineAfter stays false on
20+
# the close brace so else / elseif / catch / finally sit on the same line as
21+
# the preceding brace ("} else {"), as the standard requires.
22+
PSPlaceOpenBrace = @{
23+
Enable = $true
24+
OnSameLine = $true
25+
NewLineAfter = $true
26+
IgnoreOneLineBlock = $true
27+
}
28+
PSPlaceCloseBrace = @{
29+
Enable = $true
30+
NewLineAfter = $false
31+
IgnoreOneLineBlock = $true
32+
NoEmptyLineBefore = $true
33+
}
34+
35+
# Indent with four spaces, never tabs.
36+
PSUseConsistentIndentation = @{
37+
Enable = $true
38+
Kind = 'space'
39+
IndentationSize = 4
40+
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
41+
}
42+
43+
# One space around operators and after commas, and consistent brace and
44+
# parenthesis spacing.
45+
PSUseConsistentWhitespace = @{
46+
Enable = $true
47+
CheckInnerBrace = $true
48+
CheckOpenBrace = $true
49+
CheckOpenParen = $true
50+
CheckOperator = $true
51+
CheckPipe = $true
52+
CheckSeparator = $true
53+
}
54+
}
55+
}

.github/scripts/Test-DocumentationLink.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env pwsh
1+
#!/usr/bin/env pwsh
22
#Requires -Version 7.0
33

44
<#

.github/scripts/Update-DocumentationIndex.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ function Get-IndexTable {
112112
$rows.Add([pscustomobject]@{
113113
Order = if ($Order.ContainsKey($key)) { $Order[$key] } else { 10000 }
114114
Title = if ($meta.ContainsKey('title')) { $meta['title'] } else { $child.Name }
115-
Link = "$($child.Name)/index.md"
116-
Desc = if ($meta.ContainsKey('description')) { $meta['description'] } else { '' }
115+
Link = "$($child.Name)/index.md"
116+
Desc = if ($meta.ContainsKey('description')) { $meta['description'] } else { '' }
117117
})
118118
}
119119
foreach ($child in $files) {
@@ -122,8 +122,8 @@ function Get-IndexTable {
122122
$rows.Add([pscustomobject]@{
123123
Order = if ($Order.ContainsKey($key)) { $Order[$key] } else { 10000 }
124124
Title = if ($meta.ContainsKey('title')) { $meta['title'] } else { [System.IO.Path]::GetFileNameWithoutExtension($child.Name) }
125-
Link = $child.Name
126-
Desc = if ($meta.ContainsKey('description')) { $meta['description'] } else { '' }
125+
Link = $child.Name
126+
Desc = if ($meta.ContainsKey('description')) { $meta['description'] } else { '' }
127127
})
128128
}
129129

.github/scripts/Wait-CopilotReview.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ try {
132132
Select-Object -Last 1
133133

134134
$processing = $lastRequestedAt -and
135-
((-not $lastReviewedAt) -or ([datetimeoffset] $lastRequestedAt -gt $lastReviewedAt))
135+
((-not $lastReviewedAt) -or ([datetimeoffset] $lastRequestedAt -gt $lastReviewedAt))
136136

137137
if ($processing) {
138138
Write-Verbose "Copilot is already processing a review (requested $lastRequestedAt) - waiting for it."
@@ -219,13 +219,13 @@ try {
219219
}
220220

221221
[pscustomobject]@{
222-
Repository = $Repository
223-
PullRequest = $PullRequest
224-
ReviewState = $review.state
225-
SubmittedAt = $review.submittedAt
222+
Repository = $Repository
223+
PullRequest = $PullRequest
224+
ReviewState = $review.state
225+
SubmittedAt = $review.submittedAt
226226
NewCommentCount = $newComments.Count
227-
NewComments = $newComments
228-
Blessed = $blessed
227+
NewComments = $newComments
228+
Blessed = $blessed
229229
}
230230

231231
if ($blessed) {

src/docs/Coding-Standards/GitHub-Actions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,23 @@ appears.
258258
`main.<ext>` sits at the action root for a single-file action, or under `src/`
259259
as the entry point alongside the other modules.
260260

261+
## Toolchain
262+
263+
Two linters enforce this standard in CI, and their configuration is derived from
264+
it — the rules above are the source of truth:
265+
266+
- **[actionlint](https://github.com/rhysd/actionlint)** checks workflow
267+
correctness: expression syntax, job and step wiring, runner labels, and the
268+
shell of every `run:` step through shellcheck.
269+
- **[zizmor](https://docs.zizmor.sh/)** audits workflow security, flagging the
270+
failures this standard exists to prevent: unpinned actions, excessive
271+
`permissions`, template injection from untrusted input, `secrets: inherit`,
272+
and persisted credentials.
273+
274+
Both run through [super-linter](https://github.com/super-linter/super-linter) on
275+
every push and pull request, so a workflow that breaks this standard fails the
276+
build.
277+
261278
```text
262279
# Single-file action — main.<ext> at the action root
263280
.github/actions/link-check/

0 commit comments

Comments
 (0)