From d83eb1364bc2bdb0449162f9d258112366444f3a Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 21 Sep 2021 13:19:55 -0700 Subject: [PATCH] fix: enable missingRequire in build_tasks (#5510) --- core/common.js | 14 +++++++++----- core/interfaces/i_selectable.js | 10 ++++++---- core/serialization/exceptions.js | 13 +++++++------ core/toolbox/category.js | 2 +- core/zoom_controls.js | 8 +++++--- scripts/gulpfiles/build_tasks.js | 5 ++--- 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/core/common.js b/core/common.js index 8efbcba6d..edc2ab6ce 100644 --- a/core/common.js +++ b/core/common.js @@ -17,7 +17,11 @@ goog.module.declareLegacyNamespace(); /* eslint-disable-next-line no-unused-vars */ const Connection = goog.requireType('Blockly.Connection'); /* eslint-disable-next-line no-unused-vars */ +const ICopyable = goog.requireType('Blockly.ICopyable'); +/* eslint-disable-next-line no-unused-vars */ const Workspace = goog.requireType('Blockly.Workspace'); +/* eslint-disable-next-line no-unused-vars */ +const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg'); /** @@ -49,13 +53,13 @@ exports.setMainWorkspace = setMainWorkspace; /** * Currently selected block. - * @type {?Blockly.ICopyable} + * @type {?ICopyable} */ let selected = null; /** * Returns the currently selected block. - * @return {?Blockly.ICopyable} The currently selected block. + * @return {?ICopyable} The currently selected block. */ const getSelected = function() { return selected; @@ -64,7 +68,7 @@ exports.getSelected = getSelected; /** * Sets the currently selected block. - * @param {?Blockly.ICopyable} newSelection The newly selected block. + * @param {?ICopyable} newSelection The newly selected block. */ const setSelected = function(newSelection) { selected = newSelection; @@ -105,9 +109,9 @@ exports.setParentContainer = setParentContainer; * See Blockly.resizeSvgContents to resize the workspace when the contents * change (e.g. when a block is added or removed). * Record the height/width of the SVG image. - * @param {!Blockly.WorkspaceSvg} workspace Any workspace in the SVG. + * @param {!WorkspaceSvg} workspace Any workspace in the SVG. */ - const svgResize = function(workspace) { +const svgResize = function(workspace) { let mainWorkspace = workspace; while (mainWorkspace.options.parentWorkspace) { mainWorkspace = mainWorkspace.options.parentWorkspace; diff --git a/core/interfaces/i_selectable.js b/core/interfaces/i_selectable.js index d3355f9ab..e95b0dcfe 100644 --- a/core/interfaces/i_selectable.js +++ b/core/interfaces/i_selectable.js @@ -14,14 +14,16 @@ goog.module('Blockly.ISelectable'); goog.module.declareLegacyNamespace(); -goog.requireType('Blockly.IDeletable'); -goog.requireType('Blockly.IMovable'); +// eslint-disable-next-line no-unused-vars +const IDeletable = goog.requireType('Blockly.IDeletable'); +// eslint-disable-next-line no-unused-vars +const IMovable = goog.requireType('Blockly.IMovable'); /** * The interface for an object that is selectable. - * @extends {Blockly.IDeletable} - * @extends {Blockly.IMovable} + * @extends {IDeletable} + * @extends {IMovable} * @interface */ const ISelectable = function() {}; diff --git a/core/serialization/exceptions.js b/core/serialization/exceptions.js index 1d6cd129c..4b85f5603 100644 --- a/core/serialization/exceptions.js +++ b/core/serialization/exceptions.js @@ -13,11 +13,12 @@ goog.module('Blockly.serialization.exceptions'); goog.module.declareLegacyNamespace(); - +// eslint-disable-next-line no-unused-vars +const Block = goog.requireType('Blockly.Block'); // eslint-disable-next-line no-unused-vars const {State} = goog.requireType('Blockly.serialization.blocks'); -class DeserializationError extends Error { } +class DeserializationError extends Error {} exports.DeserializationError = DeserializationError; /** @@ -49,7 +50,7 @@ class MissingConnection extends DeserializationError { /** * @param {string} connection The name of the connection that is missing. E.g. * 'IF0', or 'next'. - * @param {!Blockly.Block} block The block missing the connection. + * @param {!Block} block The block missing the connection. * @param {!State} state The state object containing the bad connection. * @package */ @@ -59,7 +60,7 @@ connection`); /** * The block missing the connection. - * @type {!Blockly.Block} + * @type {!Block} */ this.block = block; @@ -81,7 +82,7 @@ class BadConnectionCheck extends DeserializationError { * @param {string} reason The reason the connections were not compatible. * @param {string} childConnection The name of the incompatible child * connection. E.g. 'output' or 'previous'. - * @param {!Blockly.Block} childBlock The child block that could not connect + * @param {!Block} childBlock The child block that could not connect * to its parent. * @param {!State} childState The state object representing the child block. * @package @@ -92,7 +93,7 @@ ${childConnection} to its parent, because: ${reason}`); /** * The block that could not connect to its parent. - * @type {!Blockly.Block} + * @type {!Block} */ this.childBlock = childBlock; diff --git a/core/toolbox/category.js b/core/toolbox/category.js index c085420c5..d05029034 100644 --- a/core/toolbox/category.js +++ b/core/toolbox/category.js @@ -206,7 +206,7 @@ ToolboxCategory.prototype.parseContents_ = function(categoryDef) { for (let i = 0; i < contents.length; i++) { const itemDef = contents[i]; const flyoutItem = - /** @type {Blockly.utils.toolbox.FlyoutItemInfo} */ (itemDef); + /** @type {toolbox.FlyoutItemInfo} */ (itemDef); this.flyoutItems_.push(flyoutItem); } } diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 0348a202f..5919c9578 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -18,6 +18,8 @@ const Css = goog.require('Blockly.Css'); const Events = goog.require('Blockly.Events'); /* eslint-disable-next-line no-unused-vars */ const IPositionable = goog.requireType('Blockly.IPositionable'); +/* eslint-disable-next-line no-unused-vars */ +const MetricsManager = goog.requireType('Blockly.MetricsManager'); const Rect = goog.require('Blockly.utils.Rect'); const Size = goog.require('Blockly.utils.Size'); const Svg = goog.require('Blockly.utils.Svg'); @@ -247,7 +249,7 @@ ZoomControls.prototype.getBoundingRectangle = function() { * Positions the zoom controls. * It is positioned in the opposite corner to the corner the * categories/toolbox starts at. - * @param {!Blockly.MetricsManager.UiMetrics} metrics The workspace metrics. + * @param {!MetricsManager.UiMetrics} metrics The workspace metrics. * @param {!Array} savedPositions List of rectangles that * are already on the workspace. */ @@ -264,8 +266,8 @@ ZoomControls.prototype.position = function(metrics, savedPositions) { height += this.LARGE_SPACING_ + this.HEIGHT_; } const startRect = uiPosition.getStartPositionRect( - cornerPosition, new Size(this.WIDTH_, height), - this.MARGIN_HORIZONTAL_, this.MARGIN_VERTICAL_, metrics, this.workspace_); + cornerPosition, new Size(this.WIDTH_, height), this.MARGIN_HORIZONTAL_, + this.MARGIN_VERTICAL_, metrics, this.workspace_); const verticalPosition = cornerPosition.vertical; const bumpDirection = verticalPosition === uiPosition.verticalPosition.TOP ? diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index 42fa62d21..a22e0414e 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -77,8 +77,7 @@ var JSCOMP_ERROR = [ 'missingPolyfill', 'missingProperties', 'missingProvide', - // 'missingRequire', As of Jan 8 2021, this enables the strict require check. - // Disabling this until we have fixed all the require issues. + 'missingRequire', 'missingReturn', // 'missingSourcesWarnings', 'moduleLoad', @@ -397,7 +396,7 @@ function buildLangfiles(done) { // Create output directory. const outputDir = path.join(BUILD_DIR, 'msg', 'js'); fs.mkdirSync(outputDir, {recursive: true}); - + // Run create_messages.py. let json_files = fs.readdirSync(path.join('msg', 'json')); json_files = json_files.filter(file => file.endsWith('json') &&