Skip to content

Allow generic defaults for TSESLint.RuleModule? #4134

@JoshuaKGoldberg

Description

@JoshuaKGoldberg
  • I have tried restarting my IDE and the issue persists. N/A
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

Going off the code snippet here: #4124 (comment)

This gives an error [playground link]:

import { TSESLint } from '@typescript-eslint/experimental-utils';

// Generic type 'RuleModule<TMessageIds, TOptions, TRuleListener>' requires between 2 and 3 type arguments.
export const rule: TSESLint.RuleModule = {

Although I personally would use RuleCreator, or failing that specify those TMessageIds and TOptions type arguments, it is inconvenient for folks getting started with writing rules to have to specify them. It would make for smoother documentation if we didn't have to walk people through setting them up until they're needed.

Proposal:

interface RuleModule<
-  TMessageIds extends string,
+  TMessageIds extends string = string,
-  TOptions extends readonly unknown[],
+  TOptions extends readonly unknown[] = [],

Versions

package version
@typescript-eslint/experimental-utils 5.3.1
TypeScript N/A
node N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: utilsIssues related to the @typescript-eslint/utils packagetriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions