Skip to content

Commit 953faf0

Browse files
authored
Improve undefined tests to use _.get (#1504)
1 parent c794143 commit 953faf0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

eslint-rules/lib/utils/generalUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function findValueNodeOfIdentifier(identifierName, scope) {
2121
}
2222
});
2323
if (valueNode === false || _.isNil(valueNode) || valueNode.value !== undefined) {
24-
if (scope && scope.block && scope.block.body && scope.block.body.length > 0) {
24+
if (_.get(scope, 'block.body.length', 0) > 0) {
2525
scope.block.body.forEach(scopeNode => {
26-
if (scopeNode && scopeNode.type === 'ExpressionStatement') {
26+
if (_.get(scopeNode, 'type') === 'ExpressionStatement') {
2727
const variableName = _.get(scopeNode, 'expression.left.name');
28-
if (variableName === identifierName && scopeNode.expression && scopeNode.expression.right) {
28+
if (variableName === identifierName && _.get(scopeNode, 'expression.right')) {
2929
valueNode = scopeNode.expression.right;
3030
}
3131
}

eslint-rules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-uilib",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "uilib set of eslint rules",
55
"keywords": [
66
"eslint",

0 commit comments

Comments
 (0)