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

Add types #164

Merged
merged 1 commit into from Apr 13, 2024
Merged

Add types #164

merged 1 commit into from Apr 13, 2024

Conversation

Logicer16
Copy link
Contributor

I just happened to already have types for this project in my own soon-to-be-published config. Ordinarily, configs, processors, parsers, and other custom exports would also need to be included, but as this plugin is quite simple 😉, only the basic plugin type needs to be used. For almost every use case, specific types for rules can be safely ignored as they are handled by ESLint internally with end users only referencing them by name.

fixes #163

@lydell
Copy link
Owner

lydell commented Apr 6, 2024

Awesome, thanks!

How does this work?

import type {ESLint} from "eslint";

Does the user need to install something to get that working?

How do I test this manually that it works?

@maranomynet
Copy link

maranomynet commented Apr 6, 2024

This is essentially what I was talking about here #163 (comment)

This asserts that what you're exporting is "an ESLint Plugin", but does not reflect the actual shape/contents of this particular plugin — i..e. which of the optinoal properties/objects (rules, config, etc.) it actually contains.

@Logicer16
Copy link
Contributor Author

Logicer16 commented Apr 6, 2024

Does the user need to install something to get that working?

These types are coming from @types/eslint. In most cases, a type checked eslint config will already have this installed in order to set the type for their configs. If it's missing the typescript compiler will instruct users to install it. If you'd rather, it can be listed as an optional peerDependency.

How do I test this manually that it works?

All you should need to test the types is:

import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
import type {Linter} from "eslint";
const config: Linter.FlatConfig = {
  plugins: {
    "simple-import-sort": simpleImportSortPlugin
  }
}

does not reflect the actual shape/contents of this particular plugin

@maranomynet Were you looking to use the types of any of those optional properties?

@Logicer16
Copy link
Contributor Author

@lydell Did you need anything else in this pr? If we want more specific types those can always be done later as those types would simply extend the ones we have here.

@lydell
Copy link
Owner

lydell commented Apr 13, 2024

No, I’ve tested this now and think we’re ready to go! I was waiting for this reply, but it doesn’t bring anything useful for this repo it seems. I’ll try to make a release later today.

@lydell lydell merged commit 3b0f491 into lydell:main Apr 13, 2024
3 checks passed
@lydell
Copy link
Owner

lydell commented Apr 13, 2024

Released in 12.1.0. Thanks again for the help!

@lydell
Copy link
Owner

lydell commented Apr 13, 2024

@JoshuaKGoldberg this plugin now has types, if you wanna update the table in eslint/eslint#18093 :)

@JoshuaKGoldberg
Copy link

Yay! Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TypeScript types
4 participants