Skip to content

Commit

Permalink
Make ViolationReport generic
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Sep 25, 2024
1 parent 766986b commit 44a5660
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export interface RuleContext<
LangOptions = LanguageOptions,
Code extends SourceCode = SourceCode,
RuleOptions = unknown[],
Node = unknown,
> {
/**
* The current working directory for the session.
Expand Down Expand Up @@ -269,7 +270,7 @@ export interface RuleContext<
* The report function that the rule should use to report problems.
* @param violation The violation to report.
*/
report(violation: ViolationReport): void;
report(violation: ViolationReport<Node>): void;
}

// #region Rule Fixing
Expand Down Expand Up @@ -392,11 +393,11 @@ interface ViolationReportBase {
}

type ViolationMessage = { message: string } | { messageId: string };
type ViolationLocation = { loc: SourceLocation } | { node: object };
type ViolationLocation<Node> = { loc: SourceLocation } | { node: Node };

export type ViolationReport = ViolationReportBase &
export type ViolationReport<Node = unknown> = ViolationReportBase &
ViolationMessage &
ViolationLocation;
ViolationLocation<Node>;

// #region Suggestions

Expand Down

0 comments on commit 44a5660

Please sign in to comment.