Skip to content

[eslint-changed] Fatal error on Windows when using --git #46163

@rznn7

Description

@rznn7

Impacted plugin

None / Other

Quick summary

The package fails on Windows systems when running with --git options, throwing a fatal Git error about paths existing on disk but not in the index.

Environment

  • OS: Windows (confirmed on 2 different laptops)
  • Package version: 2.1.4
  • Git: Git CLI (native Windows installation)
  • Context: Running via lint-staged in a pre-commit hook

Trace (run with lint-staged)

✔ Backed up original state in git stash (9bbcfe76e)
⚠ Running tasks for staged files...
  ❯ lint-staged.config.mjs — 1 file
    ❯ *.ts — 1 file
      ✔ node scripts/eslint-fix-silent.js
      ✖ npx @automattic/eslint-changed --git --ext .ts [FAILED]
      ◼ prettier --write
    ↓ *.html — no files
    ↓ *.{json,css,scss,md} — no files
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...
 
✖ npx @automattic/eslint-changed --git --ext .ts:
fatal: path 'app\src\app\path\to\file.ts' exists on disk, but not in the index
error: git exited with status 128
Error: lint-staged failed
husky - pre-commit script failed (code 1)

Steps to reproduce

  1. On a Windows system, create or modify a TypeScript file in a Git repository
  2. Stage the file: git add path/to/file.ts
  3. Run the command: npx @automattic/eslint-changed --git --git-unstaged --ext .ts

Expected Behavior

The tool should successfully lint the staged changes without errors, as it does on Linux.

Actual Behavior

The command fails with:

fatal: path 'app\src\app\path\to\file.ts' exists on disk, but not in the index
error: git exited with status 128

Site owner impact

Fewer than 20% of the total website/platform users

Severity

Minor

What other impact(s) does this issue have?

No revenue impact

Additional information

  • The same setup works perfectly on Linux
  • The error specifically occurs when Git is asked to interact with a path that uses Windows-style backslashes (\)
  • Git on Windows uses forward slashes (/) in its output, but the error message shows the path with backslashes
  • This suggests a path separator normalization issue between Git's output format and Windows file system operations

Platform (Simple and/or Atomic)

No response

Metadata

Metadata

Assignees

Type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions