-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Is there any way we could work together to achive typed rule support in eslint-define-config
?
#3227
Comments
eslint-define-config
?eslint-define-config
?
Hey that's awesome! There are definitely too many rules to manually write types for. If you combine In the past in personal projects I've done this generation automatically via a simple script - https://github.com/bradzacher/eslint-config-brad/blob/master/scripts/generateTypes.ts which generates types for the plugins - https://github.com/bradzacher/eslint-config-brad/tree/master/src/types In a nutshell - this script reads the JSONSchema defined for each rule in a plugin and then uses |
A "problem" I have with auto-generating them is that they would not have e.g. JSDoc Another thing is that the once that I already created are really strongly typed https://github.com/Shinigami92/eslint-define-config/blob/main/src/rules/eslint/semi.d.ts But yes, maybe we could try generating it to have a huge starting point Do you want an invite to the repo? I will send you an invite 馃檪 |
Oh @bradzacher and if you want (don't know if I'm allowed to advertise my repo so much ^^) you can advertise it in the mentioned PR The current version of my package is already usable! right now! |
Hi @Shinigami92, can't JSdocs be generated too? Babel automatically generates code for |
@fedeci Yeah please! I never auto-generated types. Feel free to open any kind of PR or issue in the repo. So we can track anything further from there 馃憤 |
You get the exact same guarantee from auto-generated types! Here are the auto-generated types for the These types are generated from the JSON schema for the rule - meaning they will match the same runtime checks that are done by ESLint. |
Mh... but numbers are also allowed for severity 馃 I think if I just provide the most common used If I just add some rules every day... I mean they are only around 200 eslint rules and around 100 of the are in the "recommended". So in a month or so I could cover most needed eslint rules 馃槄 It's not impossible |
Wouldn't it become tough to maintain? 馃 |
I don't think so, cause I provide relaxed types And all rules that are currently not defined yet fallback to https://github.com/Shinigami92/eslint-define-config/blob/2ccd3afeba34b89b06c30755b2c7043695236d9d/src/rules/rule-config.d.ts#L6 And if a defined rule break it's typing cause of an update, the community can just open an issue/pr for that |
@fedeci I mean... I literaly jump into repos like vbenjs/vue-vben-admin#431 and provide types/fixes for them |
That's just part of the script. I just do it with strings because I prefer the strings over the numbers.
But what about other plugins? There are hundreds of additional rules that you'd want to cover.
You can always just add a JSDoc comment that links to the rule's Or you could augment my simple script to allow additional comments to be emitted if one has been added for a rule? if (configuration[plugin][rule]) {
comment = `/**\n *${configuration[plugin][rule].split('\n').join('\n *')}\n*/`
} That would give you a "best of both worlds" scenario I'm just thinking from the perspective of an OSS maintainer. I think it's an admirable goal, and in an ideal world it'd be the best state. But in reality you'll just spend a sink lot of time into it, and then have to keep an eye on every release to look for changes in all the plugins and repos |
Thanks I will definitely have a look into that I expect generating something like this could be really hard |
Generating it "cleanly" with template string types - yes, that would be nigh impossible to do as it would require understanding of the rule itself. But generating the options by itself - nope that's trivial still: |
https://www.npmjs.com/package/eslint-define-config already has around 17k dl/week 馃殌 increasing 馃搱 |
Hi 馃檪 I'm the author of https://github.com/Shinigami92/eslint-define-config
I see that in this repo already some types exist: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/typings/eslint-rules.d.ts
Do you think it's possible in any way to reuse these in https://github.com/Shinigami92/eslint-define-config/tree/main/src/rules/typescript-eslint?
Another question: Is it possible that anyone can help me in
eslint-define-config
for support@typescript-eslint
?Contributions in any way are really welcome 馃槂
The text was updated successfully, but these errors were encountered: