Skip to content

fix(oxlint): v1.36.0 file discovery regression#17513

Closed
hirehamir wants to merge 1 commit into
oxc-project:mainfrom
hirehamir:fix/v1.36.0-oxlint-file-discovery-regression
Closed

fix(oxlint): v1.36.0 file discovery regression#17513
hirehamir wants to merge 1 commit into
oxc-project:mainfrom
hirehamir:fix/v1.36.0-oxlint-file-discovery-regression

Conversation

@hirehamir

Copy link
Copy Markdown
Contributor

Fixes #17510

@hirehamir
hirehamir requested a review from camc314 as a code owner December 30, 2025 21:41
Copilot AI review requested due to automatic review settings December 30, 2025 21:41
@github-actions github-actions Bot added A-linter Area - Linter A-cli Area - CLI C-bug Category - Bug labels Dec 30, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a file discovery regression introduced in v1.36.0 where oxlint would find 0 files when walking subdirectories. The root cause was the .require_git(false) configuration, which caused the walker to traverse upward and apply parent directory .gitignore patterns (like /*.js) incorrectly to subdirectory files.

Key changes:

  • Removed .require_git(false) from the walker configuration to prevent upward traversal and incorrect application of parent .gitignore patterns
  • Changed .git_ignore(true) to .git_ignore(!options.no_ignore) to make git ignore behavior consistent with the --no-ignore CLI option
  • Added regression test to verify subdirectory file discovery works correctly
  • Marked previous test for .require_git(false) functionality as ignored, with explanation of why the feature was disabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/oxlint/src/walk.rs Outdated
Comment thread apps/oxlint/src/walk.rs Outdated
Comment thread apps/oxlint/src/walk.rs Outdated
@hirehamir
hirehamir force-pushed the fix/v1.36.0-oxlint-file-discovery-regression branch from 9dee628 to 7b1b62c Compare December 30, 2025 21:51
@hirehamir
hirehamir requested a review from Copilot December 30, 2025 21:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/oxlint/src/walk.rs Outdated
Comment on lines +183 to +184
// This test must run from within the oxc repo to reproduce the bug, since it relies
// on finding the real .gitignore in the parent directory structure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do we have a way to reproduce this bug that doesn't rely on the gitignore at the root of the repo? It'd be goofy to change that and break tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. I'll see if I can push up something to address this shortly.

@hirehamir
hirehamir force-pushed the fix/v1.36.0-oxlint-file-discovery-regression branch from 7b1b62c to 276d984 Compare December 30, 2025 22:19
@camc314

camc314 commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

i don't understand how this fixes the isssue? what's the root cause?

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't feel like a proper fix - can you explain the setup with your gitignore files and why you've got them if you're not inside a git repo?

@hirehamir

Copy link
Copy Markdown
Contributor Author

this doesn't feel like a proper fix - can you explain the setup with your gitignore files and why you've got them if you're not inside a git repo?

Sure. I might have a different setup than some people. I have a .gitignore file in my home directory that ignores everything, and then adds back specific files, like

.bashrc

Then, in my home directory, I have different Git repositories with their own

.gitignore

files. It was in one of these Git repositories in my home directory that the original issue occurred.

@hirehamir

Copy link
Copy Markdown
Contributor Author

Hope this helps:

/home/hamir/
  .gitignore      ← Contains * to ignore everything, and then !.bashrc
  .git/           ← Home is a Git repo for dotfile management
  my-project/     ← My project (nested inside home dir) where
    .git/           `npx oxlint .` incorrectly runs on 0 files with v1.36.0
    src/             but not v1.35.0
      file.ts

@connorshea

Copy link
Copy Markdown
Member

Hmm, if we can't easily fix this by ignoring .gitignore files outside the current project (since there's not really any way to determine what "outside" is if there's no git repo. Unless we assume the cwd is the root of the project?), should we just straight-up error out if the user doesn't have a git repo initialized?

@hirehamir

Copy link
Copy Markdown
Contributor Author

I think this is what was happening...

With .require_git(false) (buggy v1.36.0):

  • Walker starts at my-project/
  • Traverses past my-project/.git/ (ignores Git boundaries)
  • Finds .gitignore with * pattern
  • Filters out everything
  • Result: 0 files ❌

Without .require_git(false) (this fix):

  • Walker starts at my-project/
  • Looks for .git going upward
  • Finds my-project/.git/ and stops there (respects Git boundary)
  • Only uses .gitignore files within my-project/
  • Never looks at ~/.gitignore
  • Result: Files found correctly ✅

@camc314

camc314 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

@hamirmahal can you try #17813 and see if that fixes your issue? thanks

@hirehamir

Copy link
Copy Markdown
Contributor Author

You're welcome, and thanks for looking into this. I think the approach that's there right now fixes things.

@hirehamir

Copy link
Copy Markdown
Contributor Author
$ git branch && cargo run --bin oxlint ~/test/
  c/01-08-fix_linter_skip_looking_for_ignore_files_in_parent_directories
* main
   Compiling oxlint v1.38.0 (/home/hamir/oxc/apps/oxlint)
    Finished `dev` profile [unoptimized] target(s) in 8.23s
     Running `target/debug/oxlint /home/hamir/test/`
Found 0 warnings and 0 errors.
Finished in 16ms on 0 files with 90 rules using 8 threads.
$ git branch && cargo run --bin oxlint ~/test/
* c/01-08-fix_linter_skip_looking_for_ignore_files_in_parent_directories
  main
   Compiling oxlint v1.38.0 (/home/hamir/oxc/apps/oxlint)
    Finished `dev` profile [unoptimized] target(s) in 8.10s
     Running `target/debug/oxlint /home/hamir/test/`

  × eslint(no-unused-vars): Variable 'testArray' is declared but never used. Unused variables should start with a '_'.
   ╭─[/home/hamir/test/src/test.ts:1:7]
 1 │ const testArray = []
   ·       ────┬────
   ·           ╰── 'testArray' is declared here
   ╰────
  help: Consider removing this declaration.

Found 0 warnings and 1 error.
Finished in 22ms on 1 file with 90 rules using 8 threads.

@hirehamir

Copy link
Copy Markdown
Contributor Author

@camc314 I think #17813 seemed to work the last time I tried it, do you want me to check it again?

@hirehamir
hirehamir deleted the fix/v1.36.0-oxlint-file-discovery-regression branch May 1, 2026 23:18
@camc314

camc314 commented May 2, 2026

Copy link
Copy Markdown
Contributor

massive apologies for the delay on this, but thank you for submitting this PR!

I think i've fixed this in a slightly more ideal way, in #22033, that maintains the previous behaviour, while allowiing .gitignores in non-git initialized directories.

The fix should be released on Monday (May 4th) (or possibly tuesday due to the holiday) - please try it and let me know!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npx oxlint . checks 26 files with Version: 1.31.0 but 0 files with Version: 1.36.0

4 participants