Skip to content

Commit 935b0b0

Browse files
golopotljharb
authored andcommitted
[Refactor] no-render-return-value: reuse version test result
This commit likely fixes the performace issue noted in jsx-eslint#2259.
1 parent f39829f commit 935b0b0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/rules/no-render-return-value.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ module.exports = {
2727
// Public
2828
// --------------------------------------------------------------------------
2929

30+
let calleeObjectName = /^ReactDOM$/;
31+
if (versionUtil.testReactVersion(context, '15.0.0')) {
32+
calleeObjectName = /^ReactDOM$/;
33+
} else if (versionUtil.testReactVersion(context, '0.14.0')) {
34+
calleeObjectName = /^React(DOM)?$/;
35+
} else if (versionUtil.testReactVersion(context, '0.13.0')) {
36+
calleeObjectName = /^React$/;
37+
}
38+
3039
return {
3140

3241
CallExpression: function(node) {
@@ -36,15 +45,6 @@ module.exports = {
3645
return;
3746
}
3847

39-
let calleeObjectName = /^ReactDOM$/;
40-
if (versionUtil.testReactVersion(context, '15.0.0')) {
41-
calleeObjectName = /^ReactDOM$/;
42-
} else if (versionUtil.testReactVersion(context, '0.14.0')) {
43-
calleeObjectName = /^React(DOM)?$/;
44-
} else if (versionUtil.testReactVersion(context, '0.13.0')) {
45-
calleeObjectName = /^React$/;
46-
}
47-
4848
if (
4949
callee.object.type !== 'Identifier' ||
5050
!calleeObjectName.test(callee.object.name) ||

0 commit comments

Comments
 (0)