diff --git a/src/utils/rule.ts b/src/utils/rule.ts index ba35b50b0..b4ea3c9b7 100644 --- a/src/utils/rule.ts +++ b/src/utils/rule.ts @@ -8,7 +8,6 @@ import { type ReportDescriptor, type RuleContext, type RuleListener, - type RuleModule, } from "@typescript-eslint/utils/ts-eslint"; import { Immutability, @@ -51,11 +50,15 @@ export type NamedCreateRuleCustomMeta< */ export type BaseOptions = ReadonlyArray; -export type CustomRuleModule< +// eslint-disable-next-line functional/no-mixed-types +export type RuleDefinition< MessageIds extends string, Options extends BaseOptions, -> = Omit, "meta"> & { +> = { readonly meta: NamedCreateRuleCustomMeta; + readonly create: ( + context: RuleDefinition, + ) => RuleListener; }; /** @@ -174,7 +177,7 @@ export function createRuleUsingFunction< ]), ); }, - }) as unknown as CustomRuleModule; + }) as unknown as RuleDefinition; } /** diff --git a/tests/helpers/testers.ts b/tests/helpers/testers.ts index bb3d7341b..5f998a812 100644 --- a/tests/helpers/testers.ts +++ b/tests/helpers/testers.ts @@ -1,4 +1,4 @@ -import { type CustomRuleModule } from "#eslint-plugin-functional/utils/rule"; +import { type RuleDefinition } from "#eslint-plugin-functional/utils/rule"; import { getRuleTester } from "./RuleTester"; import { configs } from "./configs"; @@ -20,7 +20,7 @@ type TestFunction< export function testRule< TMessageIds extends string, TOptions extends Readonly, ->(ruleName: string, rule: CustomRuleModule) { +>(ruleName: string, rule: RuleDefinition) { return Object.fromEntries( [...Object.entries(configs)].map( ([configName, config]): [ diff --git a/tests/helpers/util.ts b/tests/helpers/util.ts index 5b2ae923b..1c4a52e82 100644 --- a/tests/helpers/util.ts +++ b/tests/helpers/util.ts @@ -11,7 +11,7 @@ import { type NamedCreateRuleMeta } from "@typescript-eslint/utils/eslint-utils" import { createRuleUsingFunction, - type CustomRuleModule, + type RuleDefinition, type RuleFunctionsMap, } from "#eslint-plugin-functional/utils/rule"; @@ -87,7 +87,7 @@ export function createDummyRule( create: ( context: Readonly>, ) => RuleFunctionsMap, -): CustomRuleModule { +): RuleDefinition { const meta: NamedCreateRuleMeta<"generic", []> = { type: "suggestion", docs: { @@ -143,12 +143,12 @@ export function addFilename< } export type MessagesOf< - T extends CustomRuleModule>, + T extends RuleDefinition>, > = - T extends CustomRuleModule> + T extends RuleDefinition> ? Messages : never; export type OptionsOf< - T extends CustomRuleModule>, -> = T extends CustomRuleModule ? Options : never; + T extends RuleDefinition>, +> = T extends RuleDefinition ? Options : never;