NOTE: I'll do a self-review and add the test tomorrow.
<details>
<summary>Prompt</summary>
```
# Support `vite.config.*` as a Configuration File
## Target Files
- `vite.config.ts`
- `vite.config.mts`
- `vite.config.cts`
- `vite.config.js`
- `vite.config.mjs`
- `vite.config.cjs`
## Auto-Discovery Priority
When searching for a config file from `cwd` upwards, the following priority applies within the same directory:
1. Tool-specific JSON/JSONC config files (e.g. `.oxfmtrc.json`, `.oxlintrc.json`)
2. Tool-specific JS/TS config files (e.g. `oxfmt.config.ts`, `oxlint.config.ts`)
3. `vite.config.*`
## Extracting Configuration
The default export of `vite.config.*` is expected to contain tool-specific configuration under a dedicated field:
- oxfmt: `.fmt`
- oxlint: `.lint`
If the field does not exist, an error is returned (e.g. `Expected a 'fmt' field in the default export.`).
## Explicit `--config` Flag
When `--config vite.config.ts` is explicitly specified, the same behavior applies. The file name is used to determine whether to extract a nested field.
## LSP
`vite.config.*` files are added to the file watch patterns so that configuration changes trigger a reload.
```
</details>
### Overview
Part of #16608
This PR applies `oxc_formatter` to the js-in-vue section.
However, it is not complete and is only applied to the following parts within js-in-vue:
- `script` block
- and `generic="..."`
- `v-for` LHS
- `v-slot`
In the `script` block, `external_callback` is used like a regular JS file, but it isn't for others.
TL;DR: Now you can use sort-imports for Vue files.
### Review points
The points I'd like to ask your review are the following:
- Addition of `format_node()` to `oxc_formatter`
- Made it possible to process any type that implements `Format`, not just `Program`
- The implementation of `js-in-vue` fragment was separated as much as possible to avoid impacting existing code
- `oxc_formatter` IR to prettier `Doc`
### TODOs
- [x] Planning
- [x] Implementation
- [x] Check benchmark
- [x] Check coverage
- [x] Understand & refactor
- [x] oxfmt: JS side
- [x] oxfmt: Rust side
- [x] oxfmt: to_doc.rs
- [x] oxc_formatter: fragment_format
- [x] Check benchmark again
- [x] Check coverage again
- [x] Check ecosystem-ci
- [x] Tests 👉🏻#19563
- `experimentalSortImports` 👉🏻 `sortImports`
- `experimentalSortPackageJson` 👉🏻 `sortPackageJson`
- `experimentalTailwindcss` 👉🏻 `sortTailwindcss`
To avoid breaking changes, the old name is retained as an alias.
Fixes#19264
The original issue only mentioned `modifiers`, but I've implemented `selector` as well.
While the original implementation also supports more attributes, I believe this is sufficient for now.
Fixes#18726
Support glob matching instead of prefix matching.
The original used regex, but there was no necessity for it, and this approach offers better performance.
In any case, it will be a braking change.
```js
// before: Matches react, reactify, react-router, etc
"elementNamePattern": ["react"]
// after: Matches react only
// before: Matches loot-core, loot-core/foo, etc
"elementNamePattern": ["loot-core"]
// after: Matches only loot-core, should update to
"elementNamePattern": ["loot-core/*"]
```
Fixes#13705
- Support glob patterns like `*.js`, `**/*.ts`, and `{a,b}.js` in CLI paths
- Globs are pre-expanded to make `ignore` crate respects `.gitignore`
- Existing cases that don't use glob will NOT be affected in terms of performance
This also fixes bug that `oxfmt a.js a.js` formats the same file 2 times 🙈
Added Biome-to-oxfmt configuration migration, based on the Prettier
implementation.
I wasn't sure if I should exclude settings that match oxfmt's defaults
from the generated config, but I'm happy to do so if you’d like
Fixes `ignorePatterns` not working when `--config` is specified with a `..` path (e.g., `--config ../../.oxfmtrc.json`)
Canonicalize the joined path via `fs::canonicalize()` in `normalize_relative_path()`.
Fix for the issue where the code passing settings from `oxfmt` to `oxc_formatter` was missing.
- Also added tests
- Also fixed the TS type that was missing
This PR adds support for embedded language formatting in
styled-components and styled-jsx patterns:
## Changes
- [x] **Support ``styled.div`...` `` tagged templates**: Allow
formatting of tagged templates with member expressions like
`styled.div`, enabling better support for styled-components
- [x] **Support ``styled["computed"]`...` ``**: Handle static computed
member expressions in styled tags
- [x] **Support ``styled(Component)`...` ``**: Handle styled calls with
component arguments for styled-components
- [x] **Support ``<div css={`...`} />``**: Format CSS content in JSX
`css` prop
- [x] **Support ``<style jsx>{`...`}</style>``**: Format Styled JSX
content in JSX elements
## Related Issues
- Part of #15180
## Known Limitations
- **Template substitution is not supported**: Expressions inside
template literals like `` css`color: ${THIS_VAR};` `` are not yet
supported
---------
Co-authored-by: Dunqing <dengqing0821@gmail.com>
Fixes#17948 and may fix `next.js` repo diffs. => Confirmed all xxx-in-js diffs are resolved ✨
---
When Prettier fails to format embedded code (e.g., valid `css` tag but with invalid content), the previous implementation returned the original code as a successful result.
This caused issues because `block_indent` is always added (assuming Prettier has normalized root indentation).
As a result, indentation/newlines grow infinitely on each format run.