Commit 3f0aa1b
authored
fix(linting): use cross-platform path separators in gitignore pattern matching (#121)
## Description
Updated the PowerShell linting helpers to use platform-appropriate path
separators, enabling proper gitignore exclusion behavior in Linux-based
dev container environments.
- **fix**(_linting_): Updated `Get-GitIgnorePatterns` function to use
`[System.IO.Path]::DirectorySeparatorChar` instead of hardcoded
backslashes
- Normalizes input patterns by replacing both `/` and `\` with the
platform separator
- Wildcard patterns now correctly match on both Windows and Unix systems
- **refactor**(_linting_): Replaced inline gitignore parsing in
`Validate-MarkdownFrontmatter.ps1` with call to shared
`Get-GitIgnorePatterns` helper
- Removed 24 lines of duplicate code
- Ensures consistent gitignore behavior across all linting scripts
## Related Issue(s)
Fixes #120
## Type of Change
**Code & Documentation:**
- [x] Bug fix (non-breaking change fixing an issue)
- [ ] 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
**Other:**
- [x] Script/automation (`.ps1`, `.sh`, `.py`)
## Testing
- Validated with PSScriptAnalyzer (exit code 0, no issues)
- Cross-platform path separator logic verified using
`[System.IO.Path]::DirectorySeparatorChar`
## Checklist
### Required Checks
- [x] Documentation is updated (if applicable)
- [x] Files follow existing naming conventions
- [x] Changes are backwards compatible (if applicable)
### Required Automated Checks
- [ ] Markdown linting: `npm run lint:md`
- [ ] Spell checking: `npm run spell-check`
- [ ] Frontmatter validation: `npm run lint:frontmatter`
- [ ] Link validation: `npm run lint:md-links`
- [x] PowerShell analysis: `npm run lint:ps`
## Security Considerations
- [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
## Additional Notes
This fix addresses an issue where gitignore patterns using hardcoded
Windows backslashes (`\`) failed to match paths on Linux systems in the
dev container. The solution uses .NET's `DirectorySeparatorChar` for
platform detection and normalizes patterns accordingly.
🐛 - Generated by Copilot1 parent 57ef20d commit 3f0aa1b
2 files changed
Lines changed: 12 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
165 | 170 | | |
166 | | - | |
| 171 | + | |
167 | 172 | | |
168 | | - | |
169 | | - | |
| 173 | + | |
| 174 | + | |
170 | 175 | | |
171 | 176 | | |
172 | | - | |
| 177 | + | |
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
504 | | - | |
505 | | - | |
| 504 | + | |
506 | 505 | | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
| 506 | + | |
529 | 507 | | |
530 | 508 | | |
531 | 509 | | |
| |||
0 commit comments