change some manual array for loops to for..of
This commit is contained in:
parent
65a44a1e13
commit
19b05b5e61
@ -182,8 +182,8 @@ export function VariableDeclaration(node, print, parent) {
|
||||
var hasInits = false;
|
||||
// don't add whitespace to loop heads
|
||||
if (!t.isFor(parent)) {
|
||||
for (var i = 0; i < node.declarations.length; i++) {
|
||||
if (node.declarations[i].init) {
|
||||
for (var declar of (node.declarations: Array)) {
|
||||
if (declar.init) {
|
||||
// has an init so let's split it up over multiple lines
|
||||
hasInits = true;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ var hoistVariablesVisitor = explode({
|
||||
|
||||
var exprs = [];
|
||||
|
||||
for (var i = 0; i < node.declarations.length; i++) {
|
||||
for (var declar of (node.declarations: Array)) {
|
||||
var declar = node.declarations[i];
|
||||
if (declar.init) {
|
||||
exprs.push(t.expressionStatement(
|
||||
|
||||
@ -265,8 +265,8 @@ export default class Scope {
|
||||
if (node.source) {
|
||||
add(node.source);
|
||||
} else if (node.specifiers && node.specifiers.length) {
|
||||
for (var i = 0; i < node.specifiers.length; i++) {
|
||||
add(node.specifiers[i]);
|
||||
for (var specifier of (node.specifiers: Array)) {
|
||||
add(specifier);
|
||||
}
|
||||
} else if (node.declaration) {
|
||||
add(node.declaration);
|
||||
@ -283,8 +283,7 @@ export default class Scope {
|
||||
} else if (t.isCallExpression(node)) {
|
||||
add(node.callee);
|
||||
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
var prop = node.properties[i];
|
||||
for (var prop of (node.properties: Array)) {
|
||||
add(prop.key || prop.argument);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,13 +97,13 @@ export function booleanify(val: any): boolean {
|
||||
export function shouldIgnore(filename, ignore, only) {
|
||||
filename = slash(filename);
|
||||
if (only.length) {
|
||||
for (var i = 0; i < only.length; i++) {
|
||||
if (only[i].test(filename)) return false;
|
||||
for (var pattern of (only: Array)) {
|
||||
if (pattern.test(filename)) return false;
|
||||
}
|
||||
return true;
|
||||
} else if (ignore.length) {
|
||||
for (var i = 0; i < ignore.length; i++) {
|
||||
if (ignore[i].test(filename)) return true;
|
||||
for (var pattern of (ignore: Array)) {
|
||||
if (pattern.test(filename)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user