@samitouri / QOS-React-2 / commits / 2f1b08347c

Fix lint warning in react-dom codemod

Paul O’Shannessy committed Sep 8, 2015 at 23:06 UTC 2f1b08347c1b3790210bfd42d14a413447e1e7c8
1 file changed +6 -5
packages/react-codemod/transforms/react-to-react-dom.js
+6 -5
@@ -74,12 +74,13 @@ module.exports = function(file, api) {
74 .find(j.CallExpression)
75 .filter(p => isRequire(p, coreModuleName))
76 .forEach(p => {
77 + var name, scope;
78 if (p.parent.value.type === 'VariableDeclarator') {
79 if (p.parent.value.id.type === 'ObjectPattern') {
80 var pattern = p.parent.value.id;
81 var all = pattern.properties.every(function(prop) {
82 if (prop.key.type === 'Identifier') {
82 - var name = prop.key.name;
83 + name = prop.key.name;
84 return CORE_PROPERTIES.indexOf(name) !== -1;
85 }
86 return false;
@@ -101,8 +102,8 @@ module.exports = function(file, api) {
102 'Unexpected destructuring in require of ' + coreModuleName
103 );
104 }
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);
107 if (scope.declares('ReactDOM')) {
108 console.log('Using existing ReactDOM var in ' + file.path);
109 domAlreadyDeclared = true;
@@ -119,8 +120,8 @@ module.exports = function(file, api) {
120 'Unexpected destructuring in require of ' + coreModuleName
121 );
122 }
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);
125 var reactBindings = scope.getBindings()[name];
126 if (reactBindings.length !== 1) {
127 throw new Error(