Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Sep 12, 2025

Convert oxlint to a NAPI package.

This PR:

  1. Moves files from napi/oxlint into apps/oxlint.
  2. Converts oxlint into a NAPI package.
  3. Alters the release workflow and script for building oxlint packages.

Most of necessary code modifications and refactoring was done in previous PRs (#13701, #13712, #13722, #13745), so this PR only includes changes necessary for packaging as NAPI.

I've done my best to update release workflow, but am mostly "flying blind" without ability to test it, so very likely there are mistakes.

A few notes and oddities:

  • I've kept the oxlint NPM package as CommonJS. We could probably switch to ESM, but I thought it better to minimize the changes in this PR.
  • NAPI-RS creates .node files named with a -msvc postfix for Windows. The scripts here remove that postfix so that filename of .node files and NPM package names match for all platforms, for simplicity.
  • tasks/website has a dependency on oxlint as a normal library. This resulted in linker errors, so have had to put all the NAPI stuff behind napi cargo feature. Tests for tasks/website are run separately in CI, to avoid feature unification turning on the napi feature for website.

I've made a few comments below for the parts which aren't fairly self-explanatory.

@github-actions github-actions bot added A-cli Area - CLI A-ast-tools Area - AST tools C-enhancement Category - New feature or request labels Sep 12, 2025
Copy link
Member Author

overlookmotel commented Sep 12, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 12, 2025

CodSpeed Instrumentation Performance Report

Merging #13723 will not alter performance

Comparing 09-12-feat_linter_convert_oxlint_to_napi_app (53d04dd) with main (0b6dae3)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on main (53d04dd) during the generation of this report, so 0b6dae3 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app graphite-app bot changed the base branch from 09-12-test_linter_set_cwd_for_tests to graphite-base/13723 September 12, 2025 08:58
graphite-app bot pushed a commit that referenced this pull request Sep 12, 2025
#13723 turns `apps/oxlint` into a NAPI package, and moves all the files from `napi/oxlint` into `apps/oxlint`.

These files include the `test` directory, which includes tests for JS plugins. This causes problems with 3 of the existing `oxlint` Rust tests, which run with `cwd` as `apps/oxlint` and no config file specified, because they pick up config files in the JS test fixtures. These config files include JS plugins, which `oxlint`'s Rust tests can't handle because they're run without an `ExternalLinter`.

This PR works around this problem by setting `cwd` to `apps/oxlint/fixtures` for these 3 tests.

I'm not sure if this is a reasonable way to solve the problem.
@graphite-app graphite-app bot force-pushed the graphite-base/13723 branch from 0149a7e to fb2d087 Compare September 12, 2025 09:04
@graphite-app graphite-app bot force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch from 3df5acc to 90f96b1 Compare September 12, 2025 09:04
@graphite-app graphite-app bot changed the base branch from graphite-base/13723 to main September 12, 2025 09:04
@graphite-app graphite-app bot force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch from 90f96b1 to e36fe19 Compare September 12, 2025 09:05
@overlookmotel overlookmotel force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch 5 times, most recently from 940115c to 286e79f Compare September 12, 2025 12:29
@overlookmotel overlookmotel self-assigned this Sep 13, 2025
@overlookmotel overlookmotel force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch 4 times, most recently from e6dca4f to 1cb8d8c Compare September 13, 2025 13:49
@overlookmotel overlookmotel changed the base branch from main to graphite-base/13723 September 13, 2025 14:31
@overlookmotel overlookmotel force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch from 1cb8d8c to 55ea1cb Compare September 13, 2025 14:31
@overlookmotel overlookmotel changed the base branch from graphite-base/13723 to 09-13-refactor_linter_move_oxlint_application_code_into_separate_module September 13, 2025 14:32
@graphite-app graphite-app bot changed the base branch from 09-13-refactor_linter_move_oxlint_application_code_into_separate_module to graphite-base/13723 September 13, 2025 14:44
graphite-app bot pushed a commit that referenced this pull request Sep 13, 2025
…#13745)

Pure refactor. Move code for running the linter in `oxlint` into a separate `run.rs` module. This is preparation for making `oxlint` into a NAPI package (#13723).
@overlookmotel
Copy link
Member Author

We're going to merge #13724 (or a similar PR that does the same thing) and make a release before we merge this. Marking as draft for now.

@overlookmotel overlookmotel marked this pull request as draft September 16, 2025 09:55
@overlookmotel overlookmotel force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch from c13ada6 to 115149b Compare September 16, 2025 12:36
@overlookmotel
Copy link
Member Author

overlookmotel commented Sep 16, 2025

#13724 is merged and a new release cut, so I think we're good to merge this now.

@camc314 If I have that right, could you please merge this?

@overlookmotel overlookmotel marked this pull request as ready for review September 16, 2025 20:07
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Sep 17, 2025
Copy link
Contributor

camc314 commented Sep 17, 2025

Merge activity

Convert `oxlint` to a NAPI package.

This PR:

1. Moves files from `napi/oxlint` into `apps/oxlint`.
2. Converts `oxlint` into a NAPI package.
3. Alters the [release workflow](https://github.com/oxc-project/oxc/pull/13723/files#diff-80cb497c859bbaf7756da6ced2bca3d31933affc96102983eee1ad7d4bcc60fd) and [script](https://github.com/oxc-project/oxc/pull/13723/files#diff-4c4b7045c68805aeeae7c0af94cf7cf7487cb0403496da974a6a23accdc457d0) for building `oxlint` packages.

Most of necessary code modifications and refactoring was done in previous PRs (#13701, #13712, #13722, #13745), so this PR only includes changes necessary for packaging as NAPI.

I've done my best to update release workflow, but am mostly "flying blind" without ability to test it, so very likely there are mistakes.

A few notes and oddities:

* I've kept the `oxlint` NPM package as CommonJS. We could probably switch to ESM, but I thought it better to minimize the changes in this PR.
* NAPI-RS creates `.node` files named with a `-msvc` postfix for Windows. The scripts here remove that postfix so that filename of `.node` files and NPM package names match for all platforms, for simplicity.
* `tasks/website` has a dependency on `oxlint` as a normal library. This resulted in linker errors, so have had to put all the NAPI stuff behind `napi` cargo feature. Tests for `tasks/website` are run separately in CI, to avoid feature unification turning on the `napi` feature for `website`.

I've made a few comments below for the parts which aren't fairly self-explanatory.
@graphite-app graphite-app bot force-pushed the 09-12-feat_linter_convert_oxlint_to_napi_app branch from 115149b to 53d04dd Compare September 17, 2025 09:20
@graphite-app graphite-app bot merged commit 53d04dd into main Sep 17, 2025
29 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 17, 2025
@graphite-app graphite-app bot deleted the 09-12-feat_linter_convert_oxlint_to_napi_app branch September 17, 2025 09:25
@overlookmotel overlookmotel added the A-linter Area - Linter label Sep 17, 2025
graphite-app bot pushed a commit that referenced this pull request Sep 23, 2025
Now that `apps/oxlint` and `napi/parser` are both ESM packages (#13723 and #14042), we can use `.js` file extensions for all ESM files, rather than the mix of `.js` and `.mjs` file we had previously.

It's less confusing having to remember what's `.js` and what's `.mjs`, and avoids ugly workarounds like #14038 (`.d.mts`??).
camc314 added a commit that referenced this pull request Sep 23, 2025
## [1.17.0] - 2025-09-23

### 🚀 Features

- f47f978 linter/plugins: Add `definePlugin` API (#14008)
(overlookmotel)
- 3e117c6 linter/plugins: Add `defineRule` API (#13945) (overlookmotel)
- 2dc8adb linter/plugins: Add `createOnce` API (#13944) (overlookmotel)
- bef8753 linter/plugins: ESTree-compatible AST for JS plugins (#13942)
(overlookmotel)
- 55c2e11 editor: Add `oxc.fmt.experimental` flag (#13923) (Sysix)
- a21ff54 language_server: Introduce `ServerFormatter` (#13700) (Sysix)
- a14aa79 npm/oxlint: Convert to ES modules (#13876) (Boshen)
- 15eb326 linter: Add `vue/no-required-prop-with-default` rule (#13613)
(yefan)
- 5d3ba00 linter: Add `vue/require-typed-ref` rule (#13857) (yefan)
- b52389a node: Bump `engines` field to require Node.js 20.19.0+ for ESM
support (#13879) (Copilot)
- 8221a01 linter: Add `eslint/no-misleading-character-class` (#13365)
(Sysix)
- c75ae8c linter/plugins: Add options to `Context` (#13810)
(overlookmotel)
- 53d04dd linter: Convert `oxlint` to NAPI app (#13723) (overlookmotel)

### 🐛 Bug Fixes

- 1f4be38 napi/parser: Generate `.d.mts` extension for types (#14038)
(Daniel Roe)
- a018756 linter/plugins: Pin `tsdown` dependency to 0.15.1 (#14005)
(overlookmotel)
- b8790c2 language_server: Output correct position for parser & semantic
errors (#14010) (Sysix)
- 4d3c6e1 linter: Support let-chains in codegen node type detection
(#14006) (camc314)
- a34918a linter/plugins: Avoid lint warnings compiling WASM or
big-endian (#13968) (overlookmotel)
- 27022ab linter/switch-case-braces: Add support for string including
colon on case expression (#13687) (Lukinoh)
- dd3843f linter: Set package version in `package.json` (#13890)
(overlookmotel)
- fa866b3 linter: Sort optimized/unoptimized diagnostics before
comparison (#13850) (camc314)
- fac7624 linter/plugins: Improve error for no JS plugins (#13858)
(overlookmotel)

### 🚜 Refactor

- bb040bc parser, linter: Replace `.mjs` files with `.js` (#14045)
(overlookmotel)
- b353750 linter/plugins: Remove unnecessary `Serialize` derives
(#14031) (overlookmotel)
- 0d48511 linter/plugins: Improve handling `Context` method calls in
`createOnce` (#14032) (overlookmotel)
- 36ac0fb language_server: Don't create `mpsc` channel (#14011) (Sysix)
- 2e9ae3f linter: Make disable directives own the rule name (#13987)
(camc314)
- 6bc7664 oxlint: Run oxlint before tsgolint (#13519) (camc314)
- 0c93f33 language_server: Use minimal text edit for `ServerFormatter`
(#13960) (Sysix)
- 823cb57 langauge_server: Move `Backend` into own file (#13955) (Sysix)
- dc700f5 language_server: Introduce `LSPFileSystem` (#13731) (Sysix)
- 42e2c1d linter: Remove `Rc` from `DisableDirectives` (#13924)
(camc314)
- ac3e9e9 napi/parser: Move JS code into `src-js` directory (#13899)
(overlookmotel)
- e90bfe3 linter: Remove double reference in unicorn/error-message
(#13916) (camc314)
- 83791a0 linter: Remove double reference in vue/jsx-no-undef (#13915)
(camc314)
- ebd22de linter: Remove double reference in vue/require-typed-ref
(#13914) (camc314)
- 873e231 language_server: Move `needs_linter_restart` to `ServerLinter`
(#13834) (Sysix)
- 7e0d736 linter/plugins: Rename `--experimental-js-plugins` to
`--js-plugins` (#13860) (overlookmotel)
- 6245c8c linter/plugins: Make `Context` properties getters (#13809)
(overlookmotel)
- a2342a6 linter/plugins: Import named in tests (#13807) (overlookmotel)

### 📚 Documentation

- 601c876 linter: Add comment explaining why Mimalloc is feature-gated
(#14037) (overlookmotel)

### ⚡ Performance

- 4d04c6e linter/plugins: Flatten `LintFileResult` fields (#14033)
(overlookmotel)
- 06363e0 linter: Add node type codegen support for `match node.kind()`
(#13736) (camchenry)
- a79af0a linter: Replace `for (... of ...)` loops (#13913)
(overlookmotel)
- b53292d linter: Use unstable sort where possible (#13818) (sapphi-red)

### 🎨 Styling

- 8083740 linter: Import `Serialize` at top level (#14030)
(overlookmotel)

### 🧪 Testing

- b807b6f language_server: Skip formatter test on windows (#13986)
(Sysix)
- 2600858 language_server: Add Tester for ServerFormatter (#13969)
(Sysix)
- 37aadf0 language_server: Add `test_and_snapshot_multiple_file`
(#13966) (Sysix)
- ad14a41 editor: Fix test setup (#13929) (Sysix)
- f51240e linter/plugins: Tests for different import styles (#13859)
(overlookmotel)
- 407c95e linter/plugins: Check `this` is undefined in visit functions
(#13811) (overlookmotel)
- f023a22 linter/plugins: Include stack trace in plugin loading errors
(#13808) (overlookmotel)

### 💼 Other

- 0630d68 linter: Build `oxlint` locally with Mimalloc in release mode
(#14034) (overlookmotel)

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools A-cli Area - CLI A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants