npm/oxlint-plugins/README.md
Plugin utilities for Oxlint.
This package provides optional functions to assist in creating Oxlint JS plugins and rules.
npm install @oxlint/plugins
Use definePlugin and defineRule if authoring your plugin in TypeScript for type safety.
import { definePlugin, defineRule } from "@oxlint/plugins";
const rule = defineRule({
create(context) {
return {
Program(node) {
// Rule logic here
},
};
},
});
export default definePlugin({
meta: { name: "oxlint-plugin-amazing" },
rules: { amazing: rule },
});
This package also includes types for plugins and rules.
import type { Context, Rule, ESTree } from "@oxlint/plugins";
const rule: Rule = {
create(context: Context) {
return {
Program(node: ESTree.Program) {
// Rule logic here
},
};
},
};
If your plugin uses Oxlint's alternative createOnce API,
use eslintCompatPlugin to convert the plugin so it will also work with ESLint.
import { eslintCompatPlugin } from "@oxlint/plugins";
const rule = {
createOnce(context) {
return {
Program(node) {
// Rule logic here
},
};
},
};
export default eslintCompatPlugin({
meta: { name: "oxlint-plugin-amazing" },
rules: { amazing: rule },
});
This package requires Node.js 12.22.0+, 14.17.0+, 16.0.0+, or later. This matches the minimum Node.js version required by ESLint 8.
This package provides both ESM and CommonJS entry points.
So a plugin which depends on @oxlint/plugins can be:
For full documentation, see Oxlint JS Plugins docs.