Skip to content

Commit

Permalink
[Refactor] no-render-return-value: reuse version test result
Browse files Browse the repository at this point in the history
This commit likely fixes the performace issue noted in jsx-eslint#2259.
  • Loading branch information
golopot authored and ljharb committed May 6, 2019
1 parent f39829f commit 935b0b0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/rules/no-render-return-value.js
Expand Up @@ -27,6 +27,15 @@ module.exports = {
// Public
// --------------------------------------------------------------------------

let calleeObjectName = /^ReactDOM$/;
if (versionUtil.testReactVersion(context, '15.0.0')) {
calleeObjectName = /^ReactDOM$/;
} else if (versionUtil.testReactVersion(context, '0.14.0')) {
calleeObjectName = /^React(DOM)?$/;
} else if (versionUtil.testReactVersion(context, '0.13.0')) {
calleeObjectName = /^React$/;
}

return {

CallExpression: function(node) {
Expand All @@ -36,15 +45,6 @@ module.exports = {
return;
}

let calleeObjectName = /^ReactDOM$/;
if (versionUtil.testReactVersion(context, '15.0.0')) {
calleeObjectName = /^ReactDOM$/;
} else if (versionUtil.testReactVersion(context, '0.14.0')) {
calleeObjectName = /^React(DOM)?$/;
} else if (versionUtil.testReactVersion(context, '0.13.0')) {
calleeObjectName = /^React$/;
}

if (
callee.object.type !== 'Identifier' ||
!calleeObjectName.test(callee.object.name) ||
Expand Down

0 comments on commit 935b0b0

Please sign in to comment.