- Extract "known divergences" section from `AGENTS.md` to explicit `DIVERGENCES.md` with code example
- Update all anchors
- Add missing pinned fixtures
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).
Prettier uses the `conditionalGroup` IR for JS and YAML.
When this appeared in JS(containing `conditionalGroup`)-in-HTML(`script` tags)-in-JS (`oxc_formatter`), we previously bypassed the `Doc` to IR conversion.
This PR adds support for this conversion and removes the string format fallback path.
Pure renaming.
- `DispatchOutcome` -> `DispatchResponse` (counter part of `DispatchRequest`)
- `DispatchResult` -> `DispatchPayload` (lives in `DispatchResponse`)
As JSDoc is always contained within the ` * ` fenced comments, the `printWidth` option should not have been used as is.
The dedicated `jsdocPrintWidth` option has not yet been implemented. #24633
Consolidated the criteria for determining which languages are handled by?
- natively by Rust
- passed to Prettier
when formatting embedded code, as these were previously scattered across various places.
Due to historical reasons, the IR was passed as `[Doc, (Doc, ...Doc)]` only when processing `gql-in-js`, whilst for other cases such as `css-in-js` and `html-in-js`, it was always `[Doc]`.
Now, every result is single `Doc`.
- dispatcher
- string_embedder
- tailwind_sorter
Group these 3 together as `SessionServices`, make them available to `FormatSession`, and pass them around.
Previously, as Prettier was required for embedded formatting, so embedding was only supported in `napi` builds.
However, as the number of rewritten Rust components has increased recently, we have enabled embedded formatting in `pure` builds as well, thereby reducing the scope of the `napi` gate.
- Fork `apollo-rs` to be compatible with Prettier(`latest` for now)
- https://github.com/leaysgur/apollo-rs
- By doing this, Prettier fallback is no longer needed
- And now all prettier_conformance are passed, no parse error skip
> [!WARNING]
> TODO: Move fork under `oxc-project` org and replace refs
- Removed last remaining Prettier fallback path for css-in-js failure case
- In our Rust formatter host paths, Prettier is not used for CSS/LESS/SCSS anymore
- Before this PR: If `sortTailwindcss` option is enabled for CSS/LESS/SCSS, it was formatted by Prettier
- After this PR: `oxc_formatter_css` also handles `sortTailwindcss` as like `oxc_formatter` does
In addition to basic embedded (e.g. css-in-js), JSDoc also contain code fence as markdown.
This PR makes JSDoc code fence also formatted by `oxc_formatter_(css|graphql)` if specified.
- Use `oxc_formatter_css` from Oxfmt to handle CSS/LESS/SCSS files
- css-in-js is also handled by `oxc_formatter_css`
- But it will fallback to Prettier if formatting failed
- No fallback for no-embedded path
- At the point of this PR, it will fallback to Prettier when tailwind is required to format
NOTE: Both fallback will be removed in later PR.
In that sense, as a result of this series of PRs, Oxfmt's CSS support will no longer be 100% compatible compared to Prettier.
Since the parsers used are also different, it will no longer be possible to support certain postcss-plugin-specific syntax, invalid syntax or legacy syntax.
> [!WARNING]
> TODO: Move fork under `oxc-project` org and replace refs
- To use `oxc_formatter_graphql` in gql-in-js context, ground level refactoring was needed
- Extracted common logic for handling embeddings into `oxc_formatter_core`
- Updated other `xxx-in-js` callers to reflect these changes
- Added a `format_to_ir()` method to each formatter in addition to the existing `format()` method
- Use `oxc_formatter_graphql` from Oxfmt to handle `.gql` and `.graphql` files
- At point of this PR, gql-in-js is still handled by Prettier
As described in #23317, Prettier supports more syntax than ours, so for now fallback to Prettier when `oxc_formatter_graphql` failed to format.
NOTE: This fallback will be removed in later PR.
- Normalized tests that were ambiguous as to whether they were fixtures or scenarios based
- Specified this rule in AGENTS.md
- Made the test name report in the CLI clearer
Before this PR, `Oxfmtrc` was defined in `oxc_formatter` to avoid the circular reference `oxc_language_server` > `oxfmt` > `oxc_language_server`....
But now, `oxc_language_server` does not depend on `Oxfmtrc` since LSP implementation has moved to `apps/oxfmt`.
Therefore, by this PR, `Oxfmtrc` is moved to its proper location, in `apps/oxfmt`.
- Moved `Oxfmtrc` from `oxc_formatter` to `apps/oxfmt`
- Re-exposed from `apps/oxfmt`
- Now only `tasks/website_formatter` depends on it
- Also aligned JSON schema generation with `oxlint` by `just formatter-schema-json`
NOTE: In `oxc_formatter`, there are 2 places (`ir_transform` and `fixtures` tests) where we manually convert options from JSON. I'd like to fix this too in the future.