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): [no-non-null-asserted-optional-chain] infinite loop problem #5367

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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 @@ -104,12 +104,13 @@ export default util.createRule({
const node = child.parent as TSESTree.TSNonNullExpression;

let current = child;
while (current) {
let isRight = true;
while (current && isRight) {
switch (current.type) {
case AST_NODE_TYPES.MemberExpression:
if (current.optional) {
// found an optional chain! stop traversing
break;
isRight = false;
}

current = current.object;
Expand All @@ -118,7 +119,7 @@ export default util.createRule({
case AST_NODE_TYPES.CallExpression:
if (current.optional) {
// found an optional chain! stop traversing
break;
isRight = false;
}

current = current.callee;
Expand Down