Skip to content
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

[Feature Request] [ESLint-Plugin] [Rules] Include TypeScript typings and Options interfaces/types in published npm package. #3816

Closed
AllySummers opened this issue Aug 29, 2021 · 1 comment
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on

Comments

@AllySummers
Copy link

Apologies for not using the issue template, it didn't seem to fit in with a feature request. Also sorry if this is breaking any rules.

I'm trying to make a package (even if it's only me who uses it) for eslint rule configs in TypeScript, and I can see that in your repo you already create TypeScript interfaces/types for the config a rule accepts, however these aren't present (from what I could see at least) when installing from npm in the node_modules.

I can see in all/most of your rules you have an Options interface/type (like here) and it would be very appreciated if it could be somehow changed to include these in what is published to npm, as it would save me a lot of duplication and time of having to copy what's already been done.

What my project is so far (it's extremely early, I just spent the last few hours TypeScript-ifying the core ESLint rules)

@AllySummers AllySummers added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Aug 29, 2021
@bradzacher
Copy link
Member

bradzacher commented Aug 29, 2021

There's an old issue for this but I CBF finding it amongst the pile of issues we have.

The answer to the request is no, sorry.
The option types declared for rules are often not 100% correct - they are based on some idealistic view of the world or they make some assumptions. In short - they are designed purely for internal development and not intended to 100% match the JSON schema.

In terms of getting types for the rules - the better way to do so is to generate the types yourself from the rule's JSON schema. This way you can be sure the types 100% match the rule's schema.

I've played with this idea before - #1296 and other users have too - #3227.
It's a great idea and I wish I had the time to build out the tooling and infra to make this a reality.

#1296 has some links to scripts and examples for generating the types from the schema.

@bradzacher bradzacher added wontfix This will not be worked on and removed triage Waiting for maintainers to take a look labels Aug 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants