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

feat: add validator run event to allow plugins to perform custom validation #2184

Merged
merged 2 commits into from Feb 26, 2023

Conversation

RebeccaStevens
Copy link
Contributor

@RebeccaStevens RebeccaStevens commented Feb 24, 2023

fix #2183

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 24, 2023

I don't think I want the validator to be a separate thing - it's not nearly complicated enough to deserve that... I'd rather just add the validate event to ApplicationEvents and emit it on the application, then if any validator logs or listener to that method logs an error, TypeDoc will exit with the ValidationError exit code.

If it does deserve pulling out into its own class someday - I'd still want to avoid the component and emit that event from the application I think... I'm not convinced that there's value for plugins in seeing a new class.

@RebeccaStevens
Copy link
Contributor Author

RebeccaStevens commented Feb 25, 2023

@Gerrit0 I've reworked this PR to address those issues :)

@RebeccaStevens
Copy link
Contributor Author

When working on my plugin that relies on this PR, reflection.comment.getTags("@param") always return an empty array. I'm not having this issue with any other tags. Am I missing something for this tag or is this a bug?

src/lib/utils/events.ts Outdated Show resolved Hide resolved
* Emitted when validation is being run.
* The listener will be given an instance of {@link ProjectReflection}.
*/
static readonly EVENT_VALIDATION_RUN = ApplicationEvents.VALIDATION_RUN;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think validateProject might be better - it immediately implies that the callback will be passed a project, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ApplicationEvents.VALIDATE_PROJECT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, and validateProject for the string, otherwise lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's all set up :)

@Gerrit0 Gerrit0 merged commit 6ee136a into TypeStrong:master Feb 26, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 26, 2023

Thanks! Should release today.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 26, 2023

When working on my plugin that relies on this PR, reflection.comment.getTags("@param") always return an empty array. I'm not having this issue with any other tags. Am I missing something for this tag or is this a bug?

Just realized I forgot to answer this -- @param tags are moved to the ParameterReflection instances, so you generally shouldn't have any @param tags, your plugin should probably check that signatureReflection.parameters all have comments.

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.

Custom validation
2 participants