From 1e3450a051698300cc2aca2fd8bbeaebcddc58d4 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 23 Jan 2018 17:27:35 -0800 Subject: [PATCH] Indentation lint that blocks moving to eslint 4.0 --- core/blockly.js | 10 ++++++---- core/toolbox.js | 13 +++++++------ core/trashcan.js | 27 +++++++++++++++++++-------- core/variable_map.js | 4 ++-- core/warning.js | 24 +++++++++++++++--------- core/widgetdiv.js | 2 +- core/workspace_drag_surface_svg.js | 23 ++++++++++++----------- core/workspace_dragger.js | 2 +- core/workspace_svg.js | 4 ++-- core/xml.js | 17 ++++++++--------- core/zoom_controls.js | 30 ++++++++++++++++++------------ 11 files changed, 91 insertions(+), 65 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index 32950fe0d..e3b222993 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -120,8 +120,10 @@ Blockly.hueToRgb = function(hue) { * @return {!Object} Contains width and height properties. */ Blockly.svgSize = function(svg) { - return {width: svg.cachedWidth_, - height: svg.cachedHeight_}; + return { + width: svg.cachedWidth_, + height: svg.cachedHeight_ + }; }; /** @@ -307,7 +309,7 @@ Blockly.hideChaff = function(opt_allowToolbox) { Blockly.addChangeListener = function(func) { // Backwards compatibility from before there could be multiple workspaces. console.warn('Deprecated call to Blockly.addChangeListener, ' + - 'use workspace.addChangeListener instead.'); + 'use workspace.addChangeListener instead.'); return Blockly.getMainWorkspace().addChangeListener(func); }; @@ -381,7 +383,7 @@ Blockly.defineBlocksWithJsonArray = function(jsonArray) { var typename = elem.type; if (typename == null || typename === '') { console.warn('Block definition #' + i + - ' in JSON array is missing a type attribute. Skipping.'); + ' in JSON array is missing a type attribute. Skipping.'); } else { if (Blockly.Blocks[typename]) { console.warn('Block definition #' + i + diff --git a/core/toolbox.js b/core/toolbox.js index 0a07fddba..e71a02584 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -190,7 +190,7 @@ Blockly.Toolbox.prototype.init = function() { this.flyout_ = new Blockly.VerticalFlyout(workspaceOptions); } goog.dom.insertSiblingAfter(this.flyout_.createDom('svg'), - this.workspace_.getParentSvg()); + this.workspace_.getParentSvg()); this.flyout_.init(workspace); this.config_['cleardotPath'] = workspace.options.pathToMedia + '1x1.gif'; @@ -315,7 +315,7 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) { // Decode the category name for any potential message references // (eg. `%{BKY_CATEGORY_NAME_LOGIC}`). var categoryName = Blockly.utils.replaceMessageReferences( - childIn.getAttribute('name')); + childIn.getAttribute('name')); var childOut = this.tree_.createNode(categoryName); childOut.blocks = []; treeOut.add(childOut); @@ -428,7 +428,7 @@ Blockly.Toolbox.prototype.clearSelection = function() { */ Blockly.Toolbox.prototype.addStyle = function(style) { Blockly.utils.addClass(/** @type {!Element} */ (this.HtmlDiv), - style); + style); }; /** @@ -438,7 +438,7 @@ Blockly.Toolbox.prototype.addStyle = function(style) { */ Blockly.Toolbox.prototype.removeStyle = function(style) { Blockly.utils.removeClass(/** @type {!Element} */ (this.HtmlDiv), - style); + style); }; /** @@ -542,8 +542,9 @@ Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_ = function(e) { * @override */ Blockly.Toolbox.TreeControl.prototype.createNode = function(opt_html) { - return new Blockly.Toolbox.TreeNode(this.toolbox_, opt_html ? - goog.html.SafeHtml.htmlEscape(opt_html) : goog.html.SafeHtml.EMPTY, + var html = opt_html ? + goog.html.SafeHtml.htmlEscape(opt_html) : goog.html.SafeHtml.EMPTY; + return new Blockly.Toolbox.TreeNode(this.toolbox_, html, this.getConfig(), this.getDomHelper()); }; diff --git a/core/trashcan.js b/core/trashcan.js index 7dfb600a1..031daf7b3 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -172,13 +172,20 @@ Blockly.Trashcan.prototype.createDom = function() { {'id': 'blocklyTrashBodyClipPath' + rnd}, this.svgGroup_); Blockly.utils.createSvgElement('rect', - {'width': this.WIDTH_, 'height': this.BODY_HEIGHT_, - 'y': this.LID_HEIGHT_}, + { + 'width': this.WIDTH_, + 'height': this.BODY_HEIGHT_, + 'y': this.LID_HEIGHT_ + }, clip); var body = Blockly.utils.createSvgElement('image', - {'width': Blockly.SPRITE.width, 'x': -this.SPRITE_LEFT_, - 'height': Blockly.SPRITE.height, 'y': -this.SPRITE_TOP_, - 'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')'}, + { + 'width': Blockly.SPRITE.width, + 'x': -this.SPRITE_LEFT_, + 'height': Blockly.SPRITE.height, + 'y': -this.SPRITE_TOP_, + 'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')' + }, this.svgGroup_); body.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); @@ -189,9 +196,13 @@ Blockly.Trashcan.prototype.createDom = function() { Blockly.utils.createSvgElement('rect', {'width': this.WIDTH_, 'height': this.LID_HEIGHT_}, clip); this.svgLid_ = Blockly.utils.createSvgElement('image', - {'width': Blockly.SPRITE.width, 'x': -this.SPRITE_LEFT_, - 'height': Blockly.SPRITE.height, 'y': -this.SPRITE_TOP_, - 'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')'}, + { + 'width': Blockly.SPRITE.width, + 'x': -this.SPRITE_LEFT_, + 'height': Blockly.SPRITE.height, + 'y': -this.SPRITE_TOP_, + 'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')' + }, this.svgGroup_); this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); diff --git a/core/variable_map.js b/core/variable_map.js index 2bc9d859f..a7044898c 100644 --- a/core/variable_map.js +++ b/core/variable_map.js @@ -18,7 +18,7 @@ * limitations under the License. */ - /** +/** * @fileoverview Object representing a map of variables and their types. * @author marisaleung@google.com (Marisa Leung) */ @@ -35,7 +35,7 @@ goog.provide('Blockly.VariableMap'); * @constructor */ Blockly.VariableMap = function(workspace) { - /** + /** * A map from variable type to list of variable names. The lists contain all * of the named variables in the workspace, including variables * that are not currently in use. diff --git a/core/warning.js b/core/warning.js index 1c9d3481d..d0dffff43 100644 --- a/core/warning.js +++ b/core/warning.js @@ -57,21 +57,27 @@ Blockly.Warning.prototype.collapseHidden = false; Blockly.Warning.prototype.drawIcon_ = function(group) { // Triangle with rounded corners. Blockly.utils.createSvgElement('path', - {'class': 'blocklyIconShape', - 'd': 'M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z'}, - group); + { + 'class': 'blocklyIconShape', + 'd': 'M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z' + }, + group); // Can't use a real '!' text character since different browsers and operating // systems render it differently. // Body of exclamation point. Blockly.utils.createSvgElement('path', - {'class': 'blocklyIconSymbol', - 'd': 'm7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z'}, - group); + { + 'class': 'blocklyIconSymbol', + 'd': 'm7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z' + }, + group); // Dot of exclamation point. Blockly.utils.createSvgElement('rect', - {'class': 'blocklyIconSymbol', - 'x': '7', 'y': '11', 'height': '2', 'width': '2'}, - group); + { + 'class': 'blocklyIconSymbol', + 'x': '7', 'y': '11', 'height': '2', 'width': '2' + }, + group); }; /** diff --git a/core/widgetdiv.js b/core/widgetdiv.js index 005690a0c..be8a0e14e 100644 --- a/core/widgetdiv.js +++ b/core/widgetdiv.js @@ -134,7 +134,7 @@ Blockly.WidgetDiv.hideIfOwner = function(oldOwner) { * @param {boolean} rtl True if RTL, false if LTR. */ Blockly.WidgetDiv.position = function(anchorX, anchorY, windowSize, - scrollOffset, rtl) { + scrollOffset, rtl) { // Don't let the widget go above the top edge of the window. if (anchorY < scrollOffset.y) { anchorY = scrollOffset.y; diff --git a/core/workspace_drag_surface_svg.js b/core/workspace_drag_surface_svg.js index e24886acc..adb5905e9 100644 --- a/core/workspace_drag_surface_svg.js +++ b/core/workspace_drag_surface_svg.js @@ -88,13 +88,14 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.createDom = function() { * /g> * */ - this.SVG_ = Blockly.utils.createSvgElement('svg', { - 'xmlns': Blockly.SVG_NS, - 'xmlns:html': Blockly.HTML_NS, - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', - 'version': '1.1', - 'class': 'blocklyWsDragSurface blocklyOverflowVisible' - }, null); + this.SVG_ = Blockly.utils.createSvgElement('svg', + { + 'xmlns': Blockly.SVG_NS, + 'xmlns:html': Blockly.HTML_NS, + 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'version': '1.1', + 'class': 'blocklyWsDragSurface blocklyOverflowVisible' + }, null); this.container_.appendChild(this.SVG_); }; @@ -115,7 +116,7 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.translateSurface = function(x, y) { this.SVG_.style.display = 'block'; Blockly.utils.setCssTransform(this.SVG_, - 'translate3d(' + x + 'px, ' + y + 'px, 0px)'); + 'translate3d(' + x + 'px, ' + y + 'px, 0px)'); }; /** @@ -157,7 +158,7 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.clearAndHide = function(newSurface) { // Hide the drag surface. this.SVG_.style.display = 'none'; goog.asserts.assert(this.SVG_.childNodes.length == 0, - 'Drag surface was not cleared.'); + 'Drag surface was not cleared.'); Blockly.utils.setCssTransform(this.SVG_, ''); this.previousSibling_ = null; }; @@ -177,12 +178,12 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.clearAndHide = function(newSurface) { Blockly.WorkspaceDragSurfaceSvg.prototype.setContentsAndShow = function( blockCanvas, bubbleCanvas, previousSibling, width, height, scale) { goog.asserts.assert(this.SVG_.childNodes.length == 0, - 'Already dragging a block.'); + 'Already dragging a block.'); this.previousSibling_ = previousSibling; // Make sure the blocks and bubble canvas are scaled appropriately. blockCanvas.setAttribute('transform', 'translate(0, 0) scale(' + scale + ')'); bubbleCanvas.setAttribute('transform', - 'translate(0, 0) scale(' + scale + ')'); + 'translate(0, 0) scale(' + scale + ')'); this.SVG_.setAttribute('width', width); this.SVG_.setAttribute('height', height); this.SVG_.appendChild(blockCanvas); diff --git a/core/workspace_dragger.js b/core/workspace_dragger.js index 5c45aab3f..a6b0453da 100644 --- a/core/workspace_dragger.js +++ b/core/workspace_dragger.js @@ -62,7 +62,7 @@ Blockly.WorkspaceDragger = function(workspace) { * @private */ this.startScrollXY_ = new goog.math.Coordinate(workspace.scrollX, - workspace.scrollY); + workspace.scrollY); }; /** diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 19fa87cf7..81132cee5 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -634,7 +634,7 @@ Blockly.WorkspaceSvg.prototype.resize = function() { */ Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled = function() { - /* eslint-disable indent */ + /* eslint-disable indent */ var currScroll = goog.dom.getDocumentScroll(); if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_, currScroll)) { @@ -966,7 +966,7 @@ Blockly.WorkspaceSvg.prototype.deleteVariableById = function(id) { */ Blockly.WorkspaceSvg.prototype.createVariable = function(name, opt_type, opt_id) { var newVar = Blockly.WorkspaceSvg.superClass_.createVariable.call(this, name, - opt_type, opt_id); + opt_type, opt_id); this.refreshToolboxSelection_(); return newVar; }; diff --git a/core/xml.js b/core/xml.js index fb695a48f..b4033e896 100644 --- a/core/xml.js +++ b/core/xml.js @@ -585,7 +585,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { var block = null; var prototypeName = xmlBlock.getAttribute('type'); goog.asserts.assert(prototypeName, 'Block type unspecified: %s', - xmlBlock.outerHTML); + xmlBlock.outerHTML); var id = xmlBlock.getAttribute('id'); block = workspace.newBlock(prototypeName, id); @@ -600,13 +600,12 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { // Find any enclosed blocks or shadows in this tag. var childBlockElement = null; var childShadowElement = null; - for (var j = 0, grandchildNode; grandchildNode = xmlChild.childNodes[j]; - j++) { - if (grandchildNode.nodeType == 1) { - if (grandchildNode.nodeName.toLowerCase() == 'block') { - childBlockElement = /** @type {!Element} */ (grandchildNode); - } else if (grandchildNode.nodeName.toLowerCase() == 'shadow') { - childShadowElement = /** @type {!Element} */ (grandchildNode); + for (var j = 0, grandchild; grandchild = xmlChild.childNodes[j]; j++) { + if (grandchild.nodeType == 1) { + if (grandchild.nodeName.toLowerCase() == 'block') { + childBlockElement = /** @type {!Element} */ (grandchild); + } else if (grandchild.nodeName.toLowerCase() == 'shadow') { + childShadowElement = /** @type {!Element} */ (grandchild); } } } @@ -731,7 +730,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { var children = block.getChildren(); for (var i = 0, child; child = children[i]; i++) { goog.asserts.assert(child.isShadow(), - 'Shadow block not allowed non-shadow child.'); + 'Shadow block not allowed non-shadow child.'); } // Ensure this block doesn't have any variable inputs. goog.asserts.assert(block.getVarModels().length == 0, diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 143680658..8d8b085d4 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -125,10 +125,12 @@ Blockly.ZoomControls.prototype.createDom = function() { {'width': 32, 'height': 32, 'y': 77}, clip); var zoomoutSvg = Blockly.utils.createSvgElement('image', - {'width': Blockly.SPRITE.width, - 'height': Blockly.SPRITE.height, 'x': -64, - 'y': -15, - 'clip-path': 'url(#blocklyZoomoutClipPath' + rnd + ')'}, + { + 'width': Blockly.SPRITE.width, + 'height': Blockly.SPRITE.height, 'x': -64, + 'y': -15, + 'clip-path': 'url(#blocklyZoomoutClipPath' + rnd + ')' + }, this.svgGroup_); zoomoutSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', workspace.options.pathToMedia + Blockly.SPRITE.url); @@ -140,11 +142,13 @@ Blockly.ZoomControls.prototype.createDom = function() { {'width': 32, 'height': 32, 'y': 43}, clip); var zoominSvg = Blockly.utils.createSvgElement('image', - {'width': Blockly.SPRITE.width, - 'height': Blockly.SPRITE.height, - 'x': -32, - 'y': -49, - 'clip-path': 'url(#blocklyZoominClipPath' + rnd + ')'}, + { + 'width': Blockly.SPRITE.width, + 'height': Blockly.SPRITE.height, + 'x': -32, + 'y': -49, + 'clip-path': 'url(#blocklyZoominClipPath' + rnd + ')' + }, this.svgGroup_); zoominSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', workspace.options.pathToMedia + Blockly.SPRITE.url); @@ -156,9 +160,11 @@ Blockly.ZoomControls.prototype.createDom = function() { {'width': 32, 'height': 32}, clip); var zoomresetSvg = Blockly.utils.createSvgElement('image', - {'width': Blockly.SPRITE.width, - 'height': Blockly.SPRITE.height, 'y': -92, - 'clip-path': 'url(#blocklyZoomresetClipPath' + rnd + ')'}, + { + 'width': Blockly.SPRITE.width, + 'height': Blockly.SPRITE.height, 'y': -92, + 'clip-path': 'url(#blocklyZoomresetClipPath' + rnd + ')' + }, this.svgGroup_); zoomresetSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', workspace.options.pathToMedia + Blockly.SPRITE.url);