Skip to content

Add ESLint rules for cross-platform path normalization#3

Merged
jdutton merged 1 commit into
mainfrom
feat/eslint-path-normalization-rules
Jan 29, 2026
Merged

Add ESLint rules for cross-platform path normalization#3
jdutton merged 1 commit into
mainfrom
feat/eslint-path-normalization-rules

Conversation

@jdutton

@jdutton jdutton commented Jan 29, 2026

Copy link
Copy Markdown
Owner

Summary

Adds three new custom ESLint rules to catch cross-platform path operation issues during development, before they reach CI.

These rules were proven effective in vibe-agent-toolkit, where they caught real Windows CI failures related to path separator mismatches.

New Rules

1. no-manual-path-normalize

  • Detects: Manual path normalization like .split(path.sep).join('/')
  • Suggests: Use toForwardSlash() from @ts-monorepo-template/example-utils
  • Auto-fix: Replaces manual normalization with utility call

2. no-path-sep-in-strings

  • Detects: Using path.sep in string operations (split(), includes(), etc.)
  • Prevents: Platform-specific separator issues (Windows \\ vs Unix /)
  • Suggests: Normalize paths with toForwardSlash() before string operations

3. no-path-operations-in-comparisons

  • Detects: Path operations in string comparisons without normalization
  • Example: content.includes(path.relative(baseDir, file)) fails on Windows
  • Requires: Wrap path operations with toForwardSlash() before comparisons

Benefits

  • Shift-left: Catch cross-platform issues at lint-time, not in CI
  • Agentic-friendly: Prevent AI from reintroducing unsafe patterns
  • Auto-fix: First rule includes auto-fix for quick remediation
  • Proven: Ported from production use in vibe-agent-toolkit

Validation

All checks passed:

  • Build: ✅
  • TypeScript: ✅
  • ESLint: ✅ (no violations found)
  • Duplication: ✅
  • Tests: ✅

Related

Ported from vibe-agent-toolkit commit 3506451 which fixed Windows CI failures.

🤖 Generated with Claude Code

Add three new custom ESLint rules to catch path operation issues before CI:

1. no-manual-path-normalize: Detects manual .split(path.sep).join('/')
   - Suggests using toForwardSlash() utility instead
   - Auto-fix replaces manual normalization with utility call

2. no-path-sep-in-strings: Prevents using path.sep in string operations
   - Catches split(), includes(), indexOf(), etc. with path.sep
   - Prevents platform-specific separator issues

3. no-path-operations-in-comparisons: Requires normalizing path operations
   - Detects path.relative/dirname/basename/join in string comparisons
   - Prevents Windows backslash vs. Unix forward slash mismatches

These rules shift-left cross-platform path bugs from CI to lint time.

Ported from vibe-agent-toolkit where they caught real Windows CI failures.
All validation passed: lint, typecheck, tests, duplication check.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jan 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.54%. Comparing base (b03eb02) to head (3edeb1f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #3   +/-   ##
=======================================
  Coverage   85.54%   85.54%           
=======================================
  Files           2        2           
  Lines          83       83           
  Branches       17       17           
=======================================
  Hits           71       71           
  Misses         12       12           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@jdutton jdutton merged commit 056259a into main Jan 29, 2026
9 checks passed
@jdutton jdutton deleted the feat/eslint-path-normalization-rules branch January 29, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant