diff --git a/apps/oxlint/src-js/plugins/load.ts b/apps/oxlint/src-js/plugins/load.ts index cb09995bec2cb..179b7c1d1e94f 100644 --- a/apps/oxlint/src-js/plugins/load.ts +++ b/apps/oxlint/src-js/plugins/load.ts @@ -55,6 +55,7 @@ interface RuleDetailsBase { readonly fullName: string; readonly context: Readonly; readonly isFixable: boolean; + readonly hasSuggestions: boolean; readonly messages: Readonly> | null; readonly defaultOptions: Readonly; // Function to validate options against schema. @@ -172,6 +173,7 @@ export function registerPlugin( // Validate `rule.meta` and convert to vars with standardized shape let isFixable = false, + hasSuggestions = false, messages: Record | null = null, defaultOptions: Readonly = DEFAULT_OPTIONS, schemaValidator: SchemaValidator | false | null = null; @@ -194,6 +196,13 @@ export function registerPlugin( isFixable = (fixable as "code" | "whitespace" | true | false) !== false; } + const inputHasSuggestions = ruleMeta.hasSuggestions; + if (inputHasSuggestions === true) { + hasSuggestions = true; + } else if (inputHasSuggestions != null && inputHasSuggestions !== false) { + throw new TypeError("Invalid `rule.meta.hasSuggestions`"); + } + // If `schema` provided, compile schema to validator for applying schema defaults to options schemaValidator = compileSchema(ruleMeta.schema); @@ -245,6 +254,7 @@ export function registerPlugin( rule: rule as CreateRule, // Could also be `CreateOnceRule`, but just to satisfy type checker context: null!, // Filled in below isFixable, + hasSuggestions, messages, defaultOptions, optionsSchemaValidator: schemaValidator,