enable prefer const (#5113)
This commit is contained in:
@@ -16,7 +16,7 @@ function toKind(node: Object) {
|
||||
}
|
||||
|
||||
export function push(mutatorMap: Object, node: Object, kind: string, file, scope?): Object {
|
||||
let alias = t.toKeyAlias(node);
|
||||
const alias = t.toKeyAlias(node);
|
||||
|
||||
//
|
||||
|
||||
@@ -36,7 +36,7 @@ export function push(mutatorMap: Object, node: Object, kind: string, file, scope
|
||||
}
|
||||
|
||||
if (node.decorators) {
|
||||
let decorators = map.decorators = map.decorators || t.arrayExpression([]);
|
||||
const decorators = map.decorators = map.decorators || t.arrayExpression([]);
|
||||
decorators.elements = decorators.elements.concat(node.decorators.map((dec) => dec.expression).reverse());
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export function push(mutatorMap: Object, node: Object, kind: string, file, scope
|
||||
value.returnType = node.returnType;
|
||||
}
|
||||
|
||||
let inheritedKind = toKind(node);
|
||||
const inheritedKind = toKind(node);
|
||||
if (!kind || inheritedKind !== "value") {
|
||||
kind = inheritedKind;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ export function push(mutatorMap: Object, node: Object, kind: string, file, scope
|
||||
}
|
||||
|
||||
export function hasComputed(mutatorMap: Object): boolean {
|
||||
for (let key in mutatorMap) {
|
||||
for (const key in mutatorMap) {
|
||||
if (mutatorMap[key]._computed) {
|
||||
return true;
|
||||
}
|
||||
@@ -86,11 +86,11 @@ export function hasComputed(mutatorMap: Object): boolean {
|
||||
}
|
||||
|
||||
export function toComputedObjectFromClass(obj: Object): Object {
|
||||
let objExpr = t.arrayExpression([]);
|
||||
const objExpr = t.arrayExpression([]);
|
||||
|
||||
for (let i = 0; i < obj.properties.length; i++) {
|
||||
let prop = obj.properties[i];
|
||||
let val = prop.value;
|
||||
const prop = obj.properties[i];
|
||||
const val = prop.value;
|
||||
val.properties.unshift(t.objectProperty(t.identifier("key"), t.toComputedKey(prop)));
|
||||
objExpr.elements.push(val);
|
||||
}
|
||||
@@ -99,20 +99,20 @@ export function toComputedObjectFromClass(obj: Object): Object {
|
||||
}
|
||||
|
||||
export function toClassObject(mutatorMap: Object): Object {
|
||||
let objExpr = t.objectExpression([]);
|
||||
const objExpr = t.objectExpression([]);
|
||||
|
||||
each(mutatorMap, function (map) {
|
||||
let mapNode = t.objectExpression([]);
|
||||
const mapNode = t.objectExpression([]);
|
||||
|
||||
let propNode = t.objectProperty(map._key, mapNode, map._computed);
|
||||
const propNode = t.objectProperty(map._key, mapNode, map._computed);
|
||||
|
||||
each(map, function (node, key) {
|
||||
if (key[0] === "_") return;
|
||||
|
||||
let inheritNode = node;
|
||||
const inheritNode = node;
|
||||
if (t.isClassMethod(node) || t.isClassProperty(node)) node = node.value;
|
||||
|
||||
let prop = t.objectProperty(t.identifier(key), node);
|
||||
const prop = t.objectProperty(t.identifier(key), node);
|
||||
t.inheritsComments(prop, inheritNode);
|
||||
t.removeComments(inheritNode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user