feat(linter/plugins): create @oxlint/plugins and @oxlint/plugins-dev NPM packages#18796
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
4232002 to
58496be
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces two new NPM packages (@oxlint/plugins and @oxlint/plugins-dev) intended to provide plugin authoring utilities separately from the main oxlint package. However, the implementation has a critical flaw that contradicts the stated goal.
Changes:
- Added
@oxlint/pluginspackage for plugin and rule definition utilities - Added
@oxlint/plugins-devpackage for theRuleTesterdevelopment utility - Updated
oxc_release.tomlto include the new packages in version management
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| oxc_release.toml | Added versioned file entries for the two new packages |
| npm/oxlint-plugins/package.json | Package manifest for @oxlint/plugins with oxlint dependency |
| npm/oxlint-plugins/index.js | Re-exports plugin APIs from oxlint package |
| npm/oxlint-plugins/index.d.ts | Re-exports plugin types from oxlint package |
| npm/oxlint-plugins/README.md | Documentation for using the plugins package |
| npm/oxlint-plugins/CHANGELOG.md | Initial changelog entry |
| npm/oxlint-plugins-dev/package.json | Package manifest for @oxlint/plugins-dev with oxlint dependency |
| npm/oxlint-plugins-dev/index.js | Re-exports development utilities from oxlint package |
| npm/oxlint-plugins-dev/index.d.ts | Re-exports development types from oxlint package |
| npm/oxlint-plugins-dev/README.md | Documentation for using the plugins-dev package |
| npm/oxlint-plugins-dev/CHANGELOG.md | Initial changelog entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8eef88a to
4259390
Compare
9fae30e to
ceae6b5
Compare
9fae30e to
ab4fddd
Compare
4259390 to
3d7c122
Compare
…ev` NPM packages
3d7c122 to
1e13925
Compare
| "main": "index.js", | ||
| "types": "index.d.ts", | ||
| "dependencies": { | ||
| "oxlint": "^1.42.0" |
There was a problem hiding this comment.
I don't think this is right - it will mean that the dependency is the published version, which will make local dev a nightmare?
There was a problem hiding this comment.
Hmm. Do you mean local dev as in local dev for us? Or for users?
For a user of a plugin, it is a real dependency (not a peer dependency).
Or maybe this approach just plain doesn't work, and we need to put the code in the packages themselves and @oxlint/plugins shouldn't have any dependencies at all?
There was a problem hiding this comment.
yes - local dev for us.
I think there definitly is a way that this can work - but i think putting 1.42 here will point it to the published version.
does pnpm install oxlint as a dep?
There was a problem hiding this comment.
I think this approach is probably better: #18824.
|
Superceded by #18824. |
Alternative to #18796. Part of #18610. ## Overview Add `@oxlint/plugins` package. `@oxlint/plugins` package has no dependency on `oxlint`, which solves the problem raised in #18796 (comment), and is also what we wanted in the end anyway. We don't actually want plugins packages to have to depend on `oxlint`. ## Differences from other Oxc packages This package is different from all our other packages, in that it's intended to work not only with Oxlint's ecosystem, but also with ESLint's ecosystem. `@oxlint/plugins` will be a *runtime* dependency of plugin packages that the community create, and they may want their plugin to be compatible with both Oxlint and ESLint - this package provides the `eslintCompatPlugin` function for exactly this purpose. Our aim is to allow plugin authors to migrate from ESLint's `create` API to Oxlint's `createOnce` API with minimum friction, and without breaking changes for their users: 1. Their plugin should remain compatible with ESLint. 2. They do not need to alter the versions of NodeJS they support (no change to `engines` field in `package.json`). 3. They can continue to publish their plugin as a CommonJS package, if that's the format they currently use. ## Package composition Due to these requirements, the make-up of `@oxlint/plugins` is different from our other packages: ### Dual Format This package is in "dual package" format, with both ESM and CommonJS entry points. ### Older NodeJS versions support This package supports NodeJS versions back to v12.22.0. https://github.com/oxc-project/oxc/blob/9938dc476f8533b7011af03cdbac328b0d00d344/npm/oxlint-plugins/package.json#L40-L42 This matches `engines` field in all ESLint 8.x.x releases: * 8.0.0: https://www.npmjs.com/package/eslint/v/8.0.0?activeTab=code * 8.57.1: https://www.npmjs.com/package/eslint/v/8.57.1?activeTab=code Therefore, `@oxlint/plugins` can be used by any plugin which supports ESLint 8 or later. Note: Download counts for ESLint 8 are still roughly equal to ESLint 9, even though v9 was released 2 years ago. #### Notes * Changing `target` in TSDown to `"node12"` does not result in any changes to built files. See 3rd commit in this PR. * `exports` field in `package.json` is supported (without experimental flag) from NodeJS v12.17.0 + v14.0.0. * `.cjs` file extension supported from NodeJS v12.0.0. ## Building the package This PR adds 2 extra builds to TSDown config, which generate the files for the package. `build.ts` script moves the files into `npm/oxlint-plugins` directory. Later on, we'll move the logic for moving the files into the CI release workflow, so we don't need to check the generated build files into Git. ## `@oxlint/plugins-dev` In #18610 we decided to also add an `@oxlint/plugins-dev` to contain `RuleTester`, so we can move that out of `oxlint` package. This PR *does not* add that package. I've skipped that for now as (a) it's trickier and (b) it's much less important.

Closes #18610.
Add NPM packages
@oxlint/pluginsand@oxlint/plugins-dev.Add the 2 packages to the
versioned_fileslist inoxc_release.toml. From what I can understand (and what Claude tells me), that should be all that's needed to bump versions in pre-release workflow, along with the rest.The release workflow already publishes all packages matching
npm/oxlint*:oxc/.github/workflows/release_apps.yml
Lines 194 to 201 in 1d34b42