Skip to content

Commit

Permalink
Merge pull request #4151 from scratchfoundation/renovate/major-eslint…
Browse files Browse the repository at this point in the history
…-config-scratch

chore(deps): update eslint-config-scratch (major)
  • Loading branch information
cwillisf committed Dec 16, 2023
2 parents 1abce08 + 7d5a780 commit ef86783
Show file tree
Hide file tree
Showing 37 changed files with 3,563 additions and 2,473 deletions.
5,597 changes: 3,318 additions & 2,279 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"callsite": "1.0.0",
"copy-webpack-plugin": "4.5.4",
"docdash": "1.2.0",
"eslint": "5.3.0",
"eslint-config-scratch": "5.1.0",
"eslint": "8.55.0",
"eslint-config-scratch": "9.0.3",
"expose-loader": "0.7.5",
"file-loader": "2.0.0",
"format-message-cli": "6.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/scratch3_looks.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ class Scratch3LooksBlocks {
changeEffect (args, util) {
const effect = Cast.toString(args.EFFECT).toLowerCase();
const change = Cast.toNumber(args.CHANGE);
if (!util.target.effects.hasOwnProperty(effect)) return;
if (!Object.prototype.hasOwnProperty.call(util.target.effects, effect)) return;
let newValue = change + util.target.effects[effect];
newValue = this.clampEffect(effect, newValue);
util.target.setEffect(effect, newValue);
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/scratch3_procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Scratch3ProcedureBlocks {
// at earlier stack frames for the values of a given parameter (#1729)
util.initParams();
for (let i = 0; i < paramIds.length; i++) {
if (args.hasOwnProperty(paramIds[i])) {
if (Object.prototype.hasOwnProperty.call(args, paramIds[i])) {
util.pushParam(paramNames[i], args[paramIds[i]]);
} else {
util.pushParam(paramNames[i], paramDefaults[i]);
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/scratch3_sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Scratch3SoundBlocks {
const value = Cast.toNumber(args.VALUE);

const soundState = this._getSoundState(util.target);
if (!soundState.effects.hasOwnProperty(effect)) return;
if (!Object.prototype.hasOwnProperty.call(soundState.effects, effect)) return;

if (change) {
soundState.effects[effect] += value;
Expand Down Expand Up @@ -297,7 +297,7 @@ class Scratch3SoundBlocks {
_clearEffectsForTarget (target) {
const soundState = this._getSoundState(target);
for (const effect in soundState.effects) {
if (!soundState.effects.hasOwnProperty(effect)) continue;
if (!Object.prototype.hasOwnProperty.call(soundState.effects, effect)) continue;
soundState.effects[effect] = 0;
}
this._syncEffectsForTarget(target);
Expand Down
4 changes: 3 additions & 1 deletion src/dispatch/central-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class CentralDispatch extends SharedDispatch {
throw new Error(`Cannot use 'callSync' on remote provider for service ${service}.`);
}

// TODO: verify correct `this` after switching from apply to spread
// eslint-disable-next-line prefer-spread
return provider[method].apply(provider, args);
}
throw new Error(`Provider not found for service: ${service}`);
Expand All @@ -62,7 +64,7 @@ class CentralDispatch extends SharedDispatch {
* @param {object} provider - a local object which provides this service.
*/
setServiceSync (service, provider) {
if (this.services.hasOwnProperty(service)) {
if (Object.prototype.hasOwnProperty.call(this.services, service)) {
log.warn(`Central dispatch replacing existing service provider for ${service}`);
}
this.services[service] = provider;
Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/shared-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class SharedDispatch {
return this._remoteTransferCall(provider, service, method, transfer, ...args);
}

// TODO: verify correct `this` after switching from apply to spread
// eslint-disable-next-line prefer-spread
const result = provider[method].apply(provider, args);
return Promise.resolve(result);
}
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/worker-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class WorkerDispatch extends SharedDispatch {
* @returns {Promise} - a promise which will resolve once the service is registered.
*/
setService (service, provider) {
if (this.services.hasOwnProperty(service)) {
if (Object.prototype.hasOwnProperty.call(this.services, service)) {
log.warn(`Worker dispatch replacing existing service provider for ${service}`);
}
this.services[service] = provider;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const domToBlocks = function (blocksDOM) {
// Flatten blocks object into a list.
const blocksList = [];
for (const b in blocks) {
if (!blocks.hasOwnProperty(b)) continue;
if (!Object.prototype.hasOwnProperty.call(blocks, b)) continue;
blocksList.push(blocks[b]);
}
return blocksList;
Expand Down
2 changes: 2 additions & 0 deletions src/engine/block-utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class BlockUtility {
this.sequencer.runtime.ioDevices[device] &&
this.sequencer.runtime.ioDevices[device][func]) {
const devObject = this.sequencer.runtime.ioDevices[device];
// TODO: verify correct `this` after switching from apply to spread
// eslint-disable-next-line prefer-spread
return devObject[func].apply(devObject, args);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/blocks-runtime-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RuntimeScriptCache {
if (Object.keys(fields).length === 0) {
const inputs = container.getInputs(block);
for (const input in inputs) {
if (!inputs.hasOwnProperty(input)) continue;
if (!Object.prototype.hasOwnProperty.call(inputs, input)) continue;
const id = inputs[input].block;
const inputBlock = container.getBlock(id);
const inputFields = container.getFields(inputBlock);
Expand Down
45 changes: 23 additions & 22 deletions src/engine/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class Blocks {
}

for (const id in this._blocks) {
if (!this._blocks.hasOwnProperty(id)) continue;
if (!Object.prototype.hasOwnProperty.call(this._blocks, id)) continue;
const block = this._blocks[id];
if (block.opcode === 'procedures_definition') {
const internal = this._getCustomBlockInternal(block);
Expand Down Expand Up @@ -267,7 +267,7 @@ class Blocks {
}

for (const id in this._blocks) {
if (!this._blocks.hasOwnProperty(id)) continue;
if (!Object.prototype.hasOwnProperty.call(this._blocks, id)) continue;
const block = this._blocks[id];
if (block.opcode === 'procedures_prototype' &&
block.mutation.proccode === name) {
Expand Down Expand Up @@ -357,7 +357,7 @@ class Blocks {
case 'delete':
// Don't accept delete events for missing blocks,
// or shadow blocks being obscured.
if (!this._blocks.hasOwnProperty(e.blockId) ||
if (!Object.prototype.hasOwnProperty.call(this._blocks, e.blockId) ||
this._blocks[e.blockId].shadow) {
return;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ class Blocks {
}
break;
case 'var_rename':
if (editingTarget && editingTarget.variables.hasOwnProperty(e.varId)) {
if (editingTarget && Object.prototype.hasOwnProperty.call(editingTarget.variables, e.varId)) {
// This is a local variable, rename on the current target
editingTarget.renameVariable(e.varId, e.newName);
// Update all the blocks on the current target that use
Expand All @@ -416,7 +416,7 @@ class Blocks {
this.emitProjectChanged();
break;
case 'var_delete': {
const target = (editingTarget && editingTarget.variables.hasOwnProperty(e.varId)) ?
const target = (editingTarget && Object.prototype.hasOwnProperty.call(editingTarget.variables, e.varId)) ?
editingTarget : stage;
target.deleteVariable(e.varId);
this.emitProjectChanged();
Expand Down Expand Up @@ -445,20 +445,21 @@ class Blocks {
case 'comment_change':
if (this.runtime.getEditingTarget()) {
const currTarget = this.runtime.getEditingTarget();
if (!currTarget.comments.hasOwnProperty(e.commentId)) {
if (!Object.prototype.hasOwnProperty.call(currTarget.comments, e.commentId)) {
log.warn(`Cannot change comment with id ${e.commentId} because it does not exist.`);
return;
}
const comment = currTarget.comments[e.commentId];
const change = e.newContents_;
if (change.hasOwnProperty('minimized')) {
if (Object.prototype.hasOwnProperty.call(change, 'minimized')) {
comment.minimized = change.minimized;
}
if (change.hasOwnProperty('width') && change.hasOwnProperty('height')){
if (Object.prototype.hasOwnProperty.call(change, 'width') &&
Object.prototype.hasOwnProperty.call(change, 'height')) {
comment.width = change.width;
comment.height = change.height;
}
if (change.hasOwnProperty('text')) {
if (Object.prototype.hasOwnProperty.call(change, 'text')) {
comment.text = change.text;
}
this.emitProjectChanged();
Expand All @@ -467,7 +468,7 @@ class Blocks {
case 'comment_move':
if (this.runtime.getEditingTarget()) {
const currTarget = this.runtime.getEditingTarget();
if (currTarget && !currTarget.comments.hasOwnProperty(e.commentId)) {
if (currTarget && !Object.prototype.hasOwnProperty.call(currTarget.comments, e.commentId)) {
log.warn(`Cannot change comment with id ${e.commentId} because it does not exist.`);
return;
}
Expand All @@ -482,7 +483,7 @@ class Blocks {
case 'comment_delete':
if (this.runtime.getEditingTarget()) {
const currTarget = this.runtime.getEditingTarget();
if (!currTarget.comments.hasOwnProperty(e.commentId)) {
if (!Object.prototype.hasOwnProperty.call(currTarget.comments, e.commentId)) {
// If we're in this state, we have probably received
// a delete event from a workspace that we switched from
// (e.g. a delete event for a comment on sprite a's workspace
Expand Down Expand Up @@ -536,7 +537,7 @@ class Blocks {
createBlock (block) {
// Does the block already exist?
// Could happen, e.g., for an unobscured shadow.
if (this._blocks.hasOwnProperty(block.id)) {
if (Object.prototype.hasOwnProperty.call(this._blocks, block.id)) {
return;
}
// Create new block.
Expand Down Expand Up @@ -650,7 +651,7 @@ class Blocks {
}

const isSpriteSpecific = isSpriteLocalVariable ||
(this.runtime.monitorBlockInfo.hasOwnProperty(block.opcode) &&
(Object.prototype.hasOwnProperty.call(this.runtime.monitorBlockInfo, block.opcode) &&
this.runtime.monitorBlockInfo[block.opcode].isSpriteSpecific);
if (isSpriteSpecific) {
// If creating a new sprite specific monitor, the only possible target is
Expand Down Expand Up @@ -692,7 +693,7 @@ class Blocks {
* @param {!object} e Blockly move event to be processed
*/
moveBlock (e) {
if (!this._blocks.hasOwnProperty(e.id)) {
if (!Object.prototype.hasOwnProperty.call(this._blocks, e.id)) {
return;
}

Expand Down Expand Up @@ -740,7 +741,7 @@ class Blocks {
// Moved to the new parent's input.
// Don't obscure the shadow block.
let oldShadow = null;
if (this._blocks[e.newParent].inputs.hasOwnProperty(e.newInput)) {
if (Object.prototype.hasOwnProperty.call(this._blocks[e.newParent].inputs, e.newInput)) {
oldShadow = this._blocks[e.newParent].inputs[e.newInput].shadow;
}

Expand Down Expand Up @@ -990,7 +991,7 @@ class Blocks {
*/
_getCostumeField (blockId) {
const block = this.getBlock(blockId);
if (block && block.fields.hasOwnProperty('COSTUME')) {
if (block && Object.prototype.hasOwnProperty.call(block.fields, 'COSTUME')) {
return block.fields.COSTUME;
}
return null;
Expand All @@ -1005,7 +1006,7 @@ class Blocks {
*/
_getSoundField (blockId) {
const block = this.getBlock(blockId);
if (block && block.fields.hasOwnProperty('SOUND_MENU')) {
if (block && Object.prototype.hasOwnProperty.call(block.fields, 'SOUND_MENU')) {
return block.fields.SOUND_MENU;
}
return null;
Expand All @@ -1020,7 +1021,7 @@ class Blocks {
*/
_getBackdropField (blockId) {
const block = this.getBlock(blockId);
if (block && block.fields.hasOwnProperty('BACKDROP')) {
if (block && Object.prototype.hasOwnProperty.call(block.fields, 'BACKDROP')) {
return block.fields.BACKDROP;
}
return null;
Expand All @@ -1042,7 +1043,7 @@ class Blocks {
'DISTANCETOMENU', 'TOUCHINGOBJECTMENU', 'CLONE_OPTION'];
for (let i = 0; i < spriteMenuNames.length; i++) {
const menuName = spriteMenuNames[i];
if (block.fields.hasOwnProperty(menuName)) {
if (Object.prototype.hasOwnProperty.call(block.fields, menuName)) {
return block.fields[menuName];
}
}
Expand Down Expand Up @@ -1085,7 +1086,7 @@ class Blocks {
const commentId = block.comment;
if (commentId) {
if (comments) {
if (comments.hasOwnProperty(commentId)) {
if (Object.prototype.hasOwnProperty.call(comments, commentId)) {
xmlString += comments[commentId].toXML();
} else {
log.warn(`Could not find comment with id: ${commentId} in provided comment descriptions.`);
Expand All @@ -1100,7 +1101,7 @@ class Blocks {
}
// Add any inputs on this block.
for (const input in block.inputs) {
if (!block.inputs.hasOwnProperty(input)) continue;
if (!Object.prototype.hasOwnProperty.call(block.inputs, input)) continue;
const blockInput = block.inputs[input];
// Only encode a value tag if the value input is occupied.
if (blockInput.block || blockInput.shadow) {
Expand All @@ -1117,7 +1118,7 @@ class Blocks {
}
// Add any fields on this block.
for (const field in block.fields) {
if (!block.fields.hasOwnProperty(field)) continue;
if (!Object.prototype.hasOwnProperty.call(block.fields, field)) continue;
const blockField = block.fields[field];
xmlString += `<field name="${blockField.name}"`;
const fieldId = blockField.id;
Expand Down
Loading

0 comments on commit ef86783

Please sign in to comment.