Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I havesearched for related issues and found none that match my proposal.
- I have searched thecurrent rule list and found no rules that match my proposal.
- I haveread the FAQ and my problem is not listed.
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- Also, I would love to eventually add more helpers around making full plugins - it's kind of a pain to do it now - seeour
eslint-plugin-example-typed-linting...
- Also, I would love to eventually add more helpers around making full plugins - it's kind of a pain to do it now - seeour
@typescript-eslint/plugin-kit: in isolation I like this name, but@eslint/plugin-kithas 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: since
RuleCreatoris 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!
💖