Skip to content

Commit

Permalink
merge-upstream: Fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Dec 22, 2023
1 parent 5d52268 commit 9f26069
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ jobs:
with:
node-version: 16.x
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"docs": "jsdoc -c .jsdoc.json",
"i18n:src": "mkdirp translations/core && format-message extract --out-file translations/core/en.json src/extensions/**/index.js",
"i18n:push": "tx-push-src scratch-editor extensions translations/core/en.json",
"lint": "eslint . && format-message lint src/**/*.js",
"lint": "eslint .",
"prepublish": "in-publish && npm run build || not-in-publish",
"start": "webpack-dev-server",
"tap": "tap ./test/{unit,integration}/*.js",
Expand Down
14 changes: 7 additions & 7 deletions src/compiler/irgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ class ScriptTreeGenerator {
const variable = block.fields[fieldName];
const id = variable.id;

if (this.variableCache.hasOwnProperty(id)) {
if (Object.prototype.hasOwnProperty.call(this.variableCache, id)) {
return this.variableCache[id];
}

Expand All @@ -1249,20 +1249,20 @@ class ScriptTreeGenerator {
const stage = this.stage;

// Look for by ID in target...
if (target.variables.hasOwnProperty(id)) {
if (Object.prototype.hasOwnProperty.call(target.variables, id)) {
return createVariableData('target', target.variables[id]);
}

// Look for by ID in stage...
if (!target.isStage) {
if (stage && stage.variables.hasOwnProperty(id)) {
if (stage && Object.prototype.hasOwnProperty.call(stage.variables, id)) {
return createVariableData('stage', stage.variables[id]);
}
}

// Look for by name and type in target...
for (const varId in target.variables) {
if (target.variables.hasOwnProperty(varId)) {
if (Object.prototype.hasOwnProperty.call(target.variables, varId)) {
const currVar = target.variables[varId];
if (currVar.name === name && currVar.type === type) {
return createVariableData('target', currVar);
Expand All @@ -1273,7 +1273,7 @@ class ScriptTreeGenerator {
// Look for by name and type in stage...
if (!target.isStage && stage) {
for (const varId in stage.variables) {
if (stage.variables.hasOwnProperty(varId)) {
if (Object.prototype.hasOwnProperty.call(stage.variables, varId)) {
const currVar = stage.variables[varId];
if (currVar.name === name && currVar.type === type) {
return createVariableData('stage', currVar);
Expand All @@ -1291,7 +1291,7 @@ class ScriptTreeGenerator {
// This is necessary because the script cache is shared between clones.
// sprite.clones has all instances of this sprite including the original and all clones
for (const clone of target.sprite.clones) {
if (!clone.variables.hasOwnProperty(id)) {
if (!Object.prototype.hasOwnProperty.call(clone.variables, id)) {
clone.variables[id] = new Variable(id, name, type, false);
}
}
Expand Down Expand Up @@ -1598,7 +1598,7 @@ class IRGenerator {

addProcedureDependencies (dependencies) {
for (const procedureVariant of dependencies) {
if (this.procedures.hasOwnProperty(procedureVariant)) {
if (Object.prototype.hasOwnProperty.call(this.procedures, procedureVariant)) {
continue;
}
if (this.compilingProcedures.has(procedureVariant)) {
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/jsgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ class JSGenerator {
this.source += 'target.clearEffects();\n';
break;
case 'looks.changeEffect':
if (this.target.effects.hasOwnProperty(node.effect)) {
if (Object.prototype.hasOwnProperty.call(this.target.effects, node.effect)) {
this.source += `target.setEffect("${sanitize(node.effect)}", runtime.ext_scratch3_looks.clampEffect("${sanitize(node.effect)}", ${this.descendInput(node.value).asNumber()} + target.effects["${sanitize(node.effect)}"]));\n`;
}
break;
Expand Down Expand Up @@ -1010,7 +1010,7 @@ class JSGenerator {
this.source += 'target.setCostume(target.currentCostume + 1);\n';
break;
case 'looks.setEffect':
if (this.target.effects.hasOwnProperty(node.effect)) {
if (Object.prototype.hasOwnProperty.call(this.target.effects, node.effect)) {
this.source += `target.setEffect("${sanitize(node.effect)}", runtime.ext_scratch3_looks.clampEffect("${sanitize(node.effect)}", ${this.descendInput(node.value).asNumber()}));\n`;
}
break;
Expand Down Expand Up @@ -1210,7 +1210,7 @@ class JSGenerator {
}

descendVariable (variable) {
if (this.variableInputs.hasOwnProperty(variable.id)) {
if (Object.prototype.hasOwnProperty.call(this.variableInputs, variable.id)) {
return this.variableInputs[variable.id];
}
const input = new VariableInput(`${this.referenceVariable(variable)}.value`);
Expand All @@ -1233,7 +1233,7 @@ class JSGenerator {
}

evaluateOnce (source) {
if (this._setupVariables.hasOwnProperty(source)) {
if (Object.prototype.hasOwnProperty.call(this._setupVariables, source)) {
return this._setupVariables[source];
}
const variable = this._setupVariablesPool.next();
Expand Down
4 changes: 2 additions & 2 deletions src/engine/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Blocks {
* @returns {{success: boolean; value: any}|null} Cached success or error, or null if there is no cached value.
*/
getCachedCompileResult (blockId) {
if (this._cache.compiledScripts.hasOwnProperty(blockId)) {
if (Object.prototype.hasOwnProperty.call(this._cache.compiledScripts, blockId)) {
return this._cache.compiledScripts[blockId];
}
return null;
Expand Down Expand Up @@ -354,7 +354,7 @@ class Blocks {
return;
}
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') {
Expand Down
2 changes: 2 additions & 0 deletions src/extension-support/tw-unsandboxed-extension-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const createScratchX = require('./tw-scratchx-compatibility-layer');
const AsyncLimiter = require('../util/async-limiter');
const createTranslate = require('./tw-l10n');

/* eslint-disable require-await */

/**
* Parse a URL object or return null.
* @param {string} url
Expand Down
2 changes: 1 addition & 1 deletion src/io/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Keyboard {
this._keysPressed.splice(index, 1);
}
// Fix for https://github.com/LLK/scratch-vm/issues/2271
if (data.hasOwnProperty('keyCode')) {
if (Object.prototype.hasOwnProperty.call(data, 'keyCode')) {
const keyCode = data.keyCode;
if (this._numeralKeyCodesToStringKey.has(keyCode)) {
const lastKeyOfSameCode = this._numeralKeyCodesToStringKey.get(keyCode);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/tw_add_builtin_extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test('each runtime has own set of extensions', t => {
const vm1 = new VM();
const vm2 = new VM();

vm1.extensionManager.addBuiltinExtension('testbuiltin', TestBuiltinExtension)
vm1.extensionManager.addBuiltinExtension('testbuiltin', TestBuiltinExtension);

t.ok(vm1.extensionManager.isBuiltinExtension('testbuiltin'));
t.notOk(vm2.extensionManager.isBuiltinExtension('testbuiltin'));
Expand Down
6 changes: 5 additions & 1 deletion test/integration/tw_extension_and_block_xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ test('XML escaped in Blocks.toXML()', async t => {
// Check the string input
const stringInputValue = block.children[0];
t.equal(stringInputValue.name, 'value', 'string input is <value>');
t.equal(stringInputValue.attribs.name, 'string argument &lt;&gt;&amp;&quot;&apos;', 'escaped string input name');
t.equal(
stringInputValue.attribs.name,
'string argument &lt;&gt;&amp;&quot;&apos;',
'escaped string input name'
);
t.equal(stringInputValue.children.length, 1, 'string input has 1 child');

const stringInputShadow = stringInputValue.children[0];
Expand Down
2 changes: 0 additions & 2 deletions test/integration/tw_load_svg_with_stored_center.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const makeTestStorage = require('../fixtures/make-test-storage');
const FakeRenderer = require('../fixtures/fake-renderer');
const {test} = require('tap');

/* global TextEncoder */

test('importing SVG with stored rotation center', async t => {
t.plan(3);
const runtime = new Runtime();
Expand Down
6 changes: 3 additions & 3 deletions test/integration/tw_packaged_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ global.Image = function () {
};

class FakeAudioEngine {
async decodeSoundPlayer () {
return {
decodeSoundPlayer () {
return Promise.resolve({
id: 0,
buffer: {
sampleRate: 1,
length: 1
}
};
});
}
}

Expand Down
2 changes: 0 additions & 2 deletions test/integration/tw_save_project_sb3.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const VirtualMachine = require('../../src/virtual-machine');
const makeTestStorage = require('../fixtures/make-test-storage');
const JSZip = require('jszip');

/* globals Blob */

const fixture = fs.readFileSync(pathUtil.join(__dirname, '..', 'fixtures', 'tw-save-project-sb3.sb3'));

test('saveProjectSb3', async t => {
Expand Down
1 change: 1 addition & 0 deletions test/integration/tw_security_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const FETCH_EXTENSION = 'https://extensions.turbowarp.org/fetch.js';
const BITWISE_EXTENSION = 'https://extensions.turbowarp.org/bitwise.js';

/* eslint-disable no-script-url */
/* eslint-disable require-await */

test('Deny both extensions', async t => {
const vm = new VirtualMachine();
Expand Down
2 changes: 0 additions & 2 deletions test/unit/tw_costume_import_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const {
} = require('../../src/serialization/tw-costume-import-export');
const {test} = require('tap');

/* global TextEncoder */

test('parseVectorMetadata', t => {
/* eslint-disable max-len */
t.same(
Expand Down
1 change: 0 additions & 1 deletion test/unit/tw_sandboxed_extensions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const {test} = require('tap');

/* globals Request */
global.Request = class {
constructor (url) {
this.url = url;
Expand Down
3 changes: 1 addition & 2 deletions test/unit/tw_unsandboxed_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ global.document = {
};

// Mock various DOM APIs for fetching, window opening, redirecting, etc.
/* globals Request */
global.Request = class {
constructor (url) {
this.url = url;
Expand All @@ -53,7 +52,7 @@ global.window = {
open: (url, target, features) => `[Window ${url} target=${target || ''} features=${features || ''}]`
};

tap.beforeEach(async () => {
tap.beforeEach(() => {
scriptCallbacks.clear();
global.location = {
href: 'https://example.com/'
Expand Down
3 changes: 2 additions & 1 deletion test/unit/tw_util_async_limiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const AsyncLimiter = require('../../src/util/async-limiter');
const {test} = require('tap');

test('Runs callback', async t => {
/* eslint-disable-next-line require-await */
const callback = async (a, b) => a + b;

const limiter = new AsyncLimiter(callback, 2);
Expand All @@ -24,7 +25,7 @@ test('Runs callback', async t => {

test('Errors', async t => {
t.plan(1);
const callback = () => Promise.reject('Error123!');
const callback = () => Promise.reject(new Error('Error123!'));
const limiter = new AsyncLimiter(callback, 10);
try {
await limiter.do();
Expand Down

0 comments on commit 9f26069

Please sign in to comment.