eslint-config icon indicating copy to clipboard operation
eslint-config copied to clipboard

About Rule types in `@antfu/eslint-define-config`

Open xsjcTony opened this issue 1 year ago • 3 comments

Clear and concise description of the problem

Thanks for the great repo, as I'm using it as a template to build my own ESLint template.

As I can see that a lot of rule types have been defined in the repo (your experimental one @antfu/eslint-define-config), but some of them are outdated due to plugin updates.

E.g. https://github.com/antfu/eslint-define-config/blob/e00650ff81b8be2e19c3d6210801a327fe494be6/src/rules/import/newline-after-import.d.ts#L6-L9 where it now has another option exactCount?: number

Due to this now I have to do Snipaste_2023-10-28_22-09-29

Wondering is there any plan to sync those types? It's a bit hard to track every single plugin upgrade manually.

Suggested solution

N/A

Alternative

No response

Additional context

No response

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

xsjcTony avatar Oct 28 '23 11:10 xsjcTony

It's more like a temporary thing to experiment out and move fast. Later we will move to https://github.com/eslint-types instead.

antfu avatar Oct 28 '23 16:10 antfu

Yep, I can see everything is experimental right now, but I wanted to know some insights about how those types will be maintained in the future.

Are those types being created manually or by some scripts? if it's manual work, then it might be really though😂

Also another thing I want to mention there, in the final bundle I'd suggest at least spilt the dts file into one per plugin instead of all in one since 50000+ lines of code are killing my IDE🤣.

Nothing serious there tho, as I'm just being curious. Feel free to close this if discussing about it is way too early in the experimental stage

xsjcTony avatar Oct 29 '23 03:10 xsjcTony

Honestly I would like to see the types inlined rather then as-is I did make a generator POC in https://github.com/eslint-types/eslint-define-config/pull/177 It can be done much easier, I guess, if it'll be something like

type Rule<A extends any[]> = 'off'|'warn'|'...'|A
type Rules1 = {
  [K in keyof Rules0]: Rules0[K] extends Rule<[RuleLevel, infer O1]> ? Rule<[RuleLevel, Pure<O1>]>
}

and to cast Pure(akaPrettifyakaDebug) on the object to it gets reduced from interface into a type

50000+ lines of code are killing my IDE

1000s of files of code original eslint-define-config has were killing my IDE even better (reading large amounts of files is slow on Windows, it took 20s to load types)

It's more like a temporary thing to experiment out and move fast

I'd say having JSDoc generator used in this package here would be required to make renamed types(ts/*) - as JSDoc doesn't follow renaming The types, however, better to come from the package, as it updates pretty often and maintaining it may be a hussle

Dimava avatar Nov 01 '23 00:11 Dimava

Should be better now with https://github.com/antfu/eslint-typegen

antfu avatar Apr 22 '24 11:04 antfu