mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #670 from rschamp/eslint-config-scratch-4
Update eslint and eslint-config-scratch
This commit is contained in:
commit
f367f2d358
19 changed files with 103 additions and 110 deletions
|
@ -31,8 +31,8 @@
|
|||
"babel-loader": "^7.0.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"copy-webpack-plugin": "4.0.1",
|
||||
"eslint": "^3.16.0",
|
||||
"eslint-config-scratch": "^3.1.0",
|
||||
"eslint": "^4.5.0",
|
||||
"eslint-config-scratch": "^4.0.0",
|
||||
"expose-loader": "0.7.3",
|
||||
"gh-pages": "^0.12.0",
|
||||
"got": "5.7.1",
|
||||
|
|
|
@ -106,22 +106,7 @@ class Scratch3MotionBlocks {
|
|||
}
|
||||
|
||||
glide (args, util) {
|
||||
if (!util.stackFrame.timer) {
|
||||
// First time: save data for future use.
|
||||
util.stackFrame.timer = new Timer();
|
||||
util.stackFrame.timer.start();
|
||||
util.stackFrame.duration = Cast.toNumber(args.SECS);
|
||||
util.stackFrame.startX = util.target.x;
|
||||
util.stackFrame.startY = util.target.y;
|
||||
util.stackFrame.endX = Cast.toNumber(args.X);
|
||||
util.stackFrame.endY = Cast.toNumber(args.Y);
|
||||
if (util.stackFrame.duration <= 0) {
|
||||
// Duration too short to glide.
|
||||
util.target.setXY(util.stackFrame.endX, util.stackFrame.endY);
|
||||
return;
|
||||
}
|
||||
util.yield();
|
||||
} else {
|
||||
if (util.stackFrame.timer) {
|
||||
const timeElapsed = util.stackFrame.timer.timeElapsed();
|
||||
if (timeElapsed < util.stackFrame.duration * 1000) {
|
||||
// In progress: move to intermediate position.
|
||||
|
@ -137,6 +122,21 @@ class Scratch3MotionBlocks {
|
|||
// Finished: move to final position.
|
||||
util.target.setXY(util.stackFrame.endX, util.stackFrame.endY);
|
||||
}
|
||||
} else {
|
||||
// First time: save data for future use.
|
||||
util.stackFrame.timer = new Timer();
|
||||
util.stackFrame.timer.start();
|
||||
util.stackFrame.duration = Cast.toNumber(args.SECS);
|
||||
util.stackFrame.startX = util.target.x;
|
||||
util.stackFrame.startY = util.target.y;
|
||||
util.stackFrame.endX = Cast.toNumber(args.X);
|
||||
util.stackFrame.endY = Cast.toNumber(args.Y);
|
||||
if (util.stackFrame.duration <= 0) {
|
||||
// Duration too short to glide.
|
||||
util.target.setXY(util.stackFrame.endX, util.stackFrame.endY);
|
||||
return;
|
||||
}
|
||||
util.yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -86,13 +86,11 @@ const execute = function (sequencer, thread) {
|
|||
sequencer.retireThread(thread);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (!resolvedValue) {
|
||||
// Not an edge-activated hat: retire the thread
|
||||
// if predicate was false.
|
||||
if (!resolvedValue) {
|
||||
sequencer.retireThread(thread);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// In a non-hat, report the value visually if necessary if
|
||||
// at the top of the thread stack.
|
||||
|
|
|
@ -228,14 +228,12 @@ class Sequencer {
|
|||
const doWarp = definitionBlock.mutation.warp;
|
||||
if (doWarp) {
|
||||
thread.peekStackFrame().warpMode = true;
|
||||
} else {
|
||||
} else if (isRecursive) {
|
||||
// In normal-mode threads, yield any time we have a recursive call.
|
||||
if (isRecursive) {
|
||||
thread.status = Thread.STATUS_YIELD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retire a thread in the middle, without considering further blocks.
|
||||
|
|
|
@ -40,10 +40,10 @@ class Mouse {
|
|||
*/
|
||||
postData (data) {
|
||||
if (data.x) {
|
||||
this._x = data.x - data.canvasWidth / 2;
|
||||
this._x = data.x - (data.canvasWidth / 2);
|
||||
}
|
||||
if (data.y) {
|
||||
this._y = data.y - data.canvasHeight / 2;
|
||||
this._y = data.y - (data.canvasHeight / 2);
|
||||
}
|
||||
if (typeof data.isDown !== 'undefined') {
|
||||
this._isDown = data.isDown;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -95,7 +95,7 @@ class Cast {
|
|||
* @return {boolean} True if the argument is all white spaces or null / empty.
|
||||
*/
|
||||
static isWhiteSpace (val) {
|
||||
return val === null || typeof val === 'string' && val.trim().length === 0;
|
||||
return val === null || (typeof val === 'string' && val.trim().length === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ test('repeat', t => {
|
|||
// Test harness (mocks `util`)
|
||||
let i = 0;
|
||||
const repeat = 10;
|
||||
var util = {
|
||||
const util = {
|
||||
stackFrame: Object.create(null),
|
||||
startBranch: function () {
|
||||
i++;
|
||||
|
@ -38,7 +38,7 @@ test('repeatUntil', t => {
|
|||
// Test harness (mocks `util`)
|
||||
let i = 0;
|
||||
const repeat = 10;
|
||||
var util = {
|
||||
const util = {
|
||||
stackFrame: Object.create(null),
|
||||
startBranch: function () {
|
||||
i++;
|
||||
|
|
|
@ -75,12 +75,12 @@ test('set and clear effects', t => {
|
|||
const a = new RenderedTarget(s, r);
|
||||
const renderer = new FakeRenderer();
|
||||
a.renderer = renderer;
|
||||
for (var effect in a.effects) {
|
||||
for (const effect in a.effects) {
|
||||
a.setEffect(effect, 1);
|
||||
t.equals(a.effects[effect], 1);
|
||||
}
|
||||
a.clearEffects();
|
||||
for (effect in a.effects) {
|
||||
for (const effect in a.effects) {
|
||||
t.equals(a.effects[effect], 0);
|
||||
}
|
||||
t.end();
|
||||
|
|
Loading…
Reference in a new issue