Commit Graph

4 Commits

Author SHA1 Message Date
leaysgur a38f7b3d57 fix(oxlint,oxfmt): apply .gitignore only to walk targets, not explicitly named files (#25531)
Possibly fixes #25259, and partial revert of #25133.

---

- `.gitignore` applies only to discovery (walking directory targets, cwd, globs)
- An explicitly named file target is linted / formatted even when gitignored
  - = Restoring the pre-[#25133]() behavior for files, while fully keeping the [#25107]() fix for walk roots

| Target | Current | This PR |
| --- | --- | --- |
| Explicit file (`oxlint dist/a.js`) | skipped | linted |
| Explicit directory (`oxlint dist`) | skipped | skipped |
| cwd inside ignored tree | skipped | skipped |

The underlying principle:

> `.gitignore` is a message addressed to git, not to tools.
> Borrowing it to scope discovery is a useful heuristic, and a heuristic may narrow what the walk finds, but never refuse what the user names.
> Only tool's own ignore config can refuse. (which remain hard for the husky staged-file case).

This also re-aligns the CLI with stdin and LSP, which deliberately do not consult `.gitignore` (#19206).
👉🏻 This is the main motivation.

### Why not full revert

A directory target names where to search, not what to process.
The files under it are still discovered by the walk, so discovery rules apply.
Reverting that would bring back [#25107](), whose old behavior was not even a statable spec: whether running inside an ignored tree processed anything depended on the ignore pattern's form (bare `generated` did, `generated/**` didn't), an artifact of walker pruning, not a design.

### Regarding to `--no-ignore`

This flag remains orthogonal as a walk-level opt-out (`--no-ignore=vcs dist`) and for filling gap between existing tools.

However, with explicit files working again, I'm inclined to close those PRs and revisit if demand shows up.

For [#25259]()'s use case: name the files, e.g. `oxlint dist/foo.js` (or shell-expanded glob).
2026-08-14 03:35:34 +00:00
leaysgur 5f685f1961 test(oxfmt): Show generated .gitignore in the tree snapshot (#22208) 2026-05-07 06:20:06 +00:00
leaysgur c9b4db9ff7 test(oxfmt): Rework test/cli tests (#21463)
Switch to a fixture-based testing approach, similar to apps/oxlint.
2026-04-15 09:13:40 +00:00
leaysgur 1a02f6ee8c test(oxfmt): Arrange test files and directries (#17822)
Sorry for the large diff! 🙇🏻

But it's mostly just file relocations (and path updates).
Details on the changes are also documented in [`AGENTS.md`](https://github.com/oxc-project/oxc/pull/17822/changes#diff-b9a8ddc83e0b93133df7274e37b5fcdaec808090721eec2194782fe968819e69), so please refer to that file.

TL;DR: I wanted to colocate test cases and fixtures in the same directory.
2026-01-09 15:11:35 +00:00