diff --git a/blocks/lists.ts b/blocks/lists.ts index d115a321c..3b468dc9d 100644 --- a/blocks/lists.ts +++ b/blocks/lists.ts @@ -227,7 +227,7 @@ const LISTS_CREATE_WITH = { // Disconnect any children that don't belong. for (let i = 0; i < this.itemCount_; i++) { const connection = this.getInput('ADD' + i)!.connection!.targetConnection; - if (connection && connections.indexOf(connection) === -1) { + if (connection && !connections.includes(connection)) { connection.disconnect(); } } diff --git a/blocks/procedures.ts b/blocks/procedures.ts index 25fe240b8..1457971d8 100644 --- a/blocks/procedures.ts +++ b/blocks/procedures.ts @@ -858,7 +858,7 @@ const PROCEDURE_CALL_COMMON = { if ( mutatorOpen && connection && - paramIds.indexOf(this.quarkIds_[i]) === -1 + !paramIds.includes(this.quarkIds_[i]) ) { // This connection should no longer be attached to this block. connection.disconnect(); @@ -1041,7 +1041,7 @@ const PROCEDURE_CALL_COMMON = { } if ( event.type === Events.BLOCK_CREATE && - (event as BlockCreate).ids!.indexOf(this.id) !== -1 + (event as BlockCreate).ids!.includes(this.id) ) { // Look for the case where a procedure call was created (usually through // paste) and there is no matching definition. In this case, create @@ -1286,7 +1286,7 @@ const PROCEDURES_IFRETURN = { // Is the block nested in a procedure? let block = this; // eslint-disable-line @typescript-eslint/no-this-alias do { - if (this.FUNCTION_TYPES.indexOf(block.type) !== -1) { + if (this.FUNCTION_TYPES.includes(block.type)) { legal = true; break; } diff --git a/blocks/text.ts b/blocks/text.ts index e0470c169..91a27005a 100644 --- a/blocks/text.ts +++ b/blocks/text.ts @@ -796,7 +796,7 @@ const JOIN_MUTATOR_MIXIN = { // Disconnect any children that don't belong. for (let i = 0; i < this.itemCount_; i++) { const connection = this.getInput('ADD' + i)!.connection!.targetConnection; - if (connection && connections.indexOf(connection) === -1) { + if (connection && !connections.includes(connection)) { connection.disconnect(); } } diff --git a/core/block.ts b/core/block.ts index 82c82cb43..a321ad141 100644 --- a/core/block.ts +++ b/core/block.ts @@ -1529,8 +1529,7 @@ export class Block implements IASTNodeLocation, IDeletable { checks = connection.targetConnection.getCheck(); } return ( - !!checks && - (checks.indexOf('Boolean') !== -1 || checks.indexOf('Number') !== -1) + !!checks && (checks.includes('Boolean') || checks.includes('Number')) ); } diff --git a/core/bump_objects.ts b/core/bump_objects.ts index 39fcd0a50..d06b66800 100644 --- a/core/bump_objects.ts +++ b/core/bump_objects.ts @@ -99,7 +99,7 @@ export function bumpIntoBoundsHandler( return; } - if (eventUtils.BUMP_EVENTS.indexOf(e.type ?? '') !== -1) { + if (eventUtils.BUMP_EVENTS.includes(e.type ?? '')) { const scrollMetricsInWsCoords = metricsManager.getScrollMetrics(true); // Triggered by move/create event diff --git a/core/component_manager.ts b/core/component_manager.ts index 9bb66fcbb..b9654c94e 100644 --- a/core/component_manager.ts +++ b/core/component_manager.ts @@ -172,7 +172,7 @@ export class ComponentManager { capability = `${capability}`.toLowerCase(); return ( this.componentData.has(id) && - this.componentData.get(id)!.capabilities.indexOf(capability) !== -1 + this.componentData.get(id)!.capabilities.includes(capability) ); } diff --git a/core/connection_checker.ts b/core/connection_checker.ts index f7d09b972..6f5ecd5d5 100644 --- a/core/connection_checker.ts +++ b/core/connection_checker.ts @@ -210,7 +210,7 @@ export class ConnectionChecker implements IConnectionChecker { } // Find any intersection in the check lists. for (let i = 0; i < checkArrayOne.length; i++) { - if (checkArrayTwo.indexOf(checkArrayOne[i]) !== -1) { + if (checkArrayTwo.includes(checkArrayOne[i])) { return true; } } @@ -298,7 +298,7 @@ export class ConnectionChecker implements IConnectionChecker { } // Don't let blocks try to connect to themselves or ones they nest. - if (common.draggingConnections.indexOf(b) !== -1) { + if (common.draggingConnections.includes(b)) { return false; } @@ -321,7 +321,7 @@ export class ConnectionChecker implements IConnectionChecker { } // Don't let blocks try to connect to themselves or ones they nest. - if (common.draggingConnections.indexOf(b) !== -1) { + if (common.draggingConnections.includes(b)) { return false; } diff --git a/core/extensions.ts b/core/extensions.ts index 6313c4161..aa9a6a186 100644 --- a/core/extensions.ts +++ b/core/extensions.ts @@ -401,7 +401,7 @@ export function buildTooltipForDropdown( const blockTypesChecked: string[] = []; return function (this: Block) { - if (blockTypesChecked.indexOf(this.type) === -1) { + if (!blockTypesChecked.includes(this.type)) { checkDropdownOptionsInTable(this, dropdownName, lookupTable); blockTypesChecked.push(this.type); } diff --git a/core/field_dropdown.ts b/core/field_dropdown.ts index ad728f226..6fb779c4f 100644 --- a/core/field_dropdown.ts +++ b/core/field_dropdown.ts @@ -408,7 +408,13 @@ export class FieldDropdown extends Field { * @param newValue The input value. * @returns A valid language-neutral option, or null if invalid. */ - protected override doClassValidation_(newValue?: string): string | null { + protected override doClassValidation_( + newValue: string, + ): string | null | undefined; + protected override doClassValidation_(newValue?: string): string | null; + protected override doClassValidation_( + newValue?: string, + ): string | null | undefined { const options = this.getOptions(true); const isValueValid = options.some((option) => option[1] === newValue); @@ -426,7 +432,7 @@ export class FieldDropdown extends Field { } return null; } - return newValue as string; + return newValue; } /** diff --git a/core/field_number.ts b/core/field_number.ts index 8965dd330..ee04eab49 100644 --- a/core/field_number.ts +++ b/core/field_number.ts @@ -216,7 +216,7 @@ export class FieldNumber extends FieldInput { private setPrecisionInternal(precision: number | string | undefined | null) { this.precision_ = Number(precision) || 0; let precisionString = String(this.precision_); - if (precisionString.indexOf('e') !== -1) { + if (precisionString.includes('e')) { // String() is fast. But it turns .0000001 into '1e-7'. // Use the much slower toLocaleString to access all the digits. precisionString = this.precision_.toLocaleString('en-US', { diff --git a/core/flyout_base.ts b/core/flyout_base.ts index 438e92d64..360b3ac2f 100644 --- a/core/flyout_base.ts +++ b/core/flyout_base.ts @@ -1201,7 +1201,7 @@ export abstract class Flyout private filterForCapacity() { const blocks = this.workspace_.getTopBlocks(false); for (let i = 0, block; (block = blocks[i]); i++) { - if (this.permanentlyDisabled.indexOf(block) === -1) { + if (!this.permanentlyDisabled.includes(block)) { const enable = this.targetWorkspace.isCapacityAvailable( common.getBlockTypeCounts(block), ); diff --git a/core/generator.ts b/core/generator.ts index 35a962396..a24a04697 100644 --- a/core/generator.ts +++ b/core/generator.ts @@ -568,11 +568,7 @@ export class CodeGenerator { * @param _opt_thisOnly True to generate code for only this statement. * @returns Code with comments and subsequent blocks added. */ - protected scrub_( - _block: Block, - code: string, - _opt_thisOnly?: boolean, - ): string { + scrub_(_block: Block, code: string, _opt_thisOnly?: boolean): string { // Optionally override return code; } diff --git a/core/names.ts b/core/names.ts index ce8c626db..4f4c72faa 100644 --- a/core/names.ts +++ b/core/names.ts @@ -218,7 +218,7 @@ export class Names { // https://github.com/google/blockly/issues/1654 name = encodeURI(name.replace(/ /g, '_')).replace(/[^\w]/g, '_'); // Most languages don't allow names with leading numbers. - if ('0123456789'.indexOf(name[0]) !== -1) { + if ('0123456789'.includes(name[0])) { name = 'my_' + name; } } diff --git a/core/renderers/common/constants.ts b/core/renderers/common/constants.ts index 1983793f0..078fc01d6 100644 --- a/core/renderers/common/constants.ts +++ b/core/renderers/common/constants.ts @@ -617,7 +617,7 @@ export class ConstantProvider { getBlockStyle(blockStyleName: string | null): BlockStyle { return ( this.blockStyles[blockStyleName || ''] || - (blockStyleName && blockStyleName.indexOf('auto_') === 0 + (blockStyleName && blockStyleName.startsWith('auto_') ? this.getBlockStyleForColour(blockStyleName.substring(5)).style : this.createBlockStyle_('#000000')) ); diff --git a/core/renderers/zelos/constants.ts b/core/renderers/zelos/constants.ts index 1eabd7edd..f16ca8098 100644 --- a/core/renderers/zelos/constants.ts +++ b/core/renderers/zelos/constants.ts @@ -536,13 +536,13 @@ export class ConstantProvider extends BaseConstantProvider { } } // Includes doesn't work in IE. - if (checks && checks.indexOf('Boolean') !== -1) { + if (checks && checks.includes('Boolean')) { return this.HEXAGONAL!; } - if (checks && checks.indexOf('Number') !== -1) { + if (checks && checks.includes('Number')) { return this.ROUNDED!; } - if (checks && checks.indexOf('String') !== -1) { + if (checks && checks.includes('String')) { return this.ROUNDED!; } return this.ROUNDED!; diff --git a/core/shortcut_registry.ts b/core/shortcut_registry.ts index 556efb148..35f409b48 100644 --- a/core/shortcut_registry.ts +++ b/core/shortcut_registry.ts @@ -325,7 +325,7 @@ export class ShortcutRegistry { const modifierKeyCode = ( ShortcutRegistry.modifierKeys as AnyDuringMigration )[modifier]; - if (modifiers.indexOf(modifierKeyCode) > -1) { + if (modifiers.includes(modifierKeyCode)) { if (serializedKey !== '') { serializedKey += '+'; } diff --git a/core/trashcan.ts b/core/trashcan.ts index 42c32ea1f..b48777c4d 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -616,7 +616,7 @@ export class Trashcan const cleanedJson = JSON.stringify( this.cleanBlockJson(deleteEvent.oldJson), ); - if (this.contents.indexOf(cleanedJson) !== -1) { + if (this.contents.includes(cleanedJson)) { return; } this.contents.unshift(cleanedJson); diff --git a/core/utils/string.ts b/core/utils/string.ts index fbe9f5210..b7842c948 100644 --- a/core/utils/string.ts +++ b/core/utils/string.ts @@ -204,9 +204,9 @@ function wrapScore( score -= Math.pow(maxLength - lineLengths[i], 1.5); // Optimize for structure. // Add score to line endings after punctuation. - if ('.?!'.indexOf(linePunctuation[i]) !== -1) { + if ('.?!'.includes(linePunctuation[i])) { score += limit / 3; - } else if (',;)]}'.indexOf(linePunctuation[i]) !== -1) { + } else if (',;)]}'.includes(linePunctuation[i])) { score += limit / 4; } } diff --git a/core/utils/svg_math.ts b/core/utils/svg_math.ts index bb095932f..88d38f625 100644 --- a/core/utils/svg_math.ts +++ b/core/utils/svg_math.ts @@ -62,7 +62,7 @@ export function getRelativeXY(element: Element): Coordinate { // Then check for style = transform: translate(...) or translate3d(...) const style = element.getAttribute('style'); - if (style && style.indexOf('translate') > -1) { + if (style && style.includes('translate')) { const styleComponents = style.match(XY_STYLE_REGEX); if (styleComponents) { xy.x += Number(styleComponents[1]); @@ -90,7 +90,7 @@ export function getInjectionDivXY(element: Element): Coordinate { x = x + xy.x; y = y + xy.y; const classes = element.getAttribute('class') || ''; - if ((' ' + classes + ' ').indexOf(' injectionDiv ') !== -1) { + if ((' ' + classes + ' ').includes(' injectionDiv ')) { break; } element = element.parentNode as Element; diff --git a/core/utils/toolbox.ts b/core/utils/toolbox.ts index 699150f1c..17fd327c6 100644 --- a/core/utils/toolbox.ts +++ b/core/utils/toolbox.ts @@ -381,7 +381,7 @@ function addAttributes(node: Node, obj: AnyDuringMigration) { // AnyDuringMigration because: Property 'attributes' does not exist on type // 'Node'. const attr = (node as AnyDuringMigration).attributes[j]; - if (attr.nodeName.indexOf('css-') > -1) { + if (attr.nodeName.includes('css-')) { obj['cssconfig'] = obj['cssconfig'] || {}; obj['cssconfig'][attr.nodeName.replace('css-', '')] = attr.value; } else { diff --git a/core/utils/useragent.ts b/core/utils/useragent.ts index 078d79a66..92180c21d 100644 --- a/core/utils/useragent.ts +++ b/core/utils/useragent.ts @@ -37,7 +37,7 @@ let isMobile: boolean; * @returns True if name is present. */ function has(name: string): boolean { - return rawUpper.indexOf(name.toUpperCase()) !== -1; + return rawUpper.includes(name.toUpperCase()); } // Browsers. Logic from: diff --git a/core/variables.ts b/core/variables.ts index 74c2b9252..dee53a72b 100644 --- a/core/variables.ts +++ b/core/variables.ts @@ -642,7 +642,7 @@ export function getAddedVariables( const variable = allCurrentVariables[i]; // For any variable that is present in allCurrentVariables but not // present in originalVariables, add the variable to addedVariables. - if (originalVariables.indexOf(variable) === -1) { + if (!originalVariables.includes(variable)) { addedVariables.push(variable); } } diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index f608311d1..2d49485dd 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -690,7 +690,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { let element: Element = this.svgGroup_; while (element) { const classes = element.getAttribute('class') || ''; - if ((' ' + classes + ' ').indexOf(' injectionDiv ') !== -1) { + if ((' ' + classes + ' ').includes(' injectionDiv ')) { this.injectionDiv = element; break; } @@ -1301,7 +1301,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { // Using Set here would be great, but at the cost of IE10 support. if (!state) { arrayUtils.removeElem(this.highlightedBlocks, block); - } else if (this.highlightedBlocks.indexOf(block) === -1) { + } else if (!this.highlightedBlocks.includes(block)) { this.highlightedBlocks.push(block); } block.setHighlighted(state); diff --git a/demos/blockfactory/block_exporter_controller.js b/demos/blockfactory/block_exporter_controller.js index bd41f2e74..bccd8087d 100644 --- a/demos/blockfactory/block_exporter_controller.js +++ b/demos/blockfactory/block_exporter_controller.js @@ -224,9 +224,9 @@ BlockExporterController.prototype.selectUsedBlocks = function() { var unstoredCustomBlockTypes = []; for (var i = 0, blockType; blockType = this.usedBlockTypes[i]; i++) { - if (storedBlockTypes.indexOf(blockType) !== -1) { + if (storedBlockTypes.includes(blockType)) { sharedBlockTypes.push(blockType); - } else if (StandardCategories.coreBlockTypes.indexOf(blockType) === -1) { + } else if (!StandardCategories.coreBlockTypes.includes(blockType)) { unstoredCustomBlockTypes.push(blockType); } } diff --git a/demos/blockfactory/blocks.js b/demos/blockfactory/blocks.js index 70691e264..b93ae5739 100644 --- a/demos/blockfactory/blocks.js +++ b/demos/blockfactory/blocks.js @@ -682,7 +682,7 @@ Blockly.Blocks['type_group'] = { // Disconnect any children that don't belong. for (var i = 0; i < this.typeCount_; i++) { var connection = this.getInput('TYPE' + i).connection.targetConnection; - if (connection && connections.indexOf(connection) === -1) { + if (connection && !connections.includes(connection)) { connection.disconnect(); } } diff --git a/demos/blockfactory/factory.js b/demos/blockfactory/factory.js index a77d8467a..07ee889de 100644 --- a/demos/blockfactory/factory.js +++ b/demos/blockfactory/factory.js @@ -238,7 +238,7 @@ BlockFactory.updatePreview = function() { // Warn user only if their block type is already exists in Blockly's // standard library. var rootBlock = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace); - if (StandardCategories.coreBlockTypes.indexOf(blockType) !== -1) { + if (StandardCategories.coreBlockTypes.includes(blockType)) { rootBlock.setWarningText('A core Blockly block already exists ' + 'under this name.'); diff --git a/demos/blockfactory/factory_utils.js b/demos/blockfactory/factory_utils.js index 164b3357b..148498360 100644 --- a/demos/blockfactory/factory_utils.js +++ b/demos/blockfactory/factory_utils.js @@ -594,7 +594,7 @@ FactoryUtils.getOptTypesFrom = function(block, name) { var types = FactoryUtils.getTypesFrom_(block, name); if (types.length === 0) { return undefined; - } else if (types.indexOf('null') !== -1) { + } else if (types.includes('null')) { return 'null'; } else if (types.length === 1) { return types[0]; @@ -771,7 +771,7 @@ FactoryUtils.parseJsBlockDefinitions = function(blockDefsString) { var blockDefArray = []; var defStart = blockDefsString.indexOf('Blockly.Blocks'); - while (blockDefsString.indexOf('Blockly.Blocks', defStart) !== -1) { + while (blockDefsString.includes('Blockly.Blocks', defStart)) { var nextStart = blockDefsString.indexOf('Blockly.Blocks', defStart + 1); if (nextStart === -1) { // This is the last block definition. diff --git a/demos/blockfactory/index.html b/demos/blockfactory/index.html index 14d84d73f..9f33aa4fb 100644 --- a/demos/blockfactory/index.html +++ b/demos/blockfactory/index.html @@ -369,7 +369,7 @@ // Manual JavaScript works but requires use of eval(). // TODO(#1269): Replace eval() with JS-Interpreter before // re-enabling "Manual JavaScript" mode. - if (document.location.href.indexOf('file://') === 0) { + if (document.location.href.startsWith('file://')) { document.write( ''); } diff --git a/demos/blockfactory/workspacefactory/wfactory_model.js b/demos/blockfactory/workspacefactory/wfactory_model.js index 9b9586ea1..b0e1ab9d4 100644 --- a/demos/blockfactory/workspacefactory/wfactory_model.js +++ b/demos/blockfactory/workspacefactory/wfactory_model.js @@ -395,7 +395,7 @@ WorkspaceFactoryModel.prototype.getAllUsedBlockTypes = function() { // Add block types if not already in list. for (var i = 0; i < blocks.length; i++) { var type = blocks[i].getAttribute('type'); - if (list.indexOf(type) === -1) { + if (!list.includes(type)) { list.push(type); } } @@ -444,9 +444,9 @@ WorkspaceFactoryModel.prototype.updateLibBlockTypes = function(blockTypes) { */ WorkspaceFactoryModel.prototype.isDefinedBlockType = function(blockType) { var isStandardBlock = - StandardCategories.coreBlockTypes.indexOf(blockType) !== -1; - var isLibBlock = this.libBlockTypes.indexOf(blockType) !== -1; - var isImportedBlock = this.importedBlockTypes.indexOf(blockType) !== -1; + StandardCategories.coreBlockTypes.includes(blockType); + var isLibBlock = this.libBlockTypes.includes(blockType); + var isImportedBlock = this.importedBlockTypes.includes(blockType); return (isStandardBlock || isLibBlock || isImportedBlock); }; diff --git a/demos/code/code.js b/demos/code/code.js index 63b776aab..c264ff2dc 100644 --- a/demos/code/code.js +++ b/demos/code/code.js @@ -106,7 +106,7 @@ Code.getLang = function() { * @return {boolean} True if RTL, false if LTR. */ Code.isRtl = function() { - return Code.LANGUAGE_RTL.indexOf(Code.LANG) !== -1; + return Code.LANGUAGE_RTL.includes(Code.LANG); }; /** @@ -396,7 +396,7 @@ Code.checkAllGeneratorFunctionsDefined = function(generator) { for (var i = 0; i < blocks.length; i++) { var blockType = blocks[i].type; if (!generator.forBlock[blockType]) { - if (missingBlockGenerators.indexOf(blockType) === -1) { + if (!missingBlockGenerators.includes(blockType)) { missingBlockGenerators.push(blockType); } } @@ -450,7 +450,7 @@ Code.init = function() { // TODO: Clean up the message files so this is done explicitly instead of // through this for-loop. for (var messageKey in MSG) { - if (messageKey.indexOf('cat') === 0) { + if (messageKey.startsWith('cat')) { Blockly.Msg[messageKey.toUpperCase()] = MSG[messageKey]; } } diff --git a/generators/javascript/javascript_generator.ts b/generators/javascript/javascript_generator.ts index 02602e71f..592563f91 100644 --- a/generators/javascript/javascript_generator.ts +++ b/generators/javascript/javascript_generator.ts @@ -251,7 +251,6 @@ export class JavascriptGenerator extends CodeGenerator { * @param code The JavaScript code created for this block. * @param thisOnly True to generate code for only this statement. * @returns JavaScript code with comments and subsequent blocks added. - * @protected */ scrub_(block: Block, code: string, thisOnly = false): string { let commentCode = ''; diff --git a/generators/lua/loops.ts b/generators/lua/loops.ts index fec175b48..01474cd81 100644 --- a/generators/lua/loops.ts +++ b/generators/lua/loops.ts @@ -35,7 +35,7 @@ const CONTINUE_STATEMENT = 'goto continue\n'; * @returns Generated label or '' if unnecessary */ function addContinueLabel(branch: string, indent: string): string { - if (branch.indexOf(CONTINUE_STATEMENT) !== -1) { + if (branch.includes(CONTINUE_STATEMENT)) { // False positives are possible (e.g. a string literal), but are harmless. return branch + indent + '::continue::\n'; } else { diff --git a/generators/php/procedures.ts b/generators/php/procedures.ts index 5d44eb21b..bd114cd0d 100644 --- a/generators/php/procedures.ts +++ b/generators/php/procedures.ts @@ -27,7 +27,7 @@ export function procedures_defreturn(block: Block, generator: PhpGenerator) { for (const variable of usedVariables) { const varName = variable.name; // getVars returns parameter names, not ids, for procedure blocks - if (block.getVars().indexOf(varName) === -1) { + if (!block.getVars().includes(varName)) { globals.push(generator.getVariableName(varName)); } } diff --git a/generators/python/procedures.ts b/generators/python/procedures.ts index 0d9b2e85d..798d6d55a 100644 --- a/generators/python/procedures.ts +++ b/generators/python/procedures.ts @@ -27,7 +27,7 @@ export function procedures_defreturn(block: Block, generator: PythonGenerator) { for (const variable of usedVariables) { const varName = variable.name; // getVars returns parameter names, not ids, for procedure blocks - if (block.getVars().indexOf(varName) === -1) { + if (!block.getVars().includes(varName)) { globals.push(generator.getVariableName(varName)); } } diff --git a/generators/python/python_generator.ts b/generators/python/python_generator.ts index 229c2022c..bf7b87496 100644 --- a/generators/python/python_generator.ts +++ b/generators/python/python_generator.ts @@ -243,8 +243,8 @@ export class PythonGenerator extends CodeGenerator { // Follow the CPython behaviour of repr() for a non-byte string. let quote = "'"; - if (string.indexOf("'") !== -1) { - if (string.indexOf('"') === -1) { + if (string.includes("'")) { + if (!string.includes('"')) { quote = '"'; } else { string = string.replace(/'/g, "\\'"); @@ -276,7 +276,6 @@ export class PythonGenerator extends CodeGenerator { * @param code The Python code created for this block. * @param thisOnly True to generate code for only this statement. * @returns Python code with comments and subsequent blocks added. - */ scrub_(block: Block, code: string, thisOnly = false): string { let commentCode = ''; diff --git a/package-lock.json b/package-lock.json index 8b87ef3f3..27f77fc0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "prettier": "3.2.5", "readline-sync": "^1.4.10", "rimraf": "^5.0.0", - "typescript": "^5.0.2", + "typescript": "^5.3.3", "webdriverio": "^8.32.2", "yargs": "^17.2.1" }, @@ -11017,9 +11017,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", + "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 86ed37072..bb46b884a 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,7 @@ "prettier": "3.2.5", "readline-sync": "^1.4.10", "rimraf": "^5.0.0", - "typescript": "^5.0.2", + "typescript": "^5.3.3", "webdriverio": "^8.32.2", "yargs": "^17.2.1" }, diff --git a/scripts/gulpfiles/release_tasks.js b/scripts/gulpfiles/release_tasks.js index 5a0eb9f0e..f2545c7b9 100644 --- a/scripts/gulpfiles/release_tasks.js +++ b/scripts/gulpfiles/release_tasks.js @@ -131,7 +131,7 @@ function updateBetaVersion(done) { const latestBetaVersion = execSync('npm show blockly version --tag beta').toString().trim(); while (!isValid) { newVersion = readlineSync.question(`What is the new beta version? (latest beta version: ${latestBetaVersion})`); - const existsOnNpm = blocklyVersions.indexOf(newVersion) > -1; + const existsOnNpm = blocklyVersions.includes(newVersion); const isFormatted = newVersion.search(re) > -1; if (!existsOnNpm && isFormatted) { isValid = true; diff --git a/tests/mocha/test_helpers/user_input.js b/tests/mocha/test_helpers/user_input.js index 6606a6652..a5902a7db 100644 --- a/tests/mocha/test_helpers/user_input.js +++ b/tests/mocha/test_helpers/user_input.js @@ -41,10 +41,10 @@ export function createKeyDownEvent(keyCode, modifiers) { keyCode: keyCode, }; if (modifiers && modifiers.length > 0) { - event.altKey = modifiers.indexOf(KeyCodes.ALT) > -1; - event.ctrlKey = modifiers.indexOf(KeyCodes.CTRL) > -1; - event.metaKey = modifiers.indexOf(KeyCodes.META) > -1; - event.shiftKey = modifiers.indexOf(KeyCodes.SHIFT) > -1; + event.altKey = modifiers.includes(KeyCodes.ALT); + event.ctrlKey = modifiers.includes(KeyCodes.CTRL); + event.metaKey = modifiers.includes(KeyCodes.META); + event.shiftKey = modifiers.includes(KeyCodes.SHIFT); } return new KeyboardEvent('keydown', event); } diff --git a/tests/playgrounds/screenshot.js b/tests/playgrounds/screenshot.js index af20f9d52..c443755a5 100644 --- a/tests/playgrounds/screenshot.js +++ b/tests/playgrounds/screenshot.js @@ -89,8 +89,7 @@ function workspaceToSvg_(workspace, callback, customCss) { const css = [].slice .call(document.head.querySelectorAll('style')) .filter( - (el) => - /\.blocklySvg/.test(el.innerText) || el.id.indexOf('blockly-') === 0, + (el) => /\.blocklySvg/.test(el.innerText) || el.id.startsWith('blockly-'), ) .map((el) => el.innerText) .join('\n');