Skip to content

Commit 92da03e

Browse files
build(scripts): add linting infrastructure with npm scripts
- add package.json with lint:md, lint:ps, lint:links, spell-check scripts - migrate .markdownlint.json to .markdownlint-cli2.jsonc with ignores - add PowerShell linting scripts from hve-core pattern - add LintingHelpers module for GitHub Actions integration 🔧 - Generated by Copilot
1 parent 0936087 commit 92da03e

File tree

8 files changed

+1107
-145
lines changed

8 files changed

+1107
-145
lines changed

.markdownlint-cli2.jsonc

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"ignores": [
3+
"**/node_modules/**",
4+
".copilot-tracking/**",
5+
"venv/**"
6+
],
7+
"config": {
8+
"default": true,
9+
"extends": null,
10+
"MD001": true,
11+
"MD003": { "style": "consistent" },
12+
"MD004": { "style": "consistent" },
13+
"MD005": true,
14+
"MD007": { "indent": 2, "start_indented": false, "start_indent": 2 },
15+
"MD009": { "br_spaces": 2, "list_item_empty_lines": false, "strict": false },
16+
"MD010": { "code_blocks": true, "ignore_code_languages": [], "spaces_per_tab": 1 },
17+
"MD011": true,
18+
"MD012": { "maximum": 1 },
19+
"MD013": {
20+
"line_length": 500,
21+
"heading_line_length": 80,
22+
"code_block_line_length": 1200,
23+
"code_blocks": true,
24+
"tables": false,
25+
"headings": true,
26+
"strict": false,
27+
"stern": false
28+
},
29+
"MD014": true,
30+
"MD018": true,
31+
"MD019": true,
32+
"MD020": true,
33+
"MD021": true,
34+
"MD022": { "lines_above": 1, "lines_below": 1 },
35+
"MD023": true,
36+
"MD024": { "siblings_only": false },
37+
"MD025": { "level": 1, "front_matter_title": "^\\s*title\\s*[:=]" },
38+
"MD026": { "punctuation": ".,;:!。,;:!" },
39+
"MD027": true,
40+
"MD028": true,
41+
"MD029": { "style": "one_or_ordered" },
42+
"MD030": { "ul_single": 1, "ol_single": 1, "ul_multi": 1, "ol_multi": 1 },
43+
"MD031": { "list_items": true },
44+
"MD032": true,
45+
"MD033": { "allowed_elements": ["details", "summary"] },
46+
"MD034": true,
47+
"MD035": { "style": "consistent" },
48+
"MD036": { "punctuation": ".,;:!?。,;:!?" },
49+
"MD037": true,
50+
"MD038": true,
51+
"MD039": true,
52+
"MD040": { "allowed_languages": [], "language_only": false },
53+
"MD041": { "level": 1, "front_matter_title": "^\\s*title\\s*[:=]" },
54+
"MD042": true,
55+
"MD043": false,
56+
"MD044": { "names": [], "code_blocks": true, "html_elements": true },
57+
"MD045": true,
58+
"MD046": { "style": "consistent" },
59+
"MD047": true,
60+
"MD048": { "style": "consistent" },
61+
"MD049": { "style": "consistent" },
62+
"MD050": { "style": "consistent" },
63+
"MD051": { "ignore_case": false },
64+
"MD052": { "shortcut_syntax": false },
65+
"MD053": { "ignored_definitions": ["//"] },
66+
"MD054": {
67+
"autolink": true,
68+
"inline": true,
69+
"full": true,
70+
"collapsed": true,
71+
"shortcut": true,
72+
"url_inline": true
73+
},
74+
"MD055": { "style": "consistent" },
75+
"MD056": true,
76+
"MD058": true
77+
}
78+
}

.markdownlint.json

Lines changed: 0 additions & 145 deletions
This file was deleted.

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "azure-nvidia-robotics-reference-architecture",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Azure NVIDIA Robotics Reference Architecture",
6+
"scripts": {
7+
"spell-check": "cspell \"**/*.{md,ts,js,json,yaml,yml,py,sh}\"",
8+
"spell-check:fix": "cspell \"**/*.{md,ts,js,json,yaml,yml,py,sh}\" --show-suggestions",
9+
"lint:md": "markdownlint-cli2 \"**/*.md\"",
10+
"lint:md:fix": "markdownlint-cli2 \"**/*.md\" --fix",
11+
"lint:ps": "pwsh -File scripts/linting/Invoke-PSScriptAnalyzer.ps1",
12+
"lint:links": "pwsh -File scripts/linting/Invoke-LinkLanguageCheck.ps1",
13+
"lint:all": "npm run lint:md && npm run lint:ps && npm run lint:links",
14+
"format:tables": "markdown-table-formatter \"**/*.md\""
15+
},
16+
"devDependencies": {
17+
"cspell": "9.4.0",
18+
"markdown-link-check": "3.14.2",
19+
"markdown-table-formatter": "^1.6.0",
20+
"markdownlint-cli2": "^0.19.1"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/Azure-Samples/azure-nvidia-robotics-reference-architecture.git"
25+
},
26+
"author": "Microsoft",
27+
"license": "MIT"
28+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env pwsh
2+
#
3+
# Invoke-LinkLanguageCheck.ps1
4+
#
5+
# Purpose: Wrapper for Link-Lang-Check.ps1 with GitHub Actions integration
6+
7+
[CmdletBinding()]
8+
param()
9+
10+
Import-Module (Join-Path $PSScriptRoot "Modules/LintingHelpers.psm1") -Force
11+
12+
$repoRoot = git rev-parse --show-toplevel 2>$null
13+
if ($LASTEXITCODE -ne 0) {
14+
Write-Error "Not in a git repository"
15+
exit 1
16+
}
17+
18+
$logsDir = Join-Path $repoRoot "logs"
19+
if (-not (Test-Path $logsDir)) {
20+
New-Item -ItemType Directory -Path $logsDir -Force | Out-Null
21+
}
22+
23+
Write-Host "🔍 Checking for URLs with language paths..." -ForegroundColor Cyan
24+
25+
$jsonOutput = & (Join-Path $PSScriptRoot "Link-Lang-Check.ps1") 2>&1
26+
27+
try {
28+
$results = $jsonOutput | ConvertFrom-Json
29+
30+
if ($results -and $results.Count -gt 0) {
31+
Write-Host "Found $($results.Count) URLs with 'en-us' language paths`n" -ForegroundColor Yellow
32+
33+
foreach ($item in $results) {
34+
Write-GitHubAnnotation `
35+
-Type 'warning' `
36+
-Message "URL contains language path: $($item.original_url)" `
37+
-File $item.file `
38+
-Line $item.line_number
39+
}
40+
41+
$outputData = @{
42+
timestamp = (Get-Date).ToUniversalTime().ToString("o")
43+
script = "link-lang-check"
44+
summary = @{
45+
total_issues = $results.Count
46+
files_affected = ($results | Select-Object -ExpandProperty file -Unique).Count
47+
}
48+
issues = $results
49+
}
50+
$outputData | ConvertTo-Json -Depth 3 | Out-File (Join-Path $logsDir "link-lang-check-results.json") -Encoding utf8
51+
52+
Set-GitHubOutput -Name "issues" -Value $results.Count
53+
Set-GitHubEnv -Name "LINK_LANG_FAILED" -Value "true"
54+
55+
$uniqueFiles = $results | Select-Object -ExpandProperty file -Unique
56+
57+
Write-GitHubStepSummary -Content @"
58+
## Link Language Path Check Results
59+
60+
⚠️ **Status**: Issues Found
61+
62+
Found $($results.Count) URL(s) containing language path 'en-us'.
63+
64+
**Why this matters:**
65+
Language-specific URLs don't adapt to user preferences and may break for non-English users.
66+
67+
**To fix locally:**
68+
``````powershell
69+
scripts/linting/Link-Lang-Check.ps1 -Fix
70+
``````
71+
72+
**Files affected:**
73+
$(($uniqueFiles | ForEach-Object { $count = ($results | Where-Object file -eq $_).Count; "- $_ ($count occurrence(s))" }) -join "`n")
74+
"@
75+
76+
exit 1
77+
}
78+
else {
79+
Write-Host "✅ No URLs with language paths found" -ForegroundColor Green
80+
81+
$emptyResults = @{
82+
timestamp = (Get-Date).ToUniversalTime().ToString("o")
83+
script = "link-lang-check"
84+
summary = @{
85+
total_issues = 0
86+
files_affected = 0
87+
}
88+
issues = @()
89+
}
90+
$emptyResults | ConvertTo-Json -Depth 3 | Out-File (Join-Path $logsDir "link-lang-check-results.json") -Encoding utf8
91+
92+
Set-GitHubOutput -Name "issues" -Value "0"
93+
94+
Write-GitHubStepSummary -Content @"
95+
## Link Language Path Check Results
96+
97+
✅ **Status**: Passed
98+
99+
No URLs with language-specific paths detected.
100+
"@
101+
102+
exit 0
103+
}
104+
}
105+
catch {
106+
Write-Error "Error parsing results: $_"
107+
Write-Host "Raw output: $jsonOutput"
108+
exit 1
109+
}

0 commit comments

Comments
 (0)