mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
88f30e0b4a
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.
30 lines
622 B
TypeScript
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;
|
|
}
|