Skip to content

Commit

Permalink
rewrite cases where js beautify and eslint disagree on formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jun 20, 2016
1 parent e74b2f9 commit cf00a1a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 42 deletions.
6 changes: 2 additions & 4 deletions hot/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ if(module.hot) {
}

}).catch(function(err) {
if(module.hot.status() in {
abort: 1,
fail: 1
}) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
console.warn("[HMR] Cannot apply update. Need to do a full reload!");
console.warn("[HMR] " + err.stack || err.message);
window.location.reload();
Expand Down
12 changes: 4 additions & 8 deletions hot/only-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,17 @@ if(module.hot) {
console.log("[HMR] App is up to date.");
}
}).catch(function(err) {
if(module.hot.status() in {
abort: 1,
fail: 1
}) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
console.warn("[HMR] Cannot apply update. Need to do a full reload!");
console.warn("[HMR] " + err.stack || err.message);
} else {
console.warn("[HMR] Update failed: " + err.stack || err.message);
}
});
}).catch(function(err) {
if(module.hot.status() in {
abort: 1,
fail: 1
}) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
console.warn("[HMR] Cannot check for update. Need to do a full reload!");
console.warn("[HMR] " + err.stack || err.message);
} else {
Expand Down
6 changes: 2 additions & 4 deletions hot/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ if(module.hot) {
require("./log-apply-result")(updatedModules, updatedModules);
checkForUpdate(true);
}).catch(function(err) {
if(module.hot.status() in {
abort: 1,
fail: 1
}) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
console.warn("[HMR] Cannot apply update.");
console.warn("[HMR] " + err.stack || err.message);
console.warn("[HMR] You need to restart the application!");
Expand Down
12 changes: 4 additions & 8 deletions hot/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ if(module.hot) {
ignoreUnaccepted: true
}, function(err, renewedModules) {
if(err) {
if(module.hot.status() in {
abort: 1,
fail: 1
}) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
console.warn("[HMR] Cannot apply update (Need to do a full reload!)");
console.warn("[HMR] " + err.stack || err.message);
console.warn("[HMR] You need to restart the application!");
Expand All @@ -36,10 +34,8 @@ if(module.hot) {
checkForUpdate(true);
});
}).catch(function(err) {
if(module.hot.status() in {
abort: 1,
fail: 1
}) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
console.warn("[HMR] Cannot apply update.");
console.warn("[HMR] " + err.stack || err.message);
console.warn("[HMR] You need to restart the application!");
Expand Down
22 changes: 12 additions & 10 deletions lib/NormalModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ NormalModule.prototype.build = function build(options, compilation, resolver, fs
this.blocks.length = 0;
this._cachedSource = null;
if(options.module && options.module.noParse) {
function testRegExp(regExp) {
return typeof regExp === "string" ?
this.request.indexOf(regExp) === 0 :
regExp.test(this.request);
}
if(Array.isArray(options.module.noParse)) {
if(options.module.noParse.some(function(regExp) {
return typeof regExp === "string" ?
this.request.indexOf(regExp) === 0 :
regExp.test(this.request);
}, this)) return callback();
} else if(typeof options.module.noParse === "string" ?
this.request.indexOf(options.module.noParse) === 0 :
options.module.noParse.test(this.request)) {
if(options.module.noParse.some(testRegExp, this))
return callback();
} else if(testRegExp.call(this, options.module.noParse)) {
return callback();
}
}
Expand Down Expand Up @@ -230,9 +230,11 @@ NormalModule.prototype.source = function(dependencyTemplates, outputOptions, req
function doVariable(availableVars, vars, variable) {
var name = variable.name;
var expr = variable.expressionSource(dependencyTemplates, outputOptions, requestShortener);
if(availableVars.some(function(v) {

function isEqual(v) {
return v.name === name && v.expression.source() === expr.source();
})) return;
}
if(availableVars.some(isEqual)) return;
vars.push({
name: name,
expression: expr
Expand Down
4 changes: 1 addition & 3 deletions lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ Parser.prototype.initializeEvaluating = function() {
var items = expr.elements.map(function(element) {
return element !== null && this.evaluateExpression(element);
}, this);
if(items.filter(function(i) {
return !i;
}).length > 0) return;
if(!items.every(Boolean)) return;
return new BasicEvaluatedExpression().setItems(items).setRange(expr.range);
});
};
Expand Down
8 changes: 5 additions & 3 deletions lib/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ Template.prototype.asString = function(str) {
return str;
};

function moduleIdIsNumber(module) {
return typeof module.id === "number";
}

Template.prototype.getModulesArrayBounds = function(modules) {
if(modules.some(function(module) {
return typeof module.id !== "number";
}))
if(!modules.every(moduleIdIsNumber))
return false;
var maxId = -Infinity;
var minId = Infinity;
Expand Down
6 changes: 4 additions & 2 deletions lib/optimize/RemoveParentModulesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ function debugIds(chunks) {
var list = chunks.map(function(chunk) {
return chunk.debugId;
});
if(list.some(function(dId) {
var debugIdMissing = list.some(function(dId) {
return typeof dId !== "number";
})) return "no";
});
if(debugIdMissing)
return "no";
list.sort();
return list.join(",");
}
Expand Down

0 comments on commit cf00a1a

Please sign in to comment.