-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Enhancement: Move RuleCreator into its own package with fewer dependencies than utils #10383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for taking my question very seriously! I didn't expect you to suggest to re-organize your packages for this! |
Honestly - I hate having a single Plugin utils. Each namespace really should be it's own package to enable wider and lighter reuse. The difficult thing is documenting this so that people can easily discover the right package to use. |
I do really like the idea of having granular packages. It'd also make automating docs the way we did in #9293 & #9875. One clean docs section per package instead of a big semi-organized scatter for all of However, I am concerned that users would find that separation inconvenient for the utils other than Surfacing for reference: |
I asked in the ESLint Discord about naming. Confirmed that Maybe... |
|
I like Prediction: I think we'll probably want to keep the rule utils and plugin utils in the same package. I think most users of one will also be users of the other. And, if they're not, we probably want to encourage them to be. |
If we have a utils for every pacakge does it even need to be a separate package? Or can rule-tester just have a |
What I was suggesting is that we currently have these import paths:
At least this does map well to something like
Where:
But I would think that as part of this we can do a complete refactor of things and both rename everything and split
8000
everything up. I.e. minor release -> keep We could target the breaking change soon as well given the next major is planned to be a smaller one based on what we talked about with how we wanted more majors. |
Could |
The difficult thing is that a subset of utils is still a set of utils. Until you divide that set to a single member it is a set of utils. Which means that ultimately it will be some subset of utils that ends up in this new package. Which would be confusing for people - "what's the difference between The point I'm making is that we have to be very conscious about the divisions we're choosing cos the last thing we want is for most users to go from using one package in |
The problem with I do like the |
oohh really excited about this - I've have it on my mind for years but never worked up the courage to make an issue as I figured it would be a big ask to have you awesome volunteers split packages up even further, having to decide "what does this new thing belong in", etc. The reason it's been on my mind is that we use So personally I'd like ideally to have access to the rule creator and the AST types/enums by themselves (to be clear, I'm talking about the imports |
I'm not confident I'll have time for this soon, so unassigning myself. Still thinking a team member should tackle it though. |
Ok I've tried prototyping this locally three separate times. Each time I've ended up having to make >=3 (!) new packages. Essentially, #10383 (comment). @bradzacher I'm sorry for not understanding at first why your comment was 100% on point! Just noting examples some of the bigger dependency ties:
Prototypes I'd tried out included making a |
Actually, more on that - I suspect we might need to split up
|
This comment has been minimized.
This comment has been minimized.
Part of the reason I originally created We can move some of the types across to there if we want -- we just need to do be weary of what's moving across (eg we don't want to add |
I drafted up an "ideal world" prototype in #11207. It has a few split-outs, in order:
To summarize the draft's dependency shakeups, the
Problem: removing exports such as I'm also not convinced there needs to be a specific Proposal: How about we do the following non-breaking changes now...
...and then in some future major version:
|
Before You File a Proposal Please Confirm You Have Done The Following...
Relevant Package
utils
My proposal is suitable for this project
Description
Coming over from ArnaudBarre/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 once JoshuaKGoldberg/ts-api-utils#573 is fixed that's >1 MB!It does seem unfortunate to me that if you want to use typescript-eslint's
RuleCreator
, 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 exports
RuleCreator
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 stuffeslint-plugin-example-typed-linting
...@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 include
RuleModule
, 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 per https://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 types at 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:RuleCreator
is a runtime construct@typescript-eslint/types
: since AST types would only be relevant during development, and plugin exports would not include any AST infoThis was prompted by @ArnaudBarre noting in ArnaudBarre/eslint-plugin-react-refresh#62 (comment) a desire to have nicely typed rule options for a plugin without many megabytes of added dependencies. Thanks for the prod @ArnaudBarre!
💖
The text was updated successfully, but these errors were encountered: