Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhancement: Move RuleCreator into its own package with fewer dependencies than utils #10383

Open
Labels
enhancementNew feature or requestteam assignedA member of the typescript-eslint team should work on this.
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

utils

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

Coming over fromArnaudBarre/eslint-plugin-react-refresh#62 (comment):@typescript-eslint/utils has quite a few dependencies that are not necessary forRuleCreator:ts-api-utils,@typescript-eslint/scope-manager,@typescript-eslint/typescript-estree. Even onceJoshuaKGoldberg/ts-api-utils#573 is fixed that's >1 MB!

It does seem unfortunate to me that if you want to use typescript-eslint'sRuleCreator, you have to pull in multiple other packages beyond@typescript-eslint/utils. Some plugins are intended to work in JS(X) environments. Unlike with TS(X), those users might not already have@typescript-eslint/*,ts-api-utils,typescript, etc. already installed.

Proposal: how about we split out a new package that exportsRuleCreator and its relevant types? That way users canimport { RuleCreator } without taking a dependency on scope-manager, typescript-estree, etc.

I'm not sure what we'd want to call it:

  • @typescript-eslint/rule-creator: but per notes later, I think we'll also want to export module stuff
  • @typescript-eslint/plugin-kit: in isolation I like this name, but@eslint/plugin-kit has the similar name and is about a completely different idea of "plugins"

For now, I'm going to suggest@typescript-eslint/plugin-kit.

Additional Info

Note that"relevant types" will includeRuleModule, which at the moment is stored in@typescript-eslint/utils and accessed asTSESLint.RuleModule. I think we'd want to moveRuleModule and its associated types to@typescript-eslint/plugin-kit.

For reference, the package storing the typescript-estree AST types is@typescript-eslint/types, which is 173KB perhttps://pkg-size.dev/@typescript-eslint%2Ftypes?no-peers. Roughly every plugin I remember seeing does have some internal handling for TS AST types - includingeslint-plugin-react-refresh (e.g.handlingTSEnumDeclaration,handling type assertions).

Also note that I think there's a desire to make plugins not have a full dependency on AST typesat all. If a plugin is meant to be used in ESLint config files, it probably only wants to export types for the plugin and its rules + options. I think that means the@typescript-eslint/plugin-kit package will need to be careful with dependencies:

  • It would be a full dependency on any package that uses it: sinceRuleCreator is a runtime construct
  • It would have an optional peer dependency on@typescript-eslint/types: since AST types would only be relevant during development, and plugin exports would not include any AST info

This was prompted by@ArnaudBarre noting inArnaudBarre/eslint-plugin-react-refresh#62 (comment) a desire to have nicely typed rule options for a pluginwithout many megabytes of added dependencies. Thanks for the prod@ArnaudBarre!

💖

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestteam assignedA member of the typescript-eslint team should work on this.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp