Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/types/index.d.ts
Comment thread
crimsonjay0 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,16 @@ export namespace Rule {
LangOptions: Linter.LanguageOptions;
Code: SourceCode;
RuleOptions: any[];
Visitor: NodeListener;
Visitor: RuleListener;
Node: JSSyntaxElement;
MessageIds: string;
ExtRuleDocs: {};
}> {
create(context: RuleContext): NodeListener;
create(context: RuleContext): RuleListener;
}

type NodeTypes = ESTree.Node["type"];
interface NodeListener extends RuleVisitor {
interface NodeListener {
ArrayExpression?:
| ((node: ESTree.ArrayExpression & NodeParentExtension) => void)
| undefined;
Expand Down Expand Up @@ -1105,6 +1105,16 @@ export namespace Rule {

onCodePathSegmentEnd?(segment: CodePathSegment, node: Node): void;

onUnreachableCodePathSegmentStart?(
segment: CodePathSegment,
node: Node,
): void;

onUnreachableCodePathSegmentEnd?(
segment: CodePathSegment,
node: Node,
): void;

onCodePathSegmentLoop?(
fromSegment: CodePathSegment,
toSegment: CodePathSegment,
Expand Down Expand Up @@ -1282,7 +1292,7 @@ export type JSRuleDefinition<
{
LangOptions: Linter.LanguageOptions;
Code: SourceCode;
Visitor: Rule.NodeListener;
Visitor: Rule.RuleListener;
Comment thread
crimsonjay0 marked this conversation as resolved.
Node: JSSyntaxElement;
},
Options
Expand Down
23 changes: 23 additions & 0 deletions tests/lib/types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ rule = {
},
onCodePathSegmentStart(segment, node) {},
onCodePathSegmentEnd(segment, node) {},
onUnreachableCodePathSegmentStart(segment, node) {},
onUnreachableCodePathSegmentEnd(segment, node) {},
onCodePathSegmentLoop(fromSegment, toSegment, node) {},
IfStatement(node) {
node.parent;
Expand Down Expand Up @@ -969,6 +971,27 @@ type DeprecatedRuleContextKeys =
},
});

(): JSRuleDefinition => ({
create() {
return {
onCodePathStart(codePath, node) {},
onCodePathSegmentStart(segment, node) {},
onCodePathSegmentLoop(fromSegment, toSegment, node) {},
Program(node) {},
"Program:exit"(node) {},
} satisfies Rule.RuleListener;
},
});

(): JSRuleDefinition => ({
// @ts-expect-error invalid return type
create() {
return {
foo: null,
};
},
});

// #endregion

// #region Linter
Expand Down
Loading