Skip to content

linter: .gitignore outside of git working tree is being picked up #19902

Description

@imawizard

What version of Oxlint are you using?

1.50.0

What command did you run?

npx oxlint

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
}

What happened?

My folders and files look like this:

  • ~ with
    • "*/" in .gitignore
  • ~/my-repo with
    • .git
    • src/foo.ts
    • ".DS_Store" in .gitignore

Expected behavior when running oxlint with ~/my-repo is that src/* gets linted, but running OXC_LOG=debug npx oxlint reports:

2026-03-02T05:15:37.432097Z DEBUG ignore::walk: ignoring ~/my-repo/src: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("~/.gitignore"), original: "*/", actual: "**/*", is_whitelist: false, is_only_dir: true })))

Which means that ~/.gitignore is being picked up, which, however, conflicts with https://git-scm.com/docs/gitignore#_description:

Patterns read from a .gitignore file in the same directory as the path, or in any parent directory (up to the top-level of the working tree)

So afaik this line should be changed/removed (attribute defaults to true):

.require_git(false)

Its docs also say:

/// Whether a git repository is required to apply git-related ignore
/// rules (global rules, .gitignore and local exclude rules).
///
/// When disabled, git-related ignore rules are applied even when searching
/// outside a git repository.
///
/// In particular, if this is false then .gitignore files will be read
/// from parent directories above the git root directory containing .git,
/// which is different from the git behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions