Skip to content

Commit 161e3a9

Browse files
committed
Fix a ton of ESLint errors (after a long time)
1 parent 70136a3 commit 161e3a9

File tree

10 files changed

+31
-33
lines changed

10 files changed

+31
-33
lines changed

src/blocks/scratch3_comments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class Scratch3CommentsBlocks {
2525
};
2626
}
2727

28-
hat (args) {
28+
hat () {
2929
// No Operation;
3030
}
3131

32-
command (args) {
32+
command () {
3333
// No Operation;
3434
}
3535

src/blocks/scratch3_json.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Scratch3JSONBlocks {
6565
valueOfKey (args) {
6666
args.OBJ = Cast.toObject(args.OBJ);
6767
args.KEY = Cast.toString(args.KEY);
68-
return args.OBJ[args.KEY] ?? "";
68+
return args.OBJ[args.KEY] ?? '';
6969
}
7070

7171
setKey (args) {
@@ -91,7 +91,7 @@ class Scratch3JSONBlocks {
9191
hasKey (args) {
9292
args.OBJ = Cast.toObject(args.OBJ);
9393
args.KEY = Cast.toString(args.KEY);
94-
return args.OBJ.hasOwnProperty(args.KEY);
94+
return Object.hasOwn(args.OBJ, args.KEY);
9595
}
9696

9797
newArray () {
@@ -106,12 +106,12 @@ class Scratch3JSONBlocks {
106106
valueOfIndex (args) {
107107
args.ARR = Cast.toArray(args.ARR);
108108
args.INDEX = Cast.toNumber(args.INDEX);
109-
return args.ARR[args.INDEX] ?? "";
109+
return args.ARR[args.INDEX] ?? '';
110110
}
111111

112112
indexOfValue (args) {
113113
args.ARR = Cast.toArray(args.ARR);
114-
return args.ARR.indexOf(args.VALUE) !== -1 ? args.ARR.indexOf(args.VALUE) : "";
114+
return args.ARR.indexOf(args.VALUE) === -1 ? '' : args.ARR.indexOf(args.VALUE);
115115
}
116116

117117
addItem (args) {
@@ -126,9 +126,8 @@ class Scratch3JSONBlocks {
126126
if (args.INDEX >= 0 && args.INDEX < args.ARR.length) {
127127
args.ARR[args.INDEX] = args.ITEM;
128128
return args.ARR;
129-
} else {
130-
return new Array();
131129
}
130+
return new Array();
132131
}
133132

134133
deleteIndex (args) {
@@ -137,15 +136,14 @@ class Scratch3JSONBlocks {
137136
if (args.INDEX >= 0 && args.INDEX < args.ARR.length) {
138137
args.ARR.splice(args.INDEX, 1);
139138
return args.ARR;
140-
} else {
141-
return new Array();
142139
}
140+
return new Array();
143141
}
144142

145143
deleteAllOccurrences (args) {
146144
args.ARR = Cast.toArray(args.ARR);
147145
args.ITEM = Cast.toString(args.ITEM);
148-
return args.ARR.filter((item) => item !== args.ITEM);
146+
return args.ARR.filter(item => item !== args.ITEM);
149147
}
150148

151149
mergeArray (args) {

src/blocks/scratch3_operators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Scratch3OperatorsBlocks {
3939
}
4040

4141
checkbox () {
42-
return true;
42+
return true;
4343
}
4444

4545
add (args) {

src/compiler/irgen.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -796,25 +796,25 @@ class ScriptTreeGenerator {
796796
return {
797797
kind: 'comments.reporter',
798798
value: this.descendInputOfBlock(block, 'VALUE'),
799-
comment: this.descendInputOfBlock(block, 'COMMENT'),
799+
comment: this.descendInputOfBlock(block, 'COMMENT')
800800
};
801801
case 'comments_boolean':
802802
return {
803803
kind: 'comments.boolean',
804804
value: this.descendInputOfBlock(block, 'VALUE'),
805-
comment: this.descendInputOfBlock(block, 'COMMENT'),
805+
comment: this.descendInputOfBlock(block, 'COMMENT')
806806
};
807807
case 'comments_object':
808808
return {
809809
kind: 'comments.object',
810810
value: this.descendInputOfBlock(block, 'VALUE'),
811-
comment: this.descendInputOfBlock(block, 'COMMENT'),
811+
comment: this.descendInputOfBlock(block, 'COMMENT')
812812
};
813813
case 'comments_array':
814814
return {
815815
kind: 'comments.array',
816816
value: this.descendInputOfBlock(block, 'VALUE'),
817-
comment: this.descendInputOfBlock(block, 'COMMENT'),
817+
comment: this.descendInputOfBlock(block, 'COMMENT')
818818
};
819819

820820
case 'tw_getLastKeyPressed':
@@ -834,10 +834,10 @@ class ScriptTreeGenerator {
834834
if (blockInfo) {
835835
const type = blockInfo.info.blockType;
836836
if (
837-
type === BlockType.REPORTER
838-
|| type === BlockType.BOOLEAN
839-
|| type === BlockType.OBJECT
840-
|| type === BlockType.ARRAY
837+
type === BlockType.REPORTER ||
838+
type === BlockType.BOOLEAN ||
839+
type === BlockType.OBJECT ||
840+
type === BlockType.ARRAY
841841
) {
842842
return this.descendCompatLayer(block);
843843
}

src/compiler/jsexecute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @fileoverview Runtime for scripts generated by jsgen
33
*/
44

5-
const { supportsNullishCoalescing: canNullCoalsh } = require('./environment');
5+
const {supportsNullishCoalescing: canNullCoalsh} = require('./environment');
66

77
/* eslint-disable no-unused-vars */
88
/* eslint-disable prefer-template */

src/engine/blocks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,9 @@ class Blocks {
922922
if (preserve) {
923923
const parent = this._blocks[block.parent];
924924
const next = this._blocks[block.next];
925-
const input = parent?.inputs
926-
? Object.values(parent.inputs).find(input => input.block === blockId)
927-
: null;
925+
const input = parent?.inputs ?
926+
Object.values(parent.inputs).find(i => i.block === blockId) :
927+
null;
928928
if (parent && !input) {
929929
parent.next = block.next;
930930
}

src/engine/runtime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,9 +1107,9 @@ class Runtime extends EventEmitter {
11071107
*/
11081108
_reorderExtensionPrimitive (extensionIndex, reorderIndex) {
11091109
if (reorderIndex >= this._blockInfo.length) {
1110-
const padding = reorderIndex - this._blockInfo + 1;
1110+
let padding = reorderIndex - this._blockInfo.length + 1;
11111111
while (padding--) {
1112-
this._blockInfo.push(undefined);
1112+
this._blockInfo.push(null);
11131113
}
11141114
}
11151115
this._blockInfo.splice(reorderIndex, 0, this._blockInfo.splice(extensionIndex, 1)[0]);

src/extension-support/extension-manager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ class ExtensionManager {
266266
* @returns {Promise} resolved once the extension is loaded and initialized or rejected on failure
267267
*/
268268
reorderExtension (extensionIndex, reorderIndex) {
269-
let extensions = Array.from(this._loadedExtensions);
269+
const extensions = Array.from(this._loadedExtensions);
270270
if (reorderIndex >= extensions.length) {
271-
const padding = reorderIndex - extensions + 1;
271+
let padding = reorderIndex - extensions.length + 1;
272272
while (padding--) {
273-
extensions.push(undefined);
273+
extensions.push(null);
274274
}
275275
}
276276
extensions.splice(reorderIndex, 0, extensions.splice(extensionIndex, 1)[0]);
277-
this._loadedExtensions = new Map(extensions.map((extension) => [extension[0], extension[1]]));
277+
this._loadedExtensions = new Map(extensions.map(extension => [extension[0], extension[1]]));
278278
dispatch.call('runtime', '_reorderExtensionPrimitive', extensionIndex, reorderIndex);
279279
this.refreshBlocks();
280280
}

src/extensions/tw/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const ArgumentType = require('../../extension-support/argument-type');
44
const Cast = require('../../util/cast');
55

66
// eslint-disable-next-line max-len
7-
const iconURI = `data:image/svg+xml;base64,${btoa('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path fill="none" stroke="#fff" stroke-width="11.51815371" d="M24.457 7.707a18.41 18.41 0 0 0-.365 2.31c-.02.224 0 .507.06.852.061.405.092.689.092.851 0 .527-.345.79-1.034.79-.446 0-.74-.131-.881-.395-.02-.446-.01-1.054.03-1.824.04-.912.061-1.52.061-1.824-.02 0-.05-.02-.091-.06a98.522 98.522 0 0 0-5.32.364c-.04.264-.04.588 0 .973l.122 1.094c-.081.629-.122 1.56-.122 2.797.061.527.091 2.786.091 6.779v2.219c0 .344.051.587.152.73h1.885c.77-.102 1.155.222 1.155.972 0 .446-.213.76-.638.942-.264.102-.73.122-1.399.061-.405-.04-.881-.05-1.428-.03-.75.101-1.662.182-2.736.243-1.094.06-1.763-.091-2.006-.456-.162-.243-.162-.496 0-.76.283-.446 1.023-.669 2.219-.669.628 0 .942-.172.942-.516 0-.183-.01-.355-.03-.517 0-.507.01-.953.03-1.338.06-1.094.06-2.634 0-4.62-.081-2.878-.05-5.462.091-7.752l-.09-.09c-.63.04-1.805.03-3.527-.031-.081 0-.7.04-1.854.121.283 1.946.446 3.334.486 4.165l-.06.82c-.021.305-.274.457-.76.457-.386 0-.71-.73-.973-2.19-.122-.87-.244-1.752-.365-2.644 0-.142-.071-.385-.213-.73-.122-.364-.39-.97-.39-1.152 0-.641.593-.489 1.363-.61.06 0 .162.01.304.03.142.02.243.03.304.03H17.1a57.098 57.098 0 0 0 5.411-.486c.122-.06.304-.121.547-.182.426-.04.79.06 1.095.304.304.223.405.547.304.972z"/><path fill="none" stroke="#ff4c4c" stroke-width="5.75909785" d="M24.333 7.71q-.244 1.065-.365 2.311-.03.335.06.851.092.608.092.851 0 .79-1.034.79-.669 0-.881-.394-.03-.67.03-1.824.06-1.368.06-1.824-.03 0-.09-.061-2.827.122-5.32.365-.06.395 0 .973l.122 1.094q-.122.942-.122 2.796.091.79.091 6.78v2.218q0 .517.152.73h1.885q1.155-.152 1.155.973 0 .668-.638.942-.396.152-1.399.06-.608-.06-1.428-.03-1.125.152-2.736.243-1.642.092-2.006-.456-.244-.364 0-.76.425-.668 2.219-.668.942 0 .942-.517 0-.274-.03-.517 0-.76.03-1.337.091-1.642 0-4.62-.122-4.317.091-7.752l-.091-.091q-.942.06-3.526-.03-.122 0-1.854.12.425 2.919.486 4.165l-.06.821q-.031.456-.76.456-.578 0-.974-2.189-.182-1.307-.364-2.644 0-.213-.213-.73-.182-.547-.182-.82 0-.76 1.155-.943.09 0 .304.03.212.03.304.03h7.538q2.797-.12 5.411-.485.182-.092.547-.183.639-.06 1.095.304.456.335.304.973z"/><path fill="#fff" d="M24.31 7.714q-.243 1.064-.365 2.31-.03.335.061.852.091.608.091.85 0 .791-1.033.791-.67 0-.882-.395-.03-.669.03-1.824.061-1.368.061-1.824-.03 0-.09-.06-2.828.121-5.32.364-.061.396 0 .973l.121 1.094q-.121.943-.121 2.797.09.79.09 6.779v2.219q0 .517.153.73h1.884q1.156-.153 1.156.972 0 .669-.639.942-.395.152-1.398.061-.608-.06-1.429-.03-1.125.152-2.736.243-1.641.091-2.006-.456-.243-.365 0-.76.426-.669 2.22-.669.941 0 .941-.516 0-.274-.03-.517 0-.76.03-1.338.092-1.641 0-4.62-.121-4.317.092-7.752l-.092-.09q-.942.06-3.526-.031-.121 0-1.854.121.426 2.919.486 4.165l-.06.82q-.03.457-.76.457-.578 0-.973-2.19-.182-1.306-.365-2.644 0-.212-.213-.73-.182-.546-.182-.82 0-.76 1.155-.942.091 0 .304.03t.304.03h7.539q2.796-.121 5.41-.486.183-.091.548-.182.638-.061 1.094.304.456.334.304.972z"/></svg>')}`;
7+
// const iconURI = `data:image/svg+xml;base64,${btoa('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path fill="none" stroke="#fff" stroke-width="11.51815371" d="M24.457 7.707a18.41 18.41 0 0 0-.365 2.31c-.02.224 0 .507.06.852.061.405.092.689.092.851 0 .527-.345.79-1.034.79-.446 0-.74-.131-.881-.395-.02-.446-.01-1.054.03-1.824.04-.912.061-1.52.061-1.824-.02 0-.05-.02-.091-.06a98.522 98.522 0 0 0-5.32.364c-.04.264-.04.588 0 .973l.122 1.094c-.081.629-.122 1.56-.122 2.797.061.527.091 2.786.091 6.779v2.219c0 .344.051.587.152.73h1.885c.77-.102 1.155.222 1.155.972 0 .446-.213.76-.638.942-.264.102-.73.122-1.399.061-.405-.04-.881-.05-1.428-.03-.75.101-1.662.182-2.736.243-1.094.06-1.763-.091-2.006-.456-.162-.243-.162-.496 0-.76.283-.446 1.023-.669 2.219-.669.628 0 .942-.172.942-.516 0-.183-.01-.355-.03-.517 0-.507.01-.953.03-1.338.06-1.094.06-2.634 0-4.62-.081-2.878-.05-5.462.091-7.752l-.09-.09c-.63.04-1.805.03-3.527-.031-.081 0-.7.04-1.854.121.283 1.946.446 3.334.486 4.165l-.06.82c-.021.305-.274.457-.76.457-.386 0-.71-.73-.973-2.19-.122-.87-.244-1.752-.365-2.644 0-.142-.071-.385-.213-.73-.122-.364-.39-.97-.39-1.152 0-.641.593-.489 1.363-.61.06 0 .162.01.304.03.142.02.243.03.304.03H17.1a57.098 57.098 0 0 0 5.411-.486c.122-.06.304-.121.547-.182.426-.04.79.06 1.095.304.304.223.405.547.304.972z"/><path fill="none" stroke="#ff4c4c" stroke-width="5.75909785" d="M24.333 7.71q-.244 1.065-.365 2.311-.03.335.06.851.092.608.092.851 0 .79-1.034.79-.669 0-.881-.394-.03-.67.03-1.824.06-1.368.06-1.824-.03 0-.09-.061-2.827.122-5.32.365-.06.395 0 .973l.122 1.094q-.122.942-.122 2.796.091.79.091 6.78v2.218q0 .517.152.73h1.885q1.155-.152 1.155.973 0 .668-.638.942-.396.152-1.399.06-.608-.06-1.428-.03-1.125.152-2.736.243-1.642.092-2.006-.456-.244-.364 0-.76.425-.668 2.219-.668.942 0 .942-.517 0-.274-.03-.517 0-.76.03-1.337.091-1.642 0-4.62-.122-4.317.091-7.752l-.091-.091q-.942.06-3.526-.03-.122 0-1.854.12.425 2.919.486 4.165l-.06.821q-.031.456-.76.456-.578 0-.974-2.189-.182-1.307-.364-2.644 0-.213-.213-.73-.182-.547-.182-.82 0-.76 1.155-.943.09 0 .304.03.212.03.304.03h7.538q2.797-.12 5.411-.485.182-.092.547-.183.639-.06 1.095.304.456.335.304.973z"/><path fill="#fff" d="M24.31 7.714q-.243 1.064-.365 2.31-.03.335.061.852.091.608.091.85 0 .791-1.033.791-.67 0-.882-.395-.03-.669.03-1.824.061-1.368.061-1.824-.03 0-.09-.06-2.828.121-5.32.364-.061.396 0 .973l.121 1.094q-.121.943-.121 2.797.09.79.09 6.779v2.219q0 .517.153.73h1.884q1.156-.153 1.156.972 0 .669-.639.942-.395.152-1.398.061-.608-.06-1.429-.03-1.125.152-2.736.243-1.641.091-2.006-.456-.243-.365 0-.76.426-.669 2.22-.669.941 0 .941-.516 0-.274-.03-.517 0-.76.03-1.338.092-1.641 0-4.62-.121-4.317.092-7.752l-.092-.09q-.942.06-3.526-.031-.121 0-1.854.121.426 2.919.486 4.165l-.06.82q-.03.457-.76.457-.578 0-.973-2.19-.182-1.306-.365-2.644 0-.212-.213-.73-.182-.546-.182-.82 0-.76 1.155-.942.091 0 .304.03t.304.03h7.539q2.796-.121 5.41-.486.183-.091.548-.182.638-.061 1.094.304.456.334.304.972z"/></svg>')}`;
88

99
/**
1010
* Class for NitroBolt blocks

src/util/cast.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ class Cast {
9292
* @return {string} The Scratch-casted string value.
9393
*/
9494
static toString (value) {
95-
if (typeof value === 'undefined' || typeof value === 'null') {
95+
if (value === undefined || value === null) {
9696
return String();
9797
} else if (typeof value === 'object') {
9898
try {
9999
return JSON.stringify(value);
100-
} catch {} // Fallthrough
100+
} catch (e) {}
101101
}
102102
return String(value);
103103
}

0 commit comments

Comments
 (0)