Skip to content

Commit 189c32a

Browse files
committed
refactor(plugins/x): simplify code in 'no-leaked-conditional-rendering' rule
1 parent 2a02d78 commit 189c32a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as AST from "@eslint-react/ast";
2-
import { _, flow, identity } from "@eslint-react/eff";
2+
import { _, flow } from "@eslint-react/eff";
33
import type { RuleContext, RuleFeature } from "@eslint-react/shared";
44
import { createReport, getSettingsFromContext } from "@eslint-react/shared";
55
import * as VAR from "@eslint-react/var";
@@ -253,10 +253,10 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
253253
})
254254
.with({ type: T.Identifier }, (n) => {
255255
const variable = VAR.findVariable(n.name, context.sourceCode.getScope(n));
256-
const initExpression = match(variable?.defs.at(0)?.node)
257-
.with({ init: P.select({ type: P.not(T.VariableDeclaration) }) }, identity)
256+
const variableDefNode = variable?.defs.at(0)?.node;
257+
return match(variableDefNode)
258+
.with({ init: P.select({ type: P.not(T.VariableDeclaration) }) }, getReportDescriptor)
258259
.otherwise(() => _);
259-
return getReportDescriptor(initExpression);
260260
})
261261
.otherwise(() => _);
262262
}

0 commit comments

Comments
 (0)