Skip to content

Commit 2f1b083

Browse files
committed
Fix lint warning in react-dom codemod
1 parent b5b74c5 commit 2f1b083

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/react-codemod/transforms/react-to-react-dom.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,13 @@ module.exports = function(file, api) {
7474
.find(j.CallExpression)
7575
.filter(p => isRequire(p, coreModuleName))
7676
.forEach(p => {
77+
var name, scope;
7778
if (p.parent.value.type === 'VariableDeclarator') {
7879
if (p.parent.value.id.type === 'ObjectPattern') {
7980
var pattern = p.parent.value.id;
8081
var all = pattern.properties.every(function(prop) {
8182
if (prop.key.type === 'Identifier') {
82-
var name = prop.key.name;
83+
name = prop.key.name;
8384
return CORE_PROPERTIES.indexOf(name) !== -1;
8485
}
8586
return false;
@@ -101,8 +102,8 @@ module.exports = function(file, api) {
101102
'Unexpected destructuring in require of ' + coreModuleName
102103
);
103104
}
104-
var name = p.parent.value.id.name;
105-
var scope = p.scope.lookup(name);
105+
name = p.parent.value.id.name;
106+
scope = p.scope.lookup(name);
106107
if (scope.declares('ReactDOM')) {
107108
console.log('Using existing ReactDOM var in ' + file.path);
108109
domAlreadyDeclared = true;
@@ -119,8 +120,8 @@ module.exports = function(file, api) {
119120
'Unexpected destructuring in require of ' + coreModuleName
120121
);
121122
}
122-
var name = p.parent.value.left.name;
123-
var scope = p.scope.lookup(name);
123+
name = p.parent.value.left.name;
124+
scope = p.scope.lookup(name);
124125
var reactBindings = scope.getBindings()[name];
125126
if (reactBindings.length !== 1) {
126127
throw new Error(

0 commit comments

Comments
 (0)