diff --git a/lib/mod.d.ts b/lib/mod.d.ts new file mode 100644 index 0000000..f30cd4c --- /dev/null +++ b/lib/mod.d.ts @@ -0,0 +1,44 @@ +/** + * @fileoverview Allow multiple configurations of a rule without overriding it. + * @author + * 唯然 + */ + +declare module "@weiran.zsd/multi-eslint-rule-config" { + import { Linter, Rule } from "eslint"; + + interface RuleOptions { + rule: string | Rule.RuleModule; + ruleConfig: Linter.RuleEntry; + asRuleName?: string; + plugin?: { + rules: Record; + }; + } + + interface ConfigOptions { + name: string; + plugins: { + [prefix: string]: { + meta: { + name: string; + version: string; + }; + rules: Record; + }; + }; + rules: Record; + } + + /** + * Generates a configuration object for ESLint with multiple rule configurations. + * + * @param options - Array or single item containing rule options to configure. + * @param prefix - Optional prefix to use for the plugin (default is "@@"). + * @returns The generated configuration object. + */ + export function config( + options: RuleOptions | RuleOptions[], + prefix?: string, + ): ConfigOptions; +} diff --git a/package.json b/package.json index d864432..a28ab79 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "author": "唯然