From 6e4cf108c8ed0c27c302f5d44925c7bee4180ef6 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 19 Mar 2023 09:36:14 +0100 Subject: [PATCH] fix: add missing types for onCodePath* in RuleListener --- packages/utils/src/ts-eslint/Rule.ts | 49 +++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/packages/utils/src/ts-eslint/Rule.ts b/packages/utils/src/ts-eslint/Rule.ts index ff3053863219..ace7f39449c8 100644 --- a/packages/utils/src/ts-eslint/Rule.ts +++ b/packages/utils/src/ts-eslint/Rule.ts @@ -38,6 +38,7 @@ interface RuleMetaDataDocs { */ extendsBaseRule?: boolean | string; } + interface RuleMetaData { /** * True if the rule is deprecated, false otherwise @@ -262,12 +263,39 @@ interface RuleContext< report(descriptor: ReportDescriptor): void; } +interface CodePath { + id: string; + initialSegment: CodePathSegment; + finalSegments: CodePathSegment[]; + returnedSegments: CodePathSegment[]; + thrownSegments: CodePathSegment[]; + currentSegments: CodePathSegment[]; + upper: CodePath | null; + childCodePaths: CodePath[]; +} + +interface CodePathSegment { + id: string; + nextSegments: CodePathSegment[]; + prevSegments: CodePathSegment[]; + reachable: boolean; +} + +type CodePathFunction = + | ((codePath: CodePath, node: TSESTree.Node) => void) + | ((segment: CodePathSegment, node: TSESTree.Node) => void) + | (( + fromSegment: CodePathSegment, + toSegment: CodePathSegment, + node: TSESTree.Node, + ) => void); + // This isn't the correct signature, but it makes it easier to do custom unions within reusable listeners // never will break someone's code unless they specifically type the function argument type RuleFunction = (node: T) => void; interface RuleListener { - [nodeSelector: string]: RuleFunction | undefined; + [nodeSelector: string]: RuleFunction | CodePathFunction | undefined; ArrayExpression?: RuleFunction; ArrayPattern?: RuleFunction; ArrowFunctionExpression?: RuleFunction; @@ -425,6 +453,22 @@ interface RuleListener { WhileStatement?: RuleFunction; WithStatement?: RuleFunction; YieldExpression?: RuleFunction; + + onCodePathStart?: (codePath: CodePath, node: TSESTree.Node) => void; + onCodePathEnd?: (codePath: CodePath, node: TSESTree.Node) => void; + onCodePathSegmentStart?: ( + segment: CodePathSegment, + node: TSESTree.Node, + ) => void; + onCodePathSegmentEnd?: ( + segment: CodePathSegment, + node: TSESTree.Node, + ) => void; + onCodePathSegmentLoop?: ( + fromSegment: CodePathSegment, + toSegment: CodePathSegment, + node: TSESTree.Node, + ) => void; } interface RuleModule< @@ -458,6 +502,9 @@ type RuleCreateFunction< > = (context: Readonly>) => TRuleListener; export { + CodePath, + CodePathSegment, + CodePathFunction, ReportDescriptor, ReportFixFunction, ReportSuggestionArray, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy