enable prefer const (#5113)

This commit is contained in:
Henry Zhu
2017-01-14 09:48:52 -05:00
committed by GitHub
parent 982850731e
commit 672adba9a1
177 changed files with 1862 additions and 1863 deletions

View File

@@ -31,7 +31,7 @@ function getObjRef(node, nodes, file, scope) {
throw new Error(`We can't explode this node type ${node.type}`);
}
let temp = scope.generateUidIdentifierBasedOnNode(ref);
const temp = scope.generateUidIdentifierBasedOnNode(ref);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, ref)
]));
@@ -39,11 +39,11 @@ function getObjRef(node, nodes, file, scope) {
}
function getPropRef(node, nodes, file, scope) {
let prop = node.property;
let key = t.toComputedKey(node, prop);
const prop = node.property;
const key = t.toComputedKey(node, prop);
if (t.isLiteral(key) && t.isPureish(key)) return key;
let temp = scope.generateUidIdentifierBasedOnNode(prop);
const temp = scope.generateUidIdentifierBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, prop)
]));
@@ -73,8 +73,8 @@ export default function (
ref = node;
uid = obj;
} else {
let prop = getPropRef(node, nodes, file, scope);
let computed = node.computed || t.isLiteral(prop);
const prop = getPropRef(node, nodes, file, scope);
const computed = node.computed || t.isLiteral(prop);
uid = ref = t.memberExpression(obj, prop, computed);
}