Skip to content

Commit 2648215

Browse files
fix(scripts): accepts the token (YYYY-MM-dd) in frontmatter validation (#133)
# Pull Request ## Description Updated the validation logic in `scripts/linting/Validate-MarkdownFrontmatter.ps1` to support the `(YYYY-MM-dd)` placeholder token in the `ms.date` field. ## Related Issue(s) Closes #130 ## Type of Change Select all that apply: **Code & Documentation:** - [ ] Bug fix (non-breaking change fixing an issue) - [x] New feature (non-breaking change adding functionality) - [ ] Breaking change (fix or feature causing existing functionality to change) - [ ] Documentation update **Infrastructure & Configuration:** - [ ] GitHub Actions workflow - [x] Linting configuration (markdown, PowerShell, etc.) - [ ] Security configuration - [ ] DevContainer configuration - [ ] Dependency update **AI Artifacts:** - [ ] Reviewed contribution with `prompt-builder` chatmode and addressed all feedback - [ ] Copilot instructions (`.github/instructions/*.instructions.md`) - [ ] Copilot prompt (`.github/prompts/*.prompt.md`) - [ ] Copilot chatmode (`.github/chatmodes/*.chatmode.md`) **Other:** - [x] Script/automation (`.ps1`, `.sh`, `.py`) - [ ] Other (please describe): ## Testing I performed the following manual tests to verify the changes: 1. **Reproduction**: Created a temporary file `docs/test-fail.md` with `ms.date: (YYYY-MM-dd)` and confirmed it failed validation before the fix. ``` ./scripts/linting/Validate-MarkdownFrontmatter.ps1 🔍 Validating frontmatter across markdown files... Searching for markdown files in specified paths... Found 30 total markdown files to validate ::warning file=/workspaces/hve-core/README.md::Invalid date format: Expected YYYY-MM-DD (ISO 8601), got: (2025-11-05) ::warning file=/workspaces/hve-core/docs/templates/templates/tmp/test-fail.md::Invalid date format: Expected YYYY-MM-DD (ISO 8601), got: (2025-06-06) ⚠️ Warnings found: Invalid date format in: /workspaces/hve-core/README.md. Expected YYYY-MM-DD (ISO 8601), got: (2025-11-05) Invalid date format in: /workspaces/hve-core/docs/templates/templates/tmp/test-fail.md. Expected YYYY-MM-DD (ISO 8601), got: (2025-06-06) ✅ Frontmatter validation completed successfully ✅ All frontmatter validation checks passed! ``` 3. **Verification**: Ran `Validate-MarkdownFrontmatter.ps1` after applying the regex change. * Result: The file with `(YYYY-MM-dd)` passed validation successfully. ```pws ./scripts/linting/Validate-MarkdownFrontmatter.ps1 🔍 Validating frontmatter across markdown files... Searching for markdown files in specified paths... Found 30 total markdown files to validate ✅ Frontmatter validation completed successfully ✅ All frontmatter validation checks passed! 4. **Regression Testing**: Verified that files with standard ISO dates (e.g., `2025-12-05`) still pass validation. 5. **Cleanup**: Removed the temporary test file before committing. ## Checklist ### Required Checks - [ ] Documentation is updated (if applicable) - [x] Files follow existing naming conventions - [x] Changes are backwards compatible (if applicable) ### AI Artifact Contributions <!-- If contributing a chatmode, prompt, or instruction, complete these checks --> - [ ] Used `prompt-builder` chatmode to review contribution - [ ] Addressed all feedback from `prompt-builder` review - [ ] Verified contribution follows common standards and type-specific requirements ### Required Automated Checks The following validation commands must pass before merging: - [x] Markdown linting: `npm run lint:md` - [x] Spell checking: `npm run spell-check` - [x] Frontmatter validation: `npm run lint:frontmatter` - [x] Link validation: `npm run lint:md-links` - [x] PowerShell analysis: `npm run lint:ps` ## Security Considerations <!-- ⚠️ WARNING: Do not commit sensitive information such as API keys, passwords, or personal data --> - [x] This PR does not contain any sensitive or NDA information - [x] Any new dependencies have been reviewed for security issues - [x] Security-related scripts follow the principle of least privilege
1 parent 4538a03 commit 2648215

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/linting/Validate-MarkdownFrontmatter.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,10 @@ function Test-FrontmatterValidation {
747747
}
748748
}
749749

750-
# Validate date format (ISO 8601: YYYY-MM-DD)
750+
# Validate date format (ISO 8601: YYYY-MM-DD) or placeholder (YYYY-MM-dd)
751751
if ($frontmatter.Frontmatter.ContainsKey('ms.date')) {
752752
$date = $frontmatter.Frontmatter['ms.date']
753-
if ($date -notmatch '^\d{4}-\d{2}-\d{2}$') {
753+
if ($date -notmatch '^(\d{4}-\d{2}-\d{2}|\(YYYY-MM-dd\))$') {
754754
$warningMsg = "Invalid date format in: $($file.FullName). Expected YYYY-MM-DD (ISO 8601), got: $date"
755755
$warnings += $warningMsg
756756
[void]$filesWithWarnings.Add($file.FullName)
@@ -865,10 +865,10 @@ function Test-FrontmatterValidation {
865865
}
866866
}
867867

868-
# Validate date format for docs
868+
# Validate date format (ISO 8601: YYYY-MM-DD) or placeholder (YYYY-MM-dd) for docs
869869
if ($frontmatter.Frontmatter.ContainsKey('ms.date')) {
870870
$date = $frontmatter.Frontmatter['ms.date']
871-
if ($date -notmatch '^\d{4}-\d{2}-\d{2}$') {
871+
if ($date -notmatch '^(\d{4}-\d{2}-\d{2}|\(YYYY-MM-dd\))$') {
872872
$warnings += "Invalid date format in: $($file.FullName). Expected YYYY-MM-DD (ISO 8601), got: $date"
873873
[void]$filesWithWarnings.Add($file.FullName)
874874
Write-GitHubAnnotation -Type 'warning' -Message "Invalid date format: Expected YYYY-MM-DD (ISO 8601), got: $date" -File $file.FullName

0 commit comments

Comments
 (0)