-
-
Notifications
You must be signed in to change notification settings - Fork 856
feat(linter/plugins): create @oxlint/plugins and @oxlint/plugins-dev NPM packages
#18796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this package will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). | ||
|
|
||
| ## [1.42.0] - 2026-01-26 | ||
|
|
||
| ### 🚀 Features | ||
|
|
||
| - Initial release of `@oxlint/plugins-dev` package |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # @oxlint/plugins-dev | ||
|
|
||
| Development and testing utilities for [Oxlint](https://oxc.rs/docs/guide/usage/linter.html) JS plugins. | ||
|
|
||
| This package provides the `RuleTester` class for testing custom Oxlint rules. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install --save-dev @oxlint/plugins-dev | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| API is identical to [ESLint's `RuleTester`](https://eslint.org/docs/latest/integrate/nodejs-api#ruletester). | ||
|
|
||
| ```typescript | ||
| import { RuleTester } from "@oxlint/plugins-dev"; | ||
|
|
||
| const ruleTester = new RuleTester(); | ||
|
|
||
| ruleTester.run("my-rule", myRule, { | ||
| valid: ["const x = 1;"], | ||
| invalid: [ | ||
| { | ||
| code: "var x = 1;", | ||
| errors: [{ message: "Use const instead of var" }], | ||
| }, | ||
| ], | ||
| }); | ||
| ``` | ||
|
|
||
| ## Docs | ||
|
|
||
| For full documentation, see [Oxlint JS Plugins docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Re-export development utilities types from `oxlint` package | ||
| export * from "oxlint/plugins-dev"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Re-export development utilities from `oxlint` package | ||
| export * from "oxlint/plugins-dev"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "name": "@oxlint/plugins-dev", | ||
| "version": "1.42.0", | ||
| "description": "Development utilities for Oxlint plugins", | ||
| "keywords": [ | ||
| "oxlint", | ||
| "plugin", | ||
| "rule-tester", | ||
| "testing" | ||
| ], | ||
| "homepage": "https://oxc.rs/docs/guide/usage/linter/plugin-system", | ||
| "bugs": "https://github.com/oxc-project/oxc/issues", | ||
| "license": "MIT", | ||
| "author": "Boshen and oxc contributors", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/oxc-project/oxc.git", | ||
| "directory": "npm/oxlint-plugins-dev" | ||
| }, | ||
| "funding": { | ||
| "url": "https://github.com/sponsors/Boshen" | ||
| }, | ||
| "files": [ | ||
| "index.js", | ||
| "index.d.ts", | ||
| "README.md" | ||
| ], | ||
| "type": "module", | ||
| "main": "index.js", | ||
| "types": "index.d.ts", | ||
| "dependencies": { | ||
| "oxlint": "^1.42.0" | ||
| }, | ||
| "engines": { | ||
| "node": "^20.19.0 || >=22.12.0" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this package will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). | ||
|
|
||
| ## [1.42.0] - 2026-01-26 | ||
|
|
||
| ### 🚀 Features | ||
|
|
||
| - Initial release of `@oxlint/plugins` package |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # @oxlint/plugins | ||
|
|
||
| Plugin utilities for [Oxlint](https://oxc.rs/docs/guide/usage/linter.html). | ||
|
|
||
| This package provides optional functions to assist in creating Oxlint JS plugins and rules. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @oxlint/plugins | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Define functions | ||
|
|
||
| Use `definePlugin` and `defineRule` if authoring your plugin in TypeScript for type safety. | ||
|
|
||
| ```typescript | ||
| import { definePlugin, defineRule } from "@oxlint/plugins"; | ||
|
|
||
| const myRule = defineRule({ | ||
| create(context) { | ||
| return { | ||
| Program(node) { | ||
| // Rule logic here | ||
| }, | ||
| }; | ||
| }, | ||
| }); | ||
|
|
||
| export default definePlugin({ | ||
| name: "my-plugin", | ||
| rules: { "my-rule": myRule }, | ||
| }); | ||
| ``` | ||
|
|
||
| ### Types | ||
|
|
||
| This package also includes types for plugins and rules. | ||
|
|
||
| ```typescript | ||
| import type { Context, Rule, ESTree } from "@oxlint/plugins"; | ||
|
|
||
| const myRule: Rule = { | ||
| create(context: Context) { | ||
| return { | ||
| Program(node: ESTree.Program) { | ||
| // Rule logic here | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ### ESLint compatibility | ||
|
|
||
| If your plugin uses Oxlint's [alternative `createOnce` API](https://oxc.rs/docs/guide/usage/linter/js-plugins.html#alternative-api), | ||
| use `eslintCompatPlugin` to convert the plugin so it will also work with ESLint. | ||
|
|
||
| ```typescript | ||
| import { eslintCompatPlugin } from "@oxlint/plugins"; | ||
|
|
||
| const myRule = { | ||
| createOnce(context) { | ||
| return { | ||
| Program(node) { | ||
| // Rule logic here | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
|
|
||
| export default eslintCompatPlugin({ | ||
| name: "my-plugin", | ||
| rules: { "my-rule": myRule }, | ||
| }); | ||
| ``` | ||
|
|
||
| ## Docs | ||
|
|
||
| For full documentation, see [Oxlint JS Plugins docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Re-export plugins types from `oxlint` package | ||
| export * from "oxlint/plugins"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Re-export all plugin APIs from `oxlint` package | ||
| export * from "oxlint/plugins"; | ||
overlookmotel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "name": "@oxlint/plugins", | ||
| "version": "1.42.0", | ||
| "description": "Plugin utilities for Oxlint", | ||
| "keywords": [ | ||
| "eslint", | ||
| "linter", | ||
| "oxlint", | ||
| "plugin" | ||
| ], | ||
| "homepage": "https://oxc.rs/docs/guide/usage/linter/plugin-system", | ||
| "bugs": "https://github.com/oxc-project/oxc/issues", | ||
| "license": "MIT", | ||
| "author": "Boshen and oxc contributors", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/oxc-project/oxc.git", | ||
| "directory": "npm/oxlint-plugins" | ||
| }, | ||
| "funding": { | ||
| "url": "https://github.com/sponsors/Boshen" | ||
| }, | ||
| "files": [ | ||
| "index.js", | ||
| "index.d.ts", | ||
| "README.md" | ||
| ], | ||
| "type": "module", | ||
| "main": "index.js", | ||
| "types": "index.d.ts", | ||
| "dependencies": { | ||
| "oxlint": "^1.42.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is right - it will mean that the dependency is the published version, which will make local dev a nightmare?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this approach is probably better: #18824. |
||
| }, | ||
| "engines": { | ||
| "node": "^20.19.0 || >=22.12.0" | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.