Commit Graph

26 Commits

Author SHA1 Message Date
leaysgur c07fe7c217 feat(oxfmt): support experimentalOperatorPosition (#25643)
Fixes #16366

---

Option name requires `experimental` prefix for now.

Values are:

- `"start"`
- `"end"`(default)

This is also available on playground.
2026-08-14 08:12:16 +00:00
anthropic-code-agent 245273ef0a feat(napi/playground): add optimizeEnums and optimizeConstEnums options (#21815)
## Summary
This PR adds `optimizeEnums` and `optimizeConstEnums` options to the playground's transformer configuration, enabling TypeScript enum optimization features that are already available in the transformer.

## Changes
- Added `optimize_enums: bool` and `optimize_const_enums: bool` fields to the `OxcTransformerOptions` struct in `napi/playground/src/options.rs`
- Updated `apply_transformations` method in `napi/playground/src/lib.rs` to apply these options to `options.typescript.optimize_enums` and `options.typescript.optimize_const_enums`

## Reference
Resolves https://github.com/oxc-project/oxc/blob/d1cf22efc2bc9cf9fa82e887c34965d2ce3004c3/napi/playground/src/options.rs#L59

These options enable:
- `optimize_enums`: Optimize regular (non-const) enums by inlining their member accesses at usage sites when the member value is statically known
- `optimize_const_enums`: Optimize const enums by inlining their values at usage sites and removing the enum declaration
2026-04-27 04:10:29 +00:00
leaysgur fc66d6dfd1 refactor(formatter): Remove experimental prefix from sort_imports (#19472)
Internal changes that do not affect Oxfmt users.
2026-02-17 05:03:21 +00:00
leaysgur 1bb0559a32 feat(playground): Support more sort-imports options (#19424)
It hadn't been updated for some time, so I made it compatible with the latest state.

(I also want to stop manual mapping, but we are not yet ready for that...)
2026-02-16 05:05:09 +00:00
leaysgur afd6c44cd7 feat(oxfmt): Support quoteProps: consistent in Oxfmtrc (#16721)
Follow up #16677, fixes #16247.
2025-12-11 02:03:49 +00:00
overlookmotel 083fea9fa6 feat(napi/parser)!: represent empty optional fields on JS side as null (#16411)
Follow-on after #16383 and #16403.

While working on those I discovered an option NAPI-RS has to represent `Option::None` as `null`, instead of omitting the field entirely.

Use that option on the structs used for transferring errors and module record over to JS.

I think this is likely more performant because:

1. NAPI-RS can create all properties of the objects using only the faster `node_api_create_object_with_properties` API.
2. It produces consistent object shapes, so JS engine can better optimize code using these objects.

It also brings the shape of the data perfectly into line between standard transfer and raw transfer, and is consistent with how empty fields in the AST are represented as `null`.

I would have used this option before if I'd known it existed.

### Breaking change

I've marked this as a breaking change because code consuming these objects would now need to check for empty fields with `value === null` instead of `value === undefined`.

However in practice, most people probably use `!value` or `value ?? ...`, so it's unlikely to affect many users. This only affects module record and errors anyway, not the AST itself, as we transfer that as JSON, not via NAPI.
2025-12-02 23:30:56 +00:00
leaysgur 73748568af feat(formatter/sort-imports): Support options.internalPattern (#16372)
Part of #14253

The original implementation accepts a `RegExp` string, but based on the actual usage, it seems that checking as prefix is sufficient for now.

https://github.com/search?q=%22internalPattern%3A+%5B%22&type=code
2025-12-02 07:37:06 +00:00
leaysgur a446e2c05a fix(playground): Remove unsupported experimental options (#16090)
Also removed from playground.
2025-11-25 05:33:44 +00:00
Boshen f5ce55a40a feat(napi): export all options using wildcard exports
Closes #15618

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 15:38:52 +08:00
Dunqing ab168177bb feat(playground): support load formatter options and output formatter IR (#14856) 2025-10-23 00:42:30 +00:00
Boshen aad7c1840f feat(napi/playground): add configurable CFG generation (#13869)
## Summary
- Add `cfg` field to `OxcRunOptions` to control Control Flow Graph generation in semantic analysis
- Replace hardcoded `with_cfg(true)` calls with configurable `run_options.cfg` option
- Update TypeScript definitions to include the new `cfg` boolean field

## Motivation
Previously, CFG generation was always enabled (`with_cfg(true)`) in both the main semantic analysis and linter semantic analysis. This change allows users to control CFG generation for better performance when CFG data is not needed.

## Changes
- **napi/playground/src/options.rs**: Add `cfg: bool` field to `OxcRunOptions` struct
- **napi/playground/src/lib.rs**:
  - Update `build_semantic` method to use `run_options.cfg` instead of hardcoded `true`
  - Update `run_linter` method to use `run_options.cfg` instead of hardcoded `true`
- **napi/playground/index.d.ts**: Add `cfg: boolean` to TypeScript definitions

## Test plan
- [ ] Verify compilation succeeds
- [ ] Test NAPI playground with `cfg: true` (should work as before)
- [ ] Test NAPI playground with `cfg: false` (should skip CFG generation for better performance)

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-09-18 04:57:28 +00:00
Boshen ed03162cba feat(napi/playground): add configurable semantic error checking (#13868)
## Summary
- Added a new `semanticErrors` field to `OxcParserOptions` to allow users to control whether semantic syntax errors should be checked and reported
- Updated the `build_semantic` method to use this configuration option
- Semantic errors are now only collected when explicitly enabled through the configuration

## Changes
- Add `semantic_errors: bool` field to `OxcParserOptions` struct in `napi/playground/src/options.rs`
- Update `build_semantic` method in `napi/playground/src/lib.rs` to:
  - Accept `parser_options` parameter
  - Use `parser_options.semantic_errors` for `with_check_syntax_error()`
  - Conditionally collect errors based on the configuration
- Auto-generated TypeScript definitions updated to include the new field

## Test plan
Tested manually by creating a simple Node.js script that:
1. Parses code with duplicate variable declarations (semantic error)
2. Tests with `semanticErrors: true` - confirms error is reported
3. Tests with `semanticErrors: false` - confirms no error is reported

The feature works as expected, providing users with control over semantic error checking.

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-09-18 02:02:04 +00:00
Boshen b68c5a202e feat(playground): add inject and replace plugins (#13805) 2025-09-16 14:37:04 +08:00
Copilot ea259af607 feat(playground): add experimental decorators options (#13602)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
2025-09-09 10:54:23 +08:00
Boshen ddaebf7571 feat(napi/playground): add more options (#13523) 2025-09-02 17:52:19 +08: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
Nicholas Rayburn bf8263d256 feat(playground): Allow specifying a JSON string as the linter config (#11710)
When creating bug reports it would be helpful to have a link to a
reproduction that just worked in the browser. By adding the ability to
config Oxlint here, simple reproductions can be done within the
Playground and URLs shared from it.

This would be a lot better if the `config` was a JSON object instead of
a string, but I don't know how to do that only on the Rust side.

An option would be to keep the Rust side a string, but on the browser
side allow it to be an object. Whenever the object changes, we serialize
that to a string before sending it to the Rust side. If there's interest
in this, then I think I can make this change in the playground repo.

Example config and screenshots below.

```json
"linter": {},
```

![image](https://github.com/user-attachments/assets/177cdb75-4a45-4c21-bf8b-2e7f46af56df)

```json
"linter": {
  "config": "{\"plugins\":[\"typescript\"],\"categories\":{\"correctness\":\"error\"},\"rules\":{\"no-debugger\":\"warn\"}}"
},
```

![image](https://github.com/user-attachments/assets/7a0843c3-d5e3-4002-bb93-964ddcd0629a)
2025-06-16 12:02:48 +01:00
LongYinan ab0dd29a2b fix(napi): napi build cache problem (#11479) 2025-06-05 12:16:08 +08:00
Boshen 0c2d1c1e80 Revert "chore(napi): upgrade to napi@3.0.0-beta.4" (#11474)
Reverts oxc-project/oxc#11466
2025-06-04 16:03:12 +08:00
LongYinan 81af6b3988 chore(napi): upgrade to napi@3.0.0-beta.4 (#11466)
Regenerate the binding files
2025-06-04 11:49:19 +08:00
Boshen d82dff91c8 feat(formatter): new implementation based on biome formatter (#10108)
Part of #5068, suggested by @ematipico and @MichaReiser, where @leaysgur
and I explored using biome formatter as the base and made a success. All
credits to the old Rome and the new Biome team.

This PR is in a boilerplate state where some of the functions are marked
as `todo!()`.

I also made the following changes:

* changed the base to be less generic, removed the `Language` and
`Context` generics
* expanded the formatter lifetime to include an `'ast` lifetime
* added access to the source text and comments
* added a mechanism for tracking and accessing parent ast nodes (done by
our codegen)
* removed most of the unit tests because they no longer compile
* removed the `oxc_prettier` crate
2025-03-30 16:54:37 +08:00
Boshen 2cedfe4148 feat(napi): add codeframe to napi error (#9893)
closes #8684
2025-03-19 08:41:31 +00:00
Hiroshi Ogawa 233c1fc863 refactor(napi/playground): add JSON.parse wrapper (#9880)
- playground PR https://github.com/oxc-project/playground/pull/78
2025-03-19 13:51:49 +08:00
Boshen 961b95d834 refactor(napi): move common code to oxc_napi (#9875) 2025-03-18 16:06:53 +00:00
Hiroshi Ogawa 30a03a3348 refactor(napi/playground): use napi-rs wasm for playground (#9803)
playground side PR: https://github.com/oxc-project/playground/pull/71

I went ahead testing out this. Let me know if this is not the plan.

I think the benefit is that this allows rust-side playground code to
reuse some code from other napi crates, for example, `oxc_napi` and
`oxc_parser_napi`. For now, I started as mostly copying paste it and
replacing `#[wasm_bindgen]` with `#[napi]`, but I also used `oxc_napi`
for `OxcError` which replaced diagnostic serialization code from
playground.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2025-03-17 23:45:55 +08:00