diff --git a/.eslintrc.json b/.eslintrc.json index 06a71cb16..14a30722e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -54,8 +54,10 @@ "_comment": "Blockly uses single quotes except for JSON blobs, which must use double quotes.", "quotes": ["off"], "semi": ["error", "always"], - "_comment": "Blockly doesn't have space before function paren", + "_comment": "Blockly doesn't have space before function paren when defining functions", "space-before-function-paren": ["error", "never"], + "_comment": "Blocklydoesn't have space before function paren when calling functions", + "func-call-spacing": ["error", "never"], "space-infix-ops": ["error"], "_comment": "Blockly uses 'use strict' in files", "strict": ["off"], @@ -64,7 +66,14 @@ "_comment": "Closure style allows redeclarations", "no-redeclare": ["off"], "valid-jsdoc": ["error", {"requireReturn": false}], - "no-console": ["off"] + "no-console": ["off"], + "no-multi-spaces": ["error", { "ignoreEOLComments": true }], + "operator-linebreak": ["error", "after"], + "spaced-comment": ["warn", "always", { + "block": { + "balanced": true + } + }] }, "env": { "browser": true diff --git a/core/block_render_svg.js b/core/block_render_svg.js index 05cf46e03..8b6ac81fb 100644 --- a/core/block_render_svg.js +++ b/core/block_render_svg.js @@ -372,7 +372,7 @@ Blockly.BlockSvg.prototype.renderFields_ = function(fieldList, } } if (this.RTL && - field instanceof Blockly.FieldImage && + field instanceof Blockly.FieldImage && field.getFlipRtl()) { scale = 'scale(-1 1)'; translateX += field.renderWidth; diff --git a/core/bubble.js b/core/bubble.js index fe72b2c64..516c4b208 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -523,7 +523,7 @@ Blockly.Bubble.prototype.getOptimalRelativeLeft_ = function(metrics) { if (this.workspace_.RTL) { // Bubble coordinates are flipped in RTL. - var bubbleRight = this.anchorXY_.x - relativeLeft; + var bubbleRight = this.anchorXY_.x - relativeLeft; var bubbleLeft = bubbleRight - this.width_; var workspaceRight = metrics.viewLeft + metrics.viewWidth; diff --git a/core/bubble_dragger.js b/core/bubble_dragger.js index c8eed71d9..81286bed7 100644 --- a/core/bubble_dragger.js +++ b/core/bubble_dragger.js @@ -143,7 +143,7 @@ Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) { this.draggingBubble_.moveDuringDrag(this.dragSurface_, newLoc); if (this.draggingBubble_.isDeletable()) { - this.deleteArea_ = this.workspace_.isDeleteArea(e); + this.deleteArea_ = this.workspace_.isDeleteArea(e); this.updateCursorDuringBubbleDrag_(); } }; diff --git a/core/field_dropdown.js b/core/field_dropdown.js index d6599e637..10155267b 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -246,8 +246,8 @@ Blockly.FieldDropdown.prototype.positionMenu_ = function(menu) { var menuSize = Blockly.utils.uiMenu.getSize(menu); - var menuMaxHeightPx = Blockly.FieldDropdown.MAX_MENU_HEIGHT_VH - * document.documentElement.clientHeight; + var menuMaxHeightPx = Blockly.FieldDropdown.MAX_MENU_HEIGHT_VH * + document.documentElement.clientHeight; if (menuSize.height > menuMaxHeightPx) { menuSize.height = menuMaxHeightPx; } diff --git a/core/field_variable.js b/core/field_variable.js index 74f57378e..dd6bed075 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -337,7 +337,7 @@ Blockly.FieldVariable.prototype.setTypes_ = function(opt_variableTypes, 'a FieldVariable'); } // Only update the field once all checks pass. - this.defaultType_ = defaultType; + this.defaultType_ = defaultType; this.variableTypes = variableTypes; }; diff --git a/core/flyout_base.js b/core/flyout_base.js index b92c6bcf8..f22b19637 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -253,7 +253,7 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) { this.targetWorkspace_.getGesture.bind(this.targetWorkspace_); // Get variables from the main workspace rather than the target workspace. - this.workspace_.variableMap_ = this.targetWorkspace_.getVariableMap(); + this.workspace_.variableMap_ = this.targetWorkspace_.getVariableMap(); this.workspace_.createPotentialVariableMap(); }; diff --git a/core/insertion_marker_manager.js b/core/insertion_marker_manager.js index 79b9b216e..a40b3b7ba 100644 --- a/core/insertion_marker_manager.js +++ b/core/insertion_marker_manager.js @@ -343,7 +343,7 @@ Blockly.InsertionMarkerManager.prototype.shouldUpdatePreviews_ = function( var yDiff = this.localConnection_.y_ + dxy.y - this.closestConnection_.y_; var curDistance = Math.sqrt(xDiff * xDiff + yDiff * yDiff); // Slightly prefer the existing preview over a new preview. - return !(candidateClosest && radius > curDistance - + return !(candidateClosest && radius > curDistance - Blockly.CURRENT_CONNECTION_PREFERENCE); } else if (!this.localConnection_ && !this.closestConnection_) { // We weren't showing a preview before, but we should now. diff --git a/core/keyboard_nav/cursor_svg.js b/core/keyboard_nav/cursor_svg.js index fc0f825ea..7214cd90d 100644 --- a/core/keyboard_nav/cursor_svg.js +++ b/core/keyboard_nav/cursor_svg.js @@ -258,8 +258,8 @@ Blockly.CursorSvg.prototype.showWithStack_ = function() { var height = heightWidth.height + Blockly.CursorSvg.STACK_PADDING; // Shift the rectangle slightly to upper left so padding is equal on all sides. - var x = -1 * Blockly.CursorSvg.STACK_PADDING / 2; - var y = -1 * Blockly.CursorSvg.STACK_PADDING / 2; + var x = -1 * Blockly.CursorSvg.STACK_PADDING / 2; + var y = -1 * Blockly.CursorSvg.STACK_PADDING / 2; // If the block has an output connection it needs more padding. if (block.outputConnection) { diff --git a/core/mutator.js b/core/mutator.js index f3aa9df16..b2a2f21f3 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -165,7 +165,7 @@ Blockly.Mutator.prototype.createEditor_ = function() { // a top level svg. Instead of handling scale themselves, mutators // inherit scale from the parent workspace. // To fix this, scale needs to be applied at a different level in the dom. - var flyoutSvg = this.workspace_.addFlyout_('g'); + var flyoutSvg = this.workspace_.addFlyout_('g'); var background = this.workspace_.createDom('blocklyMutatorBackground'); // Insert the flyout after the but before the block canvas so that diff --git a/core/trashcan.js b/core/trashcan.js index 8ab4c0e7b..4747c644e 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -405,8 +405,8 @@ Blockly.Trashcan.prototype.animateLid_ = function() { * @private */ Blockly.Trashcan.prototype.setLidAngle_ = function(lidAngle) { - var openAtRight = this.workspace_.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT - || (this.workspace_.horizontalLayout && this.workspace_.RTL); + var openAtRight = this.workspace_.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT || + (this.workspace_.horizontalLayout && this.workspace_.RTL); this.svgLid_.setAttribute('transform', 'rotate(' + (openAtRight ? -lidAngle : lidAngle) + ',' + (openAtRight ? 4 : this.WIDTH_ - 4) + ',' + diff --git a/core/utils.js b/core/utils.js index 7f184d507..a3a5bb97a 100644 --- a/core/utils.js +++ b/core/utils.js @@ -339,7 +339,7 @@ Blockly.utils.tokenizeInterpolation_ = function(message, state = 0; // and parse as string literal. } else if (c != '}') { buffer.push(c); - } else { + } else { var rawKey = buffer.join(''); if (/[A-Z]\w*/i.test(rawKey)) { // Strict matching // Found a valid string key. Attempt case insensitive match. diff --git a/core/xml.js b/core/xml.js index 50c377ed8..148ca3fd2 100644 --- a/core/xml.js +++ b/core/xml.js @@ -479,7 +479,7 @@ Blockly.Xml.appendDomToWorkspace = function(xml, workspace) { if (blockXY.y < newY) { newY = blockXY.y; } - if (blockXY.x < newX) { // if we align also on x + if (blockXY.x < newX) { // if we align also on x newX = blockXY.x; } } diff --git a/tests/mocha/connection_test.js b/tests/mocha/connection_test.js index ef3714228..b4d171927 100644 --- a/tests/mocha/connection_test.js +++ b/tests/mocha/connection_test.js @@ -7,8 +7,8 @@ suite('Connections', function() { var connections = block.getConnections_(true); for (var i = 0; i < connections.length; i++) { var connection = connections[i]; - if (connection.type == Blockly.PREVIOUS_STATEMENT - || connection.type == Blockly.OUTPUT_VALUE) { + if (connection.type == Blockly.PREVIOUS_STATEMENT || + connection.type == Blockly.OUTPUT_VALUE) { // Only superior connections on inputs get hidden continue; } diff --git a/tests/mocha/field_angle_test.js b/tests/mocha/field_angle_test.js index 9a8252834..fee8f813e 100644 --- a/tests/mocha/field_angle_test.js +++ b/tests/mocha/field_angle_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Angle Fields', function() { +suite('Angle Fields', function() { function assertValue(angleField, expectedValue, opt_expectedText) { var actualValue = angleField.getValue(); var actualText = angleField.getText(); diff --git a/tests/mocha/field_colour_test.js b/tests/mocha/field_colour_test.js index b3c10d954..39ef4c631 100644 --- a/tests/mocha/field_colour_test.js +++ b/tests/mocha/field_colour_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Colour Fields', function() { +suite('Colour Fields', function() { function assertValue(colourField, expectedValue, expectedText) { var actualValue = colourField.getValue(); var actualText = colourField.getText(); diff --git a/tests/mocha/field_date_test.js b/tests/mocha/field_date_test.js index 326a6eb86..05620e95b 100644 --- a/tests/mocha/field_date_test.js +++ b/tests/mocha/field_date_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Date Fields', function() { +suite('Date Fields', function() { function assertValue(dateField, expectedValue) { var actualValue = dateField.getValue(); var actualText = dateField.getText(); diff --git a/tests/mocha/field_dropdown_test.js b/tests/mocha/field_dropdown_test.js index aec3de6de..c7499fd26 100644 --- a/tests/mocha/field_dropdown_test.js +++ b/tests/mocha/field_dropdown_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Dropdown Fields', function() { +suite('Dropdown Fields', function() { function assertValue(dropdownField, expectedValue, expectedText) { var actualValue = dropdownField.getValue(); var actualText = dropdownField.getText(); diff --git a/tests/mocha/field_image_test.js b/tests/mocha/field_image_test.js index c1c41b2a1..e7a317cbe 100644 --- a/tests/mocha/field_image_test.js +++ b/tests/mocha/field_image_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Image Fields', function() { +suite('Image Fields', function() { function assertValue(imageField, expectedValue, expectedText) { var actualValue = imageField.getValue(); var actualText = imageField.getText(); diff --git a/tests/mocha/field_label_serializable_test.js b/tests/mocha/field_label_serializable_test.js index 2b508dd63..09659af1a 100644 --- a/tests/mocha/field_label_serializable_test.js +++ b/tests/mocha/field_label_serializable_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Label Serializable Fields', function() { +suite('Label Serializable Fields', function() { function assertValue(labelField, expectedValue) { var actualValue = labelField.getValue(); var actualText = labelField.getText(); diff --git a/tests/mocha/field_label_test.js b/tests/mocha/field_label_test.js index 1f9b8d0f6..8cba0f472 100644 --- a/tests/mocha/field_label_test.js +++ b/tests/mocha/field_label_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Label Fields', function() { +suite('Label Fields', function() { function assertValue(labelField, expectedValue) { var actualValue = labelField.getValue(); var actualText = labelField.getText(); diff --git a/tests/mocha/field_number_test.js b/tests/mocha/field_number_test.js index 4915c8b7f..d78b5e29c 100644 --- a/tests/mocha/field_number_test.js +++ b/tests/mocha/field_number_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Number Fields', function() { +suite('Number Fields', function() { function assertValue(numberField, expectedValue, opt_expectedText) { var actualValue = numberField.getValue(); var actualText = numberField.getText(); @@ -48,7 +48,7 @@ suite ('Number Fields', function() { { 'value': value, min: value, max: value, precision: value }); } function assertNumberFieldSameValues(numberField, value) { - assertNumberField(numberField, value, value, value, value); + assertNumberField(numberField, value, value, value, value); } suite('Constructor', function() { test('Empty', function() { diff --git a/tests/mocha/field_textinput_test.js b/tests/mocha/field_textinput_test.js index 9b4e943be..27855a90e 100644 --- a/tests/mocha/field_textinput_test.js +++ b/tests/mocha/field_textinput_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -suite ('Text Input Fields', function() { +suite('Text Input Fields', function() { function assertValue(textInputField, expectedValue, opt_expectedText) { var actualValue = textInputField.getValue(); var actualText = textInputField.getText();