From 51138765882a5dd080f6a122b4977742589b6b39 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Sat, 26 Aug 2017 13:07:47 -0400 Subject: [PATCH] Pass with --fix --- src/blocks/scratch3_looks.js | 2 +- src/blocks/scratch3_pen.js | 2 +- src/blocks/scratch3_sound.js | 8 +-- src/engine/adapter.js | 96 +++++++++++++++++------------------ src/engine/blocks.js | 7 +-- src/engine/execute.js | 4 +- src/engine/list.js | 2 +- src/engine/sequencer.js | 6 +-- src/playground/playground.js | 8 +-- src/serialization/sb3.js | 4 +- src/util/cast.js | 2 +- src/util/string-util.js | 4 +- test/unit/blocks_operators.js | 4 +- test/unit/util_timer.js | 2 +- 14 files changed, 74 insertions(+), 77 deletions(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index 0caa04ff6..ca9dac2bd 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -87,7 +87,7 @@ class Scratch3LooksBlocks { * @return {Array.} Any threads started by this switch. */ _setCostumeOrBackdrop (target, - requestedCostume, optZeroIndex) { + requestedCostume, optZeroIndex) { if (typeof requestedCostume === 'number') { target.setCostume(optZeroIndex ? requestedCostume : requestedCostume - 1); diff --git a/src/blocks/scratch3_pen.js b/src/blocks/scratch3_pen.js index 13c0ed42b..a55074040 100644 --- a/src/blocks/scratch3_pen.js +++ b/src/blocks/scratch3_pen.js @@ -295,7 +295,7 @@ class Scratch3PenBlocks { penState.penAttributes.color4f[0] = rgb.r / 255.0; penState.penAttributes.color4f[1] = rgb.g / 255.0; penState.penAttributes.color4f[2] = rgb.b / 255.0; - if (rgb.hasOwnProperty('a')) { // Will there always be an 'a'? + if (rgb.hasOwnProperty('a')) { // Will there always be an 'a'? penState.penAttributes.color4f[3] = rgb.a / 255.0; } else { penState.penAttributes.color4f[3] = 1; diff --git a/src/blocks/scratch3_sound.js b/src/blocks/scratch3_sound.js index 6bd19ede2..1f7745742 100644 --- a/src/blocks/scratch3_sound.js +++ b/src/blocks/scratch3_sound.js @@ -51,20 +51,20 @@ class Scratch3SoundBlocks { return {min: 0, max: 100}; } - /** The minimum and maximum tempo values, in bpm. + /** The minimum and maximum tempo values, in bpm. * @type {{min: number, max: number}} */ static get TEMPO_RANGE () { return {min: 20, max: 500}; } - /** The minimum and maximum values for each sound effect. + /** The minimum and maximum values for each sound effect. * @type {{effect:{min: number, max: number}}} */ static get EFFECT_RANGE () { return { - pitch: {min: -600, max: 600}, // -5 to 5 octaves - pan: {min: -100, max: 100} // 100% left to 100% right + pitch: {min: -600, max: 600}, // -5 to 5 octaves + pan: {min: -100, max: 100} // 100% left to 100% right }; } diff --git a/src/engine/adapter.js b/src/engine/adapter.js index e9c7c3243..ffb8d043e 100644 --- a/src/engine/adapter.js +++ b/src/engine/adapter.js @@ -57,61 +57,61 @@ const domToBlock = function (blockDOM, blocks, isTopBlock, parent) { // as we won't be using all of them for Scratch. switch (xmlChild.name.toLowerCase()) { case 'field': - { - // Add the field to this block. - const fieldName = xmlChild.attribs.name; - // Add id in case it is a variable field - const fieldId = xmlChild.attribs.id; - let fieldData = ''; - if (xmlChild.children.length > 0 && xmlChild.children[0].data) { - fieldData = xmlChild.children[0].data; - } else { - // If the child of the field with a data property - // doesn't exist, set the data to an empty string. - fieldData = ''; - } - block.fields[fieldName] = { - name: fieldName, - id: fieldId, - value: fieldData - }; - break; + { + // Add the field to this block. + const fieldName = xmlChild.attribs.name; + // Add id in case it is a variable field + const fieldId = xmlChild.attribs.id; + let fieldData = ''; + if (xmlChild.children.length > 0 && xmlChild.children[0].data) { + fieldData = xmlChild.children[0].data; + } else { + // If the child of the field with a data property + // doesn't exist, set the data to an empty string. + fieldData = ''; } + block.fields[fieldName] = { + name: fieldName, + id: fieldId, + value: fieldData + }; + break; + } case 'value': case 'statement': - { - // Recursively generate block structure for input block. - domToBlock(childBlockNode, blocks, false, block.id); - if (childShadowNode && childBlockNode !== childShadowNode) { - // Also generate the shadow block. - domToBlock(childShadowNode, blocks, false, block.id); - } - // Link this block's input to the child block. - const inputName = xmlChild.attribs.name; - block.inputs[inputName] = { - name: inputName, - block: childBlockNode.attribs.id, - shadow: childShadowNode ? childShadowNode.attribs.id : null - }; - break; + { + // Recursively generate block structure for input block. + domToBlock(childBlockNode, blocks, false, block.id); + if (childShadowNode && childBlockNode !== childShadowNode) { + // Also generate the shadow block. + domToBlock(childShadowNode, blocks, false, block.id); } + // Link this block's input to the child block. + const inputName = xmlChild.attribs.name; + block.inputs[inputName] = { + name: inputName, + block: childBlockNode.attribs.id, + shadow: childShadowNode ? childShadowNode.attribs.id : null + }; + break; + } case 'next': - { - if (!childBlockNode || !childBlockNode.attribs) { - // Invalid child block. - continue; - } - // Recursively generate block structure for next block. - domToBlock(childBlockNode, blocks, false, block.id); - // Link next block to this block. - block.next = childBlockNode.attribs.id; - break; + { + if (!childBlockNode || !childBlockNode.attribs) { + // Invalid child block. + continue; } + // Recursively generate block structure for next block. + domToBlock(childBlockNode, blocks, false, block.id); + // Link next block to this block. + block.next = childBlockNode.attribs.id; + break; + } case 'mutation': - { - block.mutation = mutationAdapter(xmlChild); - break; - } + { + block.mutation = mutationAdapter(xmlChild); + break; + } } } }; diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 85aeabfb8..e0dce87b8 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -52,7 +52,7 @@ class Blocks { return this._scripts; } - /** + /** * Get the next block for a particular block * @param {?string} id ID of block to get the next block for * @return {?string} ID of next block in the sequence @@ -458,10 +458,7 @@ class Blocks { `<${tagName} id="${block.id}" type="${block.opcode}" - ${block.topLevel ? - `x="${block.x}" y="${block.y}"` : - '' - } + ${block.topLevel ? `x="${block.x}" y="${block.y}"` : ''} >`; // Add any mutation. Must come before inputs. if (block.mutation) { diff --git a/src/engine/execute.js b/src/engine/execute.js index 1f5a25b35..06a320e9e 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -66,8 +66,8 @@ const execute = function (sequencer, thread) { * or after a promise resolves. * @param {*} resolvedValue Value eventually returned from the primitive. */ - // @todo move this to callback attached to the thread when we have performance - // metrics (dd) + // @todo move this to callback attached to the thread when we have performance + // metrics (dd) const handleReport = function (resolvedValue) { thread.pushReportedValue(resolvedValue); if (isHat) { diff --git a/src/engine/list.js b/src/engine/list.js index bf6e8bc06..0f3ec0f2b 100644 --- a/src/engine/list.js +++ b/src/engine/list.js @@ -3,7 +3,7 @@ * Object representing a Scratch list. */ - /** +/** * @param {!string} name Name of the list. * @param {Array} contents Contents of the list, as an array. * @constructor diff --git a/src/engine/sequencer.js b/src/engine/sequencer.js index d5c79eae9..fb2c7060a 100644 --- a/src/engine/sequencer.js +++ b/src/engine/sequencer.js @@ -70,7 +70,7 @@ class Sequencer { this.stepThread(activeThread); activeThread.warpTimer = null; if (activeThread.isKilled) { - i--; // if the thread is removed from the list (killed), do not increase index + i--; // if the thread is removed from the list (killed), do not increase index } } if (activeThread.status === Thread.STATUS_RUNNING) { @@ -158,8 +158,8 @@ class Sequencer { // to be re-executed. return; } - // Don't go to the next block for this level of the stack, - // since loops need to be re-executed. + // Don't go to the next block for this level of the stack, + // since loops need to be re-executed. continue; } else if (stackFrame.waitingReporter) { diff --git a/src/playground/playground.js b/src/playground/playground.js index d9aac1c30..2c1ef3308 100644 --- a/src/playground/playground.js +++ b/src/playground/playground.js @@ -288,10 +288,10 @@ window.onload = function () { vm.setTurboMode(turboOn); }); document.getElementById('compatmode').addEventListener('change', - () => { - const compatibilityMode = document.getElementById('compatmode').checked; - vm.setCompatibilityMode(compatibilityMode); - }); + () => { + const compatibilityMode = document.getElementById('compatmode').checked; + vm.setCompatibilityMode(compatibilityMode); + }); const tabBlockExplorer = document.getElementById('tab-blockexplorer'); const tabThreadExplorer = document.getElementById('tab-threadexplorer'); const tabRenderExplorer = document.getElementById('tab-renderexplorer'); diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index 35267a5e2..f8556b6d9 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -60,7 +60,7 @@ const parseScratchObject = function (object, runtime) { sprite.name = object.name; } if (object.hasOwnProperty('blocks')) { - for (let blockId in object.blocks) { + for (const blockId in object.blocks) { blocks.createBlock(object.blocks[blockId]); } // console.log(blocks); @@ -100,7 +100,7 @@ const parseScratchObject = function (object, runtime) { const target = sprite.createClone(); // Load target properties from JSON. if (object.hasOwnProperty('variables')) { - for (let j in object.variables) { + for (const j in object.variables) { const variable = object.variables[j]; const newVariable = new Variable( variable.id, diff --git a/src/util/cast.js b/src/util/cast.js index c000ee1d9..d859d32ec 100644 --- a/src/util/cast.js +++ b/src/util/cast.js @@ -120,7 +120,7 @@ class Cast { const s2 = String(v2).toLowerCase(); return s1.localeCompare(s2); } - // Compare as numbers. + // Compare as numbers. return n1 - n2; } diff --git a/src/util/string-util.js b/src/util/string-util.js index 48dde0277..b71054a04 100644 --- a/src/util/string-util.js +++ b/src/util/string-util.js @@ -32,9 +32,9 @@ class StringUtil { const index = text.indexOf(separator); if (index >= 0) { return [text.substring(0, index), text.substring(index + 1)]; - } else { - return [text, null]; } + return [text, null]; + } } diff --git a/test/unit/blocks_operators.js b/test/unit/blocks_operators.js index 9f43603f5..d0dcbd551 100644 --- a/test/unit/blocks_operators.js +++ b/test/unit/blocks_operators.js @@ -28,8 +28,8 @@ test('multiply', t => { test('divide', t => { t.strictEqual(blocks.divide({NUM1: '2', NUM2: '2'}), 1); - t.strictEqual(blocks.divide({NUM1: '1', NUM2: '0'}), Infinity); // @todo - t.ok(isNaN(blocks.divide({NUM1: 'foo', NUM2: 'bar'}))); // @todo + t.strictEqual(blocks.divide({NUM1: '1', NUM2: '0'}), Infinity); // @todo + t.ok(isNaN(blocks.divide({NUM1: 'foo', NUM2: 'bar'}))); // @todo t.end(); }); diff --git a/test/unit/util_timer.js b/test/unit/util_timer.js index 5c0f21790..bf6d6b9ac 100644 --- a/test/unit/util_timer.js +++ b/test/unit/util_timer.js @@ -26,7 +26,7 @@ test('time', t => { test('start / timeElapsed', t => { const timer = new Timer(); const delay = 100; - const threshold = 1000 / 60; // 60 hz + const threshold = 1000 / 60; // 60 hz // Start timer timer.start();