Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/oxlint/src-js/plugins/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export async function loadPlugin(
* @throws {Error} If `plugin.meta.name` is `null` / `undefined` and `packageName` not provided
* @throws {TypeError} If one of plugin's rules is malformed, or its `createOnce` method returns invalid visitor
* @throws {TypeError} If `plugin.meta.name` is not a string
* @throws {TypeError} If the plugin has a rule with an invalid `meta.fixable` value.
*/
export function registerPlugin(
plugin: Plugin,
Expand Down Expand Up @@ -169,7 +170,10 @@ export function registerPlugin(
if (typeof ruleMeta !== "object") throw new TypeError("Invalid `rule.meta`");

const { fixable } = ruleMeta;
if (fixable != null) {
// ESLint technically only allows `null`, unset, or "code" / "whitespace" for `fixable`. Unfortunately,
// it doesn't actually enforce this meaningfully, and so some plugins use `false` by accident.
// So we have to handle `false` as well.
if (fixable != null && (fixable as any) !== false) {
if (fixable !== "code" && fixable !== "whitespace") {
throw new TypeError("Invalid `rule.meta.fixable`");
}
Expand Down
1 change: 1 addition & 0 deletions apps/oxlint/src-js/plugins/rule_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface RuleMeta {
/**
* Type of fixes that the rule provides.
* Must be `'code'` or `'whitespace'` if the rule provides fixes.
* Must be `null` or omitted entirely, if the rule does not provide fixes.
*/
fixable?: "code" | "whitespace";
/**
Expand Down
Loading