Files
oxc-project__oxc/apps/oxlint/src-js/package/define.ts
overlookmotel 88f30e0b4a feat(linter/plugins): move eslint compatible plugin conversion to eslintCompatPlugin function (#18791)
Closes #18611.

Previously `definePlugin` and `defineRule` were doing double duty:

1. Providing type safety (standard `defineConfig` pattern).
2. Converting a plugin/rule to be ESLint compatible

Combining the two duties is probably confusing to users. Users are familiar with the `defineConfig` pattern and these functions generally don't do anything at runtime - just require a specific type as param and return the input untouched.

This PR adds a separate function `eslintCompatPlugin` which does the conversion to an ESLint-compatible plugin.

`definePlugin` and `defineRule` are now no-ops at runtime - they just pass through the plugin/rule unchanged.
2026-02-01 12:37:48 +00:00

30 lines
622 B
TypeScript

/*
* `definePlugin` and `defineRule` functions.
*/
import type { Plugin, Rule } from "../plugins/load.ts";
/**
* Define a plugin.
*
* No-op function, just to provide type safety. Input is passed through unchanged.
*
* @param plugin - Plugin to define
* @returns Same plugin as passed in
*/
export function definePlugin(plugin: Plugin): Plugin {
return plugin;
}
/**
* Define a rule.
*
* No-op function, just to provide type safety. Input is passed through unchanged.
*
* @param rule - Rule to define
* @returns Same rule as passed in
*/
export function defineRule(rule: Rule): Rule {
return rule;
}