66 Commits
Author SHA1 Message Date
overlookmotel a76e5fd80d test(lexer): update just recipes to cover Neon implementation (#27705)
#27642 added an aarch64 Neon implementation of `classify`. So now we have 3 implementations.

Update `just ready-lexer` recipe to test and lint all 3.
2026-10-14 21:59:01 +00:00
sapphi-red 29e8c0cf81 perf(napi): enable Wasm 128bit SIMD Extension (#27179)
This was enabled in Rolldown (https://github.com/rolldown/rolldown/pull/4484), but wasn't enabled here.

Technically this is a breaking change as this will make the wasm not run in older browsers, but I think it's fine.

I noticed this because this was pointed out in https://x.com/_pi0_/status/2104617588550705201.
2026-09-29 08:01:49 +00:00
overlookmotel e18b83ed54 feat(lexer): require popcnt CPU feature for SIMD implementation (#26931)
Split out from #26919 to reduce the size of the diff on that PR.

That PR requires `popcnt` CPU feature for SIMD implementation. Alter all `#[cfg(...)]` blocks to include `target_feature = "popcnt"`.
2026-09-22 16:27:22 +00:00
overlookmotel 6365db964b test(lexer): enable oxc_lexer conformance tests on all platforms (#26263)
`oxc_lexer` has 2 implementations:

1\. SIMD-based on x86_64 with AVX2.
2\. Scalar/SWAR fallback which works on all platforms.

Both produce the same output.

This PR enables running the lexer conformance on either implementation. Which implementation is tested depends on what build flags are passed to `cargo coverage`.

It turns out that it's possible to test the SIMD implementation on Mac by compiling as x86_64, and running it under Rosetta 2.

This PR also adds `just` recipes to run tests and conformance on either implementation:

- `just test-lexer`
- `just test-lexer-simd`
- `just conformance-lexer`
- `just conformance-lexer-simd`

These commands should work correctly on any of Linux x86, Windows x86, Mac aarch64.
2026-09-03 10:59:05 +00:00
camchenry a685927916 feat(ci): add lint timings tracking (#24162)
Adds linter call count tracking to provide some durable evidence of call count reductions. This does not include the actual rule timings so that it is consistent across machines.
2026-07-04 17:43:39 +00:00
Connor Shea 312da18475 fix(ci): Add --workspace back to codecov command. (#18219)
Apparently it's necessary if you want to use `--exclude`.

Regression from #18187. e.g. see
https://github.com/oxc-project/oxc/actions/runs/21128701270/job/60754891058
2026-01-19 15:51:33 +08:00
Boshen 55ba98719f chore(rust): remove redundant --workspace flag from cargo commands (#18187)
## Summary
- Remove `--workspace` flag from cargo aliases in `.cargo/config.toml`
- Remove `--workspace` flag from CI workflow commands

The workspace has no `default-members` set, so cargo commands run from the workspace root already operate on all members by default, making `--workspace` redundant.

## Test plan
- CI will verify the changes work correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-01-18 14:56:04 +00:00
Boshen b1d3e005de chore(deps): upgrade napi to remove linker args that skip missing symbols (#15323) 2025-11-06 19:22:28 +08:00
Boshen 25ce9a1b00 fix(ci): fix linker issues on linux (#15327)
Attempt to get main to green before the bigger change in
https://github.com/oxc-project/oxc/pull/15323
2025-11-05 21:22:27 +08:00
Boshen 898d6fec12 feat(oxfmt): add embedded language formatting with Prettier integration (#14820)
## Summary

Adds support for formatting embedded languages (CSS, GraphQL, HTML, Markdown) in JavaScript/TypeScript template literals using Prettier via NAPI bindings.

## Motivation

JavaScript/TypeScript developers often embed CSS, GraphQL queries, HTML, and Markdown in their code using tagged template literals. Without proper formatting support, these embedded languages remain unformatted, leading to inconsistent code style and reduced readability.

This PR enables oxfmt to format these embedded languages using Prettier, providing a seamless formatting experience similar to Prettier's own embedded language support.

## Changes

### Core Functionality
- **Embedded language detection**: Recognizes `css`, `styled`, `gql`, `graphql`, `html`, `md`, and `markdown` template tags
- **Prettier integration**: Uses `@prettier/sync` for synchronous formatting of embedded code
- **NAPI bridge**: Rust-to-JavaScript interop using NAPI ThreadsafeFunction
- **Graceful fallback**: Returns original code if formatting fails or tag is unsupported

### Implementation Details

**Rust side** (`crates/oxc_formatter/`, `apps/oxfmt/src/prettier_plugins/`):
- New `EmbeddedFormatter` trait with callback-based API
- NAPI bindings using `FnArgs` pattern for clean multi-argument calls
- Template formatter enhancement to detect and format tagged templates
- Proper indentation handling: splits Prettier output into lines, uses `hard_line_break()` separators, wraps in `indent()` for context-aware indentation
- Arena allocator pattern to avoid borrow checker conflicts

**JavaScript side** (`apps/oxfmt/src-js/`):
- TypeScript bindings with clean signatures: `formatEmbeddedCode(tagName: string, code: string)`
- Prettier configuration: 80 char width, 2 space indent, semicolons, double quotes
- Tag-to-parser mapping for supported languages
- Error handling with console logging and fallback

**Testing**:
- E2E test suite using Vitest (8 test cases)
- Test fixtures for each supported language
- Snapshot testing with timing normalization for stability
- All tests passing consistently

## Examples

**Before** (unformatted):
```js
const styles = css`.button { color: red; background: blue; }`;
```

**After** (formatted with proper indentation):
```js
const styles = css`
  .button {
    color: red;
    background: blue;
  }
`;
```

**Supported tags:**
```js
// CSS
const styles = css`...`;
const component = styled`...`;

// GraphQL
const query = gql`...`;
const schema = graphql`...`;

// HTML
const template = html`...`;

// Markdown
const docs = md`...`;
const readme = markdown`...`;
```

## Testing

```bash
# Run oxfmt tests
just oxfmt

# Watch mode for development
just watch-oxfmt
```

All 8 E2E tests pass:
- ✓ embedded_css
- ✓ embedded_graphql
- ✓ embedded_html
- ✓ embedded_markdown
- ✓ mixed_embedded
- ✓ no_embedded
- ✓ unsupported_tag
- ✓ check_mode

## Related

Related to #13427

## Future Work

Potential enhancements:
- Support for additional embedded languages (SQL, YAML, etc.)
- Custom Prettier configuration via oxfmt config
- Performance optimization for large embedded blocks
- Integration with language servers for inline diagnostics
2025-11-03 02:05:35 +00:00
overlookmotel a47cb9ac4f fix(tools): fix just oxlint and just watch-oxlint (#14036)
Fix `just oxlint` and `just watch-oxlint`. They were broken because `oxlint` is now a NAPI package.

Remove `cargo oxlint` command, because `oxlint` needs to be built with NAPI-RS now.
2025-09-23 10:08:18 +00:00
overlookmotel 8fbb37e15f ci(coverage): fix Code Coverage CI task (#13970)
Fixes #13866.

Skip `tasks/website` in Code Coverage CI task, because it fails with
linker errors.
2025-09-21 21:54:58 +08:00
camchenry a744aff1d7 perf(linter): skip rules that do not have any relevant node types (#13138)
- part of https://github.com/oxc-project/oxc/issues/12223
- supersedes stack: https://github.com/oxc-project/oxc/pull/12228

This PR adds the ability to add node type information to indicate what node types a lint rule acts on. The lint rule runner can use this information to optimize running lint rules by skipping nodes, files, or rules that don't apply.

This is a simple version that is focused on creating the framework for automatically generating the rule runner code. This is not the end of optimizations. Currently only 102 rules have node type information, while 471 rules have no node type information and will not be skipped. Adding node type information for more rules will improve performance. We may also be able to skip more nodes and files by being clever about how we use this information. For example, filtering out any rules which do not run on any node type, if the file contains no relevant node types for the rule.

- Adds a new `RuleRunner` trait which includes information needed for indicating whether a rule has node type info or not
- Adds a `oxc_linter_codegen` task which is used to generate the implementation of `RuleRunner` trait for all lint rules. This is mostly written by AI, so worth a bit of skepticism, but I've tried to manually verify the results and it looks good (just lacking more complex detection).
  - Currently, only rules that contain a single top-level `if` statement (or chain of `else if`), or a single `match` statement will have their node type info generated. This should give us a high level of confidence, since these patterns are relatively easy to verify and identify, but it's only a subset of all rules. Next steps will be to add support for `let...else`
- Adjusts the main linting loop to use the node type information to skip rules for node types that don't apply
- Updates CI to include a check for any uncommitted linter codegen changes

---

## Benchmarks

In the latest version of this PR, CodSpeed shows an up to +13% increase in linter performance across large and small files. In the real-world, I've seen a ~5-15% improvement in performance, but in some cases close to zero for very small files. In either case, there appears to be little downside and a lot of potential upside here.

<img width="769" height="242" alt="Screenshot 2025-08-24 at 9 29 30 PM" src="https://github.com/user-attachments/assets/d2c430c4-17a9-4606-85d5-c66c734975d9" />
<img width="757" height="308" alt="Screenshot 2025-08-24 at 9 30 24 PM" src="https://github.com/user-attachments/assets/5508464f-de55-4f4e-9ddd-58f215c4ce85" />
<img width="976" height="368" alt="Screenshot 2025-08-24 at 9 34 52 PM" src="https://github.com/user-attachments/assets/203f83c7-46f3-49f1-a1a8-e18f7ec8483b" />
2025-09-08 03:22:26 +00:00
camchenry d79f4ec83a test(parser): track number of allocations (#12555)
- related: https://github.com/oxc-project/backlog/issues/5

This PR adds a reliable method of tracking the number of allocations made while running the parser. This includes both arena allocations (via a new feature), as well as system allocations (by creating a new global allocator). Reductions in these numbers should correlate to real-world performance improvements that aren't quantified in CodSpeed currently. This will also help prevent regressions where we accidentally allocate lots more memory than we expect.

Originally I had included total system bytes allocated, but it was tricky to get this number to match exactly between platforms. I opted not try and make this perfect but instead use the total number of allocations which is a good proxy for bytes anyway.
2025-08-06 05:38:03 +00:00
camc314 2f7cbdaac8 refactor(linter): move napi bindings out of oxc_linter (#12072)
Fix #12068.
2025-07-04 11:00:33 +00:00
camc314 f81d336ac5 feat(linter): introduce ExternalLinter struct (#12052) 2025-07-03 19:49:14 +00:00
Boshen 49324953f4 chore(oxlint): improve feature and build command (#10270)
Binary size reduced from `6.3M` to `5.8M` with this change.
2025-04-06 15:44:38 +00:00
Boshen a08ede79aa fix(napi): segfault when running napi-rs within a Node.js worker thread on gnu linux
closes #9054
2025-03-02 10:33:13 +08:00
Boshenandautofix-ci[bot] 1d81adac48 Rust Edition 2024 (#9289)
closes #9271

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-22 11:56:25 +08:00
Boshen 5d2028d2c1 ci: temporarily reset the broken napi .d.ts files (#9197) 2025-02-18 18:48:35 +08:00
overlookmotel d3ce88fa1c ci(benchmarks): fix and improve benchmarking commands (#9067)
* Fix `cargo benchmark` - previous it failed with an error.
* Add `just benchmark-one` to run a single benchmark e.g. `just
benchmark-one parser`.
* Simplify `default` feature in `tasks/benchmark/Cargo.toml`.
2025-02-12 21:11:17 +08:00
Boshenandautofix-ci[bot] 66cf26fe2c deps(rust): update Cargo.lock version from 3 to 4 (#9052)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-12 13:34:43 +08:00
Boshen a006955fcb build(rust): incompatible-rust-versions = "fallback" + cargo update (#8407) 2025-01-10 06:41:51 +00:00
Boshen bd977cf742 feat(oxc): add oxc_napi crate (#7612) 2024-12-03 14:02:47 +00:00
Boshen 7c62a33a06 feat(napi/parser): return esm info (#7602)
The parser now returns import / export statement information, which can be used for parser plugins.
2024-12-03 11:21:54 +00:00
Boshen 9076deefca feat(minifier): implement part of StatementFusion (#5936) 2024-09-21 09:24:01 +00:00
BoshenandBoshen 63a830e08c chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
overlookmotel bcd090af98 ci: run conformance with debug assertions (#4386)
Run conformance with debug assertions enabled to ensure `debug_assert!`s
pass.
2024-07-21 20:40:50 +08:00
overlookmotel 000d083c61 chore: format .cargo/config.toml (#4385)
Fix indentation in `.cargo/config.toml`.
2024-07-21 12:06:19 +00:00
Boshen ae6654f247 ci: speed up conformance with thin lto (#3773) 2024-06-19 16:05:06 +00:00
Boshen 515deb6165 chore: add cargo oxlint command 2024-05-28 11:10:08 +08:00
Boshen ae4f474bab ci: run cargo check with --all-features 2024-04-03 16:43:50 +08:00
Boshen 4af5f29774 ci: disable native build 2023-11-20 17:45:51 +08:00
Boshen 1a576f60a8 refactor(rust): move to workspace lint table (#1444) 2023-11-20 14:38:10 +08:00
Boshen c1c2a01135 ci: no need to build tests on PR branches (#1348) 2023-11-16 17:32:10 +08:00
Boshen 767744afc1 ci: remove cargo nextest because cargo test is now faster (#1341) 2023-11-16 13:31:51 +08:00
Boshen 4886d408eb chore(clippy): enable undocumented_unsafe_blocks 2023-10-16 15:18:14 +08:00
Boshen db5417f9a9 refactor(clippy): allow clippy::too_many_lines 2023-10-16 15:18:11 +08:00
Boshen eaeb63072f refactor(clippy): allow struct_excessive_bools 2023-10-16 15:18:07 +08:00
Boshen d208d6f325 ci: longer slow-timeout for cargo codecov 2023-09-13 17:05:46 +08:00
Boshen f9b0c8bd17 chore(cargo): remove sparse registries, which is now the default 2023-06-02 11:01:28 +08:00
Boshen 30fc21ce54 refactor(index): use index_vec crate (#383) 2023-05-24 21:45:06 +08:00
Boshen 2812591e4a chore(rust): allow clippy::new_without_default 2023-05-13 15:07:00 +08:00
Boshen ed693d9941 chore(clippy): allow #[must_use] 2023-05-11 20:58:52 +08:00
Boshen 60485669bb ci: cache release for benchmark, benchmark use fewer files (#345) 2023-05-10 22:13:11 +08:00
Boshen 99fdaad03a chore(rust): bump bitflags to v2 2023-05-04 12:24:47 +08:00
Boshen 080baaa2db chore: use taplo to reformat toml files 2023-04-22 15:58:59 +08:00
Boshen ec01a295a8 chore: do not append -- to cargo lint 2023-04-17 16:38:09 +08:00
Boshen 87400917e1 chore: change cargo lint to deny all warnings 2023-04-16 21:32:00 +08:00
Boshen cf68642858 chore: remove --all-features from codecov command
We should get a higher codecov from this
2023-04-16 00:39:07 +08:00