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

Reorganize public type definitions #6508

Closed
ybiquitous opened this issue Dec 6, 2022 · 3 comments · Fixed by #6510
Closed

Reorganize public type definitions #6508

ybiquitous opened this issue Dec 6, 2022 · 3 comments · Fixed by #6510
Labels
status: wip is being worked on by someone type: enhancement a new feature that isn't related to rules

Comments

@ybiquitous
Copy link
Member

ybiquitous commented Dec 6, 2022

Because it is unclear whether a type definition is public or internal and so available from Stylelint plugin packages, there is a problem in that we cannot safely refactor type definitions.

There are a few ways to limit the publicity of type definitions:

  1. Add the @internal JSDoc annotation and a warning message like this:
    /**
    * Internal use only. Do not use or rely on this type. It may change at
    * any time.
    * @internal
    */
    export type InternalApi = {
  2. Add a _ prefix to types or type members like this:
    export type InternalApi = {
    _options: LinterOptions & { cwd: string };
    _extendExplorer: ReturnType<typeof cosmiconfig>;
    _specifiedConfigCache: Map<Config, Promise<CosmiconfigResult>>;
    _postcssResultCache: Map<string, PostCSS.Result>;
    _fileCache: FileCache;
    };
  3. Remove export from internal types as possible. This way is smarter, but it may need to remove namespace:
    namespace stylelint {

I believe we need to reorganize type definitions by combining such ways well.
I'm happy to hear any feedback.

Ref:

@ybiquitous ybiquitous added the status: needs discussion triage needs further discussion label Dec 6, 2022
@jeddy3
Copy link
Member

jeddy3 commented Dec 6, 2022

You're probably the most familiar with our types than anyone else 😄 Do you have a preference for how to combine the approaches? We can roll into v15 so that it can be a breaking change.

@ybiquitous ybiquitous linked a pull request Dec 6, 2022 that will close this issue
@ybiquitous ybiquitous added status: wip is being worked on by someone type: refactor an improvement to the code structure type: enhancement a new feature that isn't related to rules and removed status: needs discussion triage needs further discussion type: refactor an improvement to the code structure labels Dec 6, 2022
@ybiquitous
Copy link
Member Author

@jeddy3 Thank you for your feedback. Since I may be just in time for v15, I've opened PR #6510.

@jeddy3
Copy link
Member

jeddy3 commented Dec 28, 2022

Done in #6510

@jeddy3 jeddy3 closed this as completed Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip is being worked on by someone type: enhancement a new feature that isn't related to rules
Development

Successfully merging a pull request may close this issue.

2 participants