Skip to content

formatter: .gitignore not respected when executing oxfmt in a sub directory #22034

@camc314

Description

@camc314

What version of Oxfmt are you using?

Latest npm release via:

pnpm dlx oxfmt@latest --version

What command did you run?

Minimal repro:

https://github.com/camc314/oxfmt-gitignore-subdir-repro

Repro 1:

pnpm dlx oxfmt@latest --check dist

Repro 2:

cd apps
pnpm dlx oxfmt@latest --check

What happened?

oxfmt formats/checks files inside directories ignored by a parent .gitignore.

Repro structure:

.
├── .git/
├── .gitignore      # ignores dist/ and apps/dist/
├── dist/
│   └── unformatted.js
└── apps/
    └── dist/
        └── unformatted.js

.gitignore:

dist/
apps/dist/

Actual output includes ignored files:

dist/unformatted.js

Format issues found in above 1 files.

For the package-subdirectory case:

cd apps
pnpm dlx oxfmt@latest --check

also checks:

dist/unformatted.js

What did you expect to happen?

oxfmt should skip files ignored by parent .gitignore files inside the same Git repo.

In the examples above:

  • dist/unformatted.js should be skipped because root .gitignore ignores dist/
  • apps/dist/unformatted.js should be skipped when running from apps/ because root .gitignore ignores apps/dist/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions