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

@@ -5,12 +5,12 @@ import * as t from "babel-types";
export default function (classPath) {
classPath.assertClass();
let memoisedExpressions = [];
const memoisedExpressions = [];
function maybeMemoise(path) {
if (!path.node || path.isPure()) return;
let uid = classPath.scope.generateDeclaredUidIdentifier();
const uid = classPath.scope.generateDeclaredUidIdentifier();
memoisedExpressions.push(t.assignmentExpression("=", uid, path.node));
path.replaceWith(uid);
}
@@ -24,7 +24,7 @@ export default function (classPath) {
// bind decorators if they're member expressions
bindifyDecorators(paths);
for (let path of paths) {
for (const path of paths) {
maybeMemoise(path);
}
}
@@ -32,8 +32,8 @@ export default function (classPath) {
maybeMemoise(classPath.get("superClass"));
memoiseDecorators(classPath.get("decorators"), true);
let methods: Array<NodePath> = classPath.get("body.body");
for (let methodPath of methods) {
const methods: Array<NodePath> = classPath.get("body.body");
for (const methodPath of methods) {
if (methodPath.is("computed")) {
maybeMemoise(methodPath.get("key"));
}