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

fix(eslint-plugin): [explicit-module-boundary-types] cyclical reference infinite recursion crash #2482

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -96,6 +96,10 @@ export default util.createRule<Options, MessageIds>({
// tracks functions that were found whilst traversing
const foundFunctions: FunctionNode[] = [];

// all nodes visited, avoids infinite recursion for cyclic references
// (such as class member referring to itself)
const alreadyVisited = new Set<TSESTree.Node>();

/*
# How the rule works:

Expand Down Expand Up @@ -311,9 +315,10 @@ export default util.createRule<Options, MessageIds>({
}

function checkNode(node: TSESTree.Node | null): void {
if (node == null) {
if (node == null || alreadyVisited.has(node)) {
return;
}
alreadyVisited.add(node);

switch (node.type) {
case AST_NODE_TYPES.ArrowFunctionExpression:
Expand Down
Expand Up @@ -654,6 +654,11 @@ export abstract class Foo<T> {
`
export declare class Foo {
set time(seconds: number);
}
`,
`
export class A {
b = A;
}
`,
],
Expand Down