Updated eslint whitespace rules

This commit is contained in:
n1474335 2017-02-09 15:09:33 +00:00
parent ebf2258715
commit e803d208e8
51 changed files with 801 additions and 793 deletions

View File

@ -45,9 +45,7 @@
"comma-spacing": "error", "comma-spacing": "error",
"comma-style": "error", "comma-style": "error",
"computed-property-spacing": "error", "computed-property-spacing": "error",
"no-trailing-spaces": ["warn", { "no-trailing-spaces": "warn",
"skipBlankLines": true
}],
"eol-last": "error", "eol-last": "error",
"func-call-spacing": "error", "func-call-spacing": "error",
"indent": ["error", 4, { "indent": ["error", 4, {
@ -70,7 +68,19 @@
"ClassDeclaration": true, "ClassDeclaration": true,
"ArrowFunctionExpression": true "ArrowFunctionExpression": true
} }
}] }],
"keyword-spacing": ["error", {
"before": true,
"after": true
}],
"no-multiple-empty-lines": ["warn", {
"max": 2,
"maxEOF": 1,
"maxBOF": 0
}],
"no-whitespace-before-property": "error",
"operator-linebreak": ["error", "after"],
"space-in-parens": "error"
}, },
"globals": { "globals": {
/* core/* */ /* core/* */

View File

@ -113,7 +113,7 @@ Chef.prototype.silentBake = function(recipeConfig) {
try { try {
recipe.execute(dish); recipe.execute(dish);
} catch(err) { } catch (err) {
// Suppress all errors // Suppress all errors
} }
return new Date().getTime() - startTime; return new Date().getTime() - startTime;

View File

@ -70,7 +70,7 @@ var FlowControl = {
var dish = new Dish(inputs[i], inputType); var dish = new Dish(inputs[i], inputType);
try { try {
progress = recipe.execute(dish, 0); progress = recipe.execute(dish, 0);
} catch(err) { } catch (err) {
if (!ignoreErrors) { if (!ignoreErrors) {
throw err; throw err;
} }

View File

@ -922,8 +922,8 @@ var Utils = {
* @returns {Object} * @returns {Object}
*/ */
extend: function(a, b){ extend: function(a, b){
for(var key in b) for (var key in b)
if(b.hasOwnProperty(key)) if (b.hasOwnProperty(key))
a[key] = b[key]; a[key] = b[key];
return a; return a;
}, },
@ -1169,7 +1169,6 @@ String.prototype.count = function(chr) {
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Library overrides /////////////////////////////////////////////////////////////////////////////// // Library overrides ///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -153,7 +153,7 @@ var Checksum = {
var csum = 0; var csum = 0;
for (var i = 0; i < input.length; i++) { for (var i = 0; i < input.length; i++) {
if(i % 2 === 0) { if (i % 2 === 0) {
csum += (input[i] << 8); csum += (input[i] << 8);
} else { } else {
csum += input[i]; csum += input[i];

View File

@ -460,7 +460,7 @@ var Cipher = {
msgIndex = alphabet.indexOf(input[i]); msgIndex = alphabet.indexOf(input[i]);
// Subtract indexes from each other, add 26 just in case the value is negative, // Subtract indexes from each other, add 26 just in case the value is negative,
// modulo to remove if neccessary // modulo to remove if neccessary
output += alphabet[(msgIndex - keyIndex + alphabet.length ) % 26]; output += alphabet[(msgIndex - keyIndex + alphabet.length) % 26];
} else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) { } else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
chr = key[(i - fail) % key.length].toLowerCase(); chr = key[(i - fail) % key.length].toLowerCase();
keyIndex = alphabet.indexOf(chr); keyIndex = alphabet.indexOf(chr);

View File

@ -244,7 +244,7 @@ var Code = {
var i = 0, var i = 0,
level = 0; level = 0;
while (i < code.length) { while (i < code.length) {
switch(code[i]) { switch (code[i]) {
case "{": case "{":
level++; level++;
break; break;

View File

@ -140,7 +140,7 @@ var DateTime = {
try { try {
date = moment.tz(input, inputFormat, inputTimezone); date = moment.tz(input, inputFormat, inputTimezone);
if (!date || date.format() === "Invalid date") throw Error; if (!date || date.format() === "Invalid date") throw Error;
} catch(err) { } catch (err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES; return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
} }
@ -164,7 +164,7 @@ var DateTime = {
try { try {
date = moment.tz(input, inputFormat, inputTimezone); date = moment.tz(input, inputFormat, inputTimezone);
if (!date || date.format() === "Invalid date") throw Error; if (!date || date.format() === "Invalid date") throw Error;
} catch(err) { } catch (err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES; return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
} }

View File

@ -243,7 +243,6 @@ var HTML = {
}, },
/** /**
* Converts an HSL color value to RGB. Conversion formula * Converts an HSL color value to RGB. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_colorSpace. * adapted from http://en.wikipedia.org/wiki/HSL_colorSpace.
@ -309,7 +308,7 @@ var HTML = {
} else { } else {
var d = max - min; var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch(max) { switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break; case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break; case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break; case b: h = (r - g) / d + 4; break;

View File

@ -122,7 +122,7 @@ var JS = {
AST = escodegen.attachComments(AST, AST.comments, AST.tokens); AST = escodegen.attachComments(AST, AST.comments, AST.tokens);
result = escodegen.generate(AST, options); result = escodegen.generate(AST, options);
} catch(e) { } catch (e) {
// Leave original error so the user can see the detail // Leave original error so the user can see the detail
throw "Unable to parse JavaScript.<br>" + e.message; throw "Unable to parse JavaScript.<br>" + e.message;
} }

View File

@ -89,7 +89,7 @@ var MorseCode = {
words = Array.prototype.map.call(words, function(word) { words = Array.prototype.map.call(words, function(word) {
var letters = Array.prototype.map.call(word, function(character) { var letters = Array.prototype.map.call(word, function(character) {
var letter = character.toUpperCase(); var letter = character.toUpperCase();
if(typeof MorseCode.MORSE_TABLE[letter] == "undefined") { if (typeof MorseCode.MORSE_TABLE[letter] == "undefined") {
return ""; return "";
} }
@ -106,7 +106,7 @@ var MorseCode = {
input = input.replace( input = input.replace(
/<dash>|<dot>|<ld>|<wd>/g, /<dash>|<dot>|<ld>|<wd>/g,
function(match) { function(match) {
switch(match) { switch (match) {
case "<dash>": return dash; case "<dash>": return dash;
case "<dot>": return dot; case "<dot>": return dot;
case "<ld>": return letterDelim; case "<ld>": return letterDelim;
@ -131,14 +131,14 @@ var MorseCode = {
var reverseTable = function() { var reverseTable = function() {
reversedTable = {}; reversedTable = {};
for(var letter in MorseCode.MORSE_TABLE) { for (var letter in MorseCode.MORSE_TABLE) {
var signal = MorseCode.MORSE_TABLE[letter]; var signal = MorseCode.MORSE_TABLE[letter];
reversedTable[signal] = letter; reversedTable[signal] = letter;
} }
}; };
return function(input, args) { return function(input, args) {
if(reversedTable === null) { if (reversedTable === null) {
reverseTable(); reverseTable();
} }

View File

@ -86,7 +86,7 @@ var SeqUtils = {
var regex = new RegExp(search, "gi"), var regex = new RegExp(search, "gi"),
matches = input.match(regex); matches = input.match(regex);
return matches.length; return matches.length;
} catch(err) { } catch (err) {
return 0; return 0;
} }
} else if (search) { } else if (search) {

View File

@ -42,7 +42,7 @@ var URL_ = {
var data = input.replace(/\+/g, "%20"); var data = input.replace(/\+/g, "%20");
try { try {
return decodeURIComponent(data); return decodeURIComponent(data);
} catch(err) { } catch (err) {
return unescape(data); return unescape(data);
} }
}, },

View File

@ -192,7 +192,7 @@ ControlsWaiter.prototype.saveTextChange = function() {
try { try {
var recipeConfig = JSON.parse(document.getElementById("save-text").value); var recipeConfig = JSON.parse(document.getElementById("save-text").value);
this.initialiseSaveLink(recipeConfig); this.initialiseSaveLink(recipeConfig);
} catch(err) {} } catch (err) {}
}; };
@ -336,7 +336,7 @@ ControlsWaiter.prototype.loadButtonClick = function() {
this.app.setRecipeConfig(recipeConfig); this.app.setRecipeConfig(recipeConfig);
$("#rec-list [data-toggle=popover]").popover(); $("#rec-list [data-toggle=popover]").popover();
} catch(e) { } catch (e) {
this.app.alert("Invalid recipe", "danger", 2000); this.app.alert("Invalid recipe", "danger", 2000);
} }
}; };

View File

@ -362,13 +362,13 @@ HTMLApp.prototype.loadURIParams = function() {
try { try {
var recipeConfig = JSON.parse(this.queryString.recipe); var recipeConfig = JSON.parse(this.queryString.recipe);
this.setRecipeConfig(recipeConfig); this.setRecipeConfig(recipeConfig);
} catch(err) {} } catch (err) {}
} else if (this.queryString.op) { } else if (this.queryString.op) {
// If there's no recipe, look for single operations // If there's no recipe, look for single operations
this.manager.recipe.clearRecipe(); this.manager.recipe.clearRecipe();
try { try {
this.manager.recipe.addOperation(this.queryString.op); this.manager.recipe.addOperation(this.queryString.op);
} catch(err) { } catch (err) {
// If no exact match, search for nearest match and add that // If no exact match, search for nearest match and add that
var matchedOps = this.manager.ops.filterOperations(this.queryString.op, false); var matchedOps = this.manager.ops.filterOperations(this.queryString.op, false);
if (matchedOps.length) { if (matchedOps.length) {
@ -388,7 +388,7 @@ HTMLApp.prototype.loadURIParams = function() {
try { try {
var inputData = Utils.fromBase64(this.queryString.input); var inputData = Utils.fromBase64(this.queryString.input);
this.setInput(inputData); this.setInput(inputData);
} catch(err) {} } catch (err) {}
} }
// Restore auto-bake state // Restore auto-bake state

View File

@ -227,7 +227,7 @@ SeasonalWaiter.treeWalk = (function() {
while (node && node !== parent) { while (node && node !== parent) {
if (allNodes || node.nodeType === 1) { if (allNodes || node.nodeType === 1) {
if (fn(node) === false) { if (fn(node) === false) {
return(false); return false;
} }
} }
// If it's an element && // If it's an element &&