Pass with --fix

This commit is contained in:
Ray Schamp 2017-08-26 13:07:47 -04:00
parent a4d634d84d
commit 5113876588
14 changed files with 74 additions and 77 deletions

View file

@ -87,7 +87,7 @@ class Scratch3LooksBlocks {
* @return {Array.<!Thread>} Any threads started by this switch.
*/
_setCostumeOrBackdrop (target,
requestedCostume, optZeroIndex) {
requestedCostume, optZeroIndex) {
if (typeof requestedCostume === 'number') {
target.setCostume(optZeroIndex ?
requestedCostume : requestedCostume - 1);

View file

@ -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;

View file

@ -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
};
}

View file

@ -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;
}
}
}
};

View file

@ -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) {

View file

@ -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) {

View file

@ -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

View file

@ -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) {

View file

@ -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');

View file

@ -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,

View file

@ -120,7 +120,7 @@ class Cast {
const s2 = String(v2).toLowerCase();
return s1.localeCompare(s2);
}
// Compare as numbers.
// Compare as numbers.
return n1 - n2;
}

View file

@ -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];
}
}

View file

@ -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();
});

View file

@ -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();