Added eslint space-before-blocks rule

This commit is contained in:
n1474335 2019-08-27 18:13:33 +01:00
parent 44b90be7d6
commit 094d352e5f
17 changed files with 23 additions and 22 deletions

View File

@ -43,6 +43,7 @@
// stylistic conventions // stylistic conventions
"brace-style": ["error", "1tbs"], "brace-style": ["error", "1tbs"],
"space-before-blocks": ["error", "always"],
"block-spacing": "error", "block-spacing": "error",
"array-bracket-spacing": "error", "array-bracket-spacing": "error",
"comma-spacing": "error", "comma-spacing": "error",

View File

@ -109,7 +109,7 @@ export function mean(data) {
*/ */
export function median(data) { export function median(data) {
if ((data.length % 2) === 0 && data.length > 0) { if ((data.length % 2) === 0 && data.length > 0) {
data.sort(function(a, b){ data.sort(function(a, b) {
return a.minus(b); return a.minus(b);
}); });
const first = data[Math.floor(data.length / 2)]; const first = data[Math.floor(data.length / 2)];

View File

@ -327,13 +327,13 @@ export function convertCoordinates (input, inFormat, inDelim, outFormat, outDeli
* @param {string} input - The input data to be split * @param {string} input - The input data to be split
* @returns {number[]} An array of the different items in the string, stored as floats * @returns {number[]} An array of the different items in the string, stored as floats
*/ */
function splitInput (input){ function splitInput (input) {
const split = []; const split = [];
input.split(/\s+/).forEach(item => { input.split(/\s+/).forEach(item => {
// Remove any character that isn't a digit, decimal point or negative sign // Remove any character that isn't a digit, decimal point or negative sign
item = item.replace(/[^0-9.-]/g, ""); item = item.replace(/[^0-9.-]/g, "");
if (item.length > 0){ if (item.length > 0) {
// Turn the item into a float // Turn the item into a float
split.push(parseFloat(item)); split.push(parseFloat(item));
} }
@ -350,7 +350,7 @@ function splitInput (input){
* @param {number} precision - The precision the result should be rounded to * @param {number} precision - The precision the result should be rounded to
* @returns {{string: string, degrees: number}} An object containing the raw converted value (obj.degrees), and a formatted string version (obj.string) * @returns {{string: string, degrees: number}} An object containing the raw converted value (obj.degrees), and a formatted string version (obj.string)
*/ */
function convDMSToDD (degrees, minutes, seconds, precision){ function convDMSToDD (degrees, minutes, seconds, precision) {
const absDegrees = Math.abs(degrees); const absDegrees = Math.abs(degrees);
let conv = absDegrees + (minutes / 60) + (seconds / 3600); let conv = absDegrees + (minutes / 60) + (seconds / 3600);
let outString = round(conv, precision) + "°"; let outString = round(conv, precision) + "°";
@ -566,7 +566,7 @@ export function findFormat (input, delim) {
// Test DMS/DDM/DD formats // Test DMS/DDM/DD formats
if (testData !== undefined) { if (testData !== undefined) {
const split = splitInput(testData); const split = splitInput(testData);
switch (split.length){ switch (split.length) {
case 3: case 3:
return "Degrees Minutes Seconds"; return "Degrees Minutes Seconds";
case 2: case 2:

View File

@ -241,7 +241,7 @@ export function ipv6ListedRange(match, includeNetworkInfo) {
ipv6List = ipv6List.filter(function(str) { ipv6List = ipv6List.filter(function(str) {
return str.trim(); return str.trim();
}); });
for (let i =0; i < ipv6List.length; i++){ for (let i =0; i < ipv6List.length; i++) {
ipv6List[i] = ipv6List[i].trim(); ipv6List[i] = ipv6List[i].trim();
} }
const ipv6CidrList = ipv6List.filter(function(a) { const ipv6CidrList = ipv6List.filter(function(a) {
@ -502,8 +502,8 @@ export function ipv6Compare(a, b) {
const a_ = strToIpv6(a), const a_ = strToIpv6(a),
b_ = strToIpv6(b); b_ = strToIpv6(b);
for (let i = 0; i < a_.length; i++){ for (let i = 0; i < a_.length; i++) {
if (a_[i] !== b_[i]){ if (a_[i] !== b_[i]) {
return a_[i] - b_[i]; return a_[i] - b_[i];
} }
} }

View File

@ -85,7 +85,7 @@ function getWords(length=3) {
const words = []; const words = [];
let word; let word;
let previousWord; let previousWord;
while (words.length < length){ while (words.length < length) {
do { do {
word = wordList[Math.floor(Math.random() * wordList.length)]; word = wordList[Math.floor(Math.random() * wordList.length)];
} while (previousWord === word); } while (previousWord === word);

View File

@ -64,7 +64,7 @@ class BlurImage extends Operation {
throw new OperationError(`Error loading image. (${err})`); throw new OperationError(`Error loading image. (${err})`);
} }
try { try {
switch (blurType){ switch (blurType) {
case "Fast": case "Fast":
if (isWorkerEnvironment()) if (isWorkerEnvironment())
self.sendStatusMessage("Fast blurring image..."); self.sendStatusMessage("Fast blurring image...");

View File

@ -111,7 +111,7 @@ class DNSOverHTTPS extends Operation {
* @returns {JSON} * @returns {JSON}
*/ */
function extractData(data) { function extractData(data) {
if (typeof(data) == "undefined"){ if (typeof(data) == "undefined") {
return []; return [];
} else { } else {
const dataValues = []; const dataValues = [];

View File

@ -58,7 +58,7 @@ class FlipImage extends Operation {
try { try {
if (isWorkerEnvironment()) if (isWorkerEnvironment())
self.sendStatusMessage("Flipping image..."); self.sendStatusMessage("Flipping image...");
switch (flipAxis){ switch (flipAxis) {
case "Horizontal": case "Horizontal":
image.flip(true, false); image.flip(true, false);
break; break;

View File

@ -47,7 +47,7 @@ class GenerateLoremIpsum extends Operation {
*/ */
run(input, args) { run(input, args) {
const [length, lengthType] = args; const [length, lengthType] = args;
if (length < 1){ if (length < 1) {
throw new OperationError("Length must be greater than 0"); throw new OperationError("Length must be greater than 0");
} }
switch (lengthType) { switch (lengthType) {

View File

@ -48,7 +48,7 @@ class ImageFilter extends Operation {
*/ */
async run(input, args) { async run(input, args) {
const [filterType] = args; const [filterType] = args;
if (!isImage(new Uint8Array(input))){ if (!isImage(new Uint8Array(input))) {
throw new OperationError("Invalid file type."); throw new OperationError("Invalid file type.");
} }

View File

@ -34,7 +34,7 @@ class MicrosoftScriptDecoder extends Operation {
run(input, args) { run(input, args) {
const matcher = /#@~\^.{6}==(.+).{6}==\^#~@/; const matcher = /#@~\^.{6}==(.+).{6}==\^#~@/;
const encodedData = matcher.exec(input); const encodedData = matcher.exec(input);
if (encodedData){ if (encodedData) {
return MicrosoftScriptDecoder._decode(encodedData[1]); return MicrosoftScriptDecoder._decode(encodedData[1]);
} else { } else {
return ""; return "";

View File

@ -134,7 +134,7 @@ CMYK: ${cmyk}
static _hslToRgb(h, s, l) { static _hslToRgb(h, s, l) {
let r, g, b; let r, g, b;
if (s === 0){ if (s === 0) {
r = g = b = l; // achromatic r = g = b = l; // achromatic
} else { } else {
const hue2rgb = function hue2rgb(p, q, t) { const hue2rgb = function hue2rgb(p, q, t) {

View File

@ -62,7 +62,7 @@ class SharpenImage extends Operation {
async run(input, args) { async run(input, args) {
const [radius, amount, threshold] = args; const [radius, amount, threshold] = args;
if (!isImage(new Uint8Array(input))){ if (!isImage(new Uint8Array(input))) {
throw new OperationError("Invalid file type."); throw new OperationError("Invalid file type.");
} }

View File

@ -79,7 +79,7 @@ class SwapEndianness extends Operation {
const word = data.slice(i, i + wordLength); const word = data.slice(i, i + wordLength);
// Pad word if too short // Pad word if too short
if (padIncompleteWords && word.length < wordLength){ if (padIncompleteWords && word.length < wordLength) {
for (j = word.length; j < wordLength; j++) { for (j = word.length; j < wordLength; j++) {
word.push(0); word.push(0);
} }

View File

@ -51,7 +51,7 @@ class UNIXTimestampToWindowsFiletime extends Operation {
input = new BigNumber(input); input = new BigNumber(input);
if (units === "Seconds (s)"){ if (units === "Seconds (s)") {
input = input.multipliedBy(new BigNumber("10000000")); input = input.multipliedBy(new BigNumber("10000000"));
} else if (units === "Milliseconds (ms)") { } else if (units === "Milliseconds (ms)") {
input = input.multipliedBy(new BigNumber("10000")); input = input.multipliedBy(new BigNumber("10000"));
@ -65,7 +65,7 @@ class UNIXTimestampToWindowsFiletime extends Operation {
input = input.plus(new BigNumber("116444736000000000")); input = input.plus(new BigNumber("116444736000000000"));
if (format === "Hex"){ if (format === "Hex") {
return input.toString(16); return input.toString(16);
} else { } else {
return input.toFixed(); return input.toFixed();

View File

@ -57,7 +57,7 @@ class WindowsFiletimeToUNIXTimestamp extends Operation {
input = input.minus(new BigNumber("116444736000000000")); input = input.minus(new BigNumber("116444736000000000"));
if (units === "Seconds (s)"){ if (units === "Seconds (s)") {
input = input.dividedBy(new BigNumber("10000000")); input = input.dividedBy(new BigNumber("10000000"));
} else if (units === "Milliseconds (ms)") { } else if (units === "Milliseconds (ms)") {
input = input.dividedBy(new BigNumber("10000")); input = input.dividedBy(new BigNumber("10000"));

View File

@ -295,7 +295,7 @@ export function help(input) {
* bake [Wrapped] - Perform an array of operations on some input. * bake [Wrapped] - Perform an array of operations on some input.
* @returns {Function} * @returns {Function}
*/ */
export function bake(){ export function bake() {
/** /**
* bake * bake