From 03d56dcea79b37237bfc3c60ef0715ecce68cd7c Mon Sep 17 00:00:00 2001 From: Willy Liao Date: Mon, 28 Mar 2022 16:09:19 +0800 Subject: [PATCH] Fix issue #3240 --- lib/rules/no-unused-state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/no-unused-state.js b/lib/rules/no-unused-state.js index cf8cbf917f..a142890c11 100644 --- a/lib/rules/no-unused-state.js +++ b/lib/rules/no-unused-state.js @@ -371,7 +371,7 @@ module.exports = { } const scope = childScope.variableScope.childScopes.find((x) => x.block === node.value); const stateArg = node.value.params[1]; // probably "state" - if (!scope.variables) { + if (!scope || !scope.variables) { return; } const argVar = scope.variables.find((x) => x.name === stateArg.name);