enable prefer const (#5113)
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user