Skip to content

Commit

Permalink
chore: fix more lint (#5676)
Browse files Browse the repository at this point in the history
* chore: fix assorted lint

* chore: clang-format

* chore: clang-format
  • Loading branch information
rachel-fenichel authored Nov 9, 2021
1 parent beefe36 commit f14a1c8
Show file tree
Hide file tree
Showing 30 changed files with 146 additions and 98 deletions.
1 change: 0 additions & 1 deletion blocks/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ Blockly.Extensions.registerMutator('controls_if_mutator',
* @package
*/
Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION = function() {

this.setTooltip(function() {
if (!this.elseifCount_ && !this.elseCount_) {
return Blockly.Msg['CONTROLS_IF_TOOLTIP_1'];
Expand Down
1 change: 0 additions & 1 deletion blocks/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Blockly.Blocks['procedures_defnoreturn'] = {
* @this {Blockly.Block}
*/
updateParams_: function() {

// Merge the arguments into a human-readable list.
let paramString = '';
if (this.arguments_.length) {
Expand Down
5 changes: 3 additions & 2 deletions blocks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Blockly.defineBlocksWithJsonArray([
"width": 12,
"height": 17,
"alt": '\u00B6',
},{
},
{
"type": "field_multilinetext",
"name": "TEXT",
"text": "",
Expand Down Expand Up @@ -200,7 +201,7 @@ Blockly.defineBlocksWithJsonArray([
"message0": "%{BKY_TEXT_CHARAT_TITLE}", // "in text %1 %2"
"args0": [
{
"type":"input_value",
"type": "input_value",
"name": "VALUE",
"check": "String",
},
Expand Down
8 changes: 4 additions & 4 deletions blocks/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
*/
customContextMenu: function(options) {
if (!this.isInFlyout) {
let opposite_type;
let oppositeType;
let contextMenuMsg;
// Getter blocks have the option to create a setter block, and vice versa.
if (this.type === 'variables_get') {
opposite_type = 'variables_set';
oppositeType = 'variables_set';
contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET'];
} else {
opposite_type = 'variables_get';
oppositeType = 'variables_get';
contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET'];
}

Expand All @@ -100,7 +100,7 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
xmlField.setAttribute('name', 'VAR');
xmlField.appendChild(Blockly.utils.xml.createTextNode(name));
const xmlBlock = Blockly.utils.xml.createElement('block');
xmlBlock.setAttribute('type', opposite_type);
xmlBlock.setAttribute('type', oppositeType);
xmlBlock.appendChild(xmlField);
option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
options.push(option);
Expand Down
8 changes: 4 additions & 4 deletions blocks/variables_dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
customContextMenu: function(options) {
// Getter blocks have the option to create a setter block, and vice versa.
if (!this.isInFlyout) {
let opposite_type;
let oppositeType;
let contextMenuMsg;
const id = this.getFieldValue('VAR');
const variableModel = this.workspace.getVariableById(id);
const varType = variableModel.type;
if (this.type === 'variables_get_dynamic') {
opposite_type = 'variables_set_dynamic';
oppositeType = 'variables_set_dynamic';
contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET'];
} else {
opposite_type = 'variables_get_dynamic';
oppositeType = 'variables_get_dynamic';
contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET'];
}

Expand All @@ -101,7 +101,7 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
xmlField.setAttribute('variabletype', varType);
xmlField.appendChild(Blockly.utils.xml.createTextNode(name));
const xmlBlock = Blockly.utils.xml.createElement('block');
xmlBlock.setAttribute('type', opposite_type);
xmlBlock.setAttribute('type', oppositeType);
xmlBlock.appendChild(xmlField);
option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
options.push(option);
Expand Down
3 changes: 1 addition & 2 deletions core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ const Block = function(workspace, prototypeName, opt_id) {
if (eventUtils.isEnabled()) {
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(this));
}

} finally {
if (!existingGroup) {
eventUtils.setGroup(false);
Expand Down Expand Up @@ -1669,7 +1668,7 @@ Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
}
if (!opt_disableCheck) {
const overwrites = [];
for (let key in mixinObj) {
for (const key in mixinObj) {
if (this[key] !== undefined) {
overwrites.push(key);
}
Expand Down
7 changes: 3 additions & 4 deletions core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,9 @@ BlockSvg.prototype.setParent = function(newParent) {
const newXY = this.getRelativeToSurfaceXY();
// Move the connections to match the child's new position.
this.moveConnections(newXY.x - oldXY.x, newXY.y - oldXY.y);
}
// If we are losing a parent, we want to move our DOM element to the
// root of the workspace.
else if (oldParent) {
} else if (oldParent) {
// If we are losing a parent, we want to move our DOM element to the
// root of the workspace.
this.workspace.getCanvas().appendChild(svgRoot);
this.translate(oldXY.x, oldXY.y);
}
Expand Down
4 changes: 3 additions & 1 deletion core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ Connection.prototype.disconnect = function() {
if (otherConnection.targetConnection !== this) {
throw Error('Target connection not connected to source connection.');
}
let parentBlock, childBlock, parentConnection;
let parentBlock;
let childBlock;
let parentConnection;
if (this.isSuperior()) {
// Superior block.
parentBlock = this.sourceBlock_;
Expand Down
3 changes: 2 additions & 1 deletion core/connection_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ ConnectionChecker.prototype.doSafetyChecks = function(a, b) {
if (!a || !b) {
return Connection.REASON_TARGET_NULL;
}
let blockA, blockB;
let blockA;
let blockB;
if (a.isSuperior()) {
blockA = a.getSourceBlock();
blockB = b.getSourceBlock();
Expand Down
2 changes: 1 addition & 1 deletion core/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const inject = function(hasCss, pathToMedia) {
}
// Strip off any trailing slash (either Unix or Windows).
const mediaPath = pathToMedia.replace(/[\\/]$/, '');
let cssContent = content.replace(/<<<PATH>>>/g, mediaPath);
const cssContent = content.replace(/<<<PATH>>>/g, mediaPath);
// Cleanup the collected css content after injecting it to the DOM.
content = '';

Expand Down
5 changes: 2 additions & 3 deletions core/dropdowndiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,13 @@ const getPositionTopOfPageMetrics = function(sourceX, boundsInfo, divSize) {
*/
DropDownDiv.getPositionX = function(
sourceX, boundsLeft, boundsRight, divWidth) {
let arrowX, divX;
arrowX = divX = sourceX;

let divX = sourceX;
// Offset the topLeft coord so that the dropdowndiv is centered.
divX -= divWidth / 2;
// Fit the dropdowndiv within the bounds of the workspace.
divX = math.clamp(boundsLeft, divX, boundsRight - divWidth);

let arrowX = sourceX;
// Offset the arrow coord so that the arrow is centered.
arrowX -= DropDownDiv.ARROW_SIZE / 2;
// Convert the arrow position to be relative to the top left of the div.
Expand Down
2 changes: 1 addition & 1 deletion core/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ const buildTooltipForDropdown = function(dropdownName, lookupTable) {
// of document object, in which case skip the validation.
if (typeof document === 'object') { // Relies on document.readyState
utils.runAfterPageLoad(function() {
for (let key in lookupTable) {
for (const key in lookupTable) {
// Will print warnings if reference is missing.
utils.checkMessageReferences(lookupTable[key]);
}
Expand Down
4 changes: 3 additions & 1 deletion core/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,9 @@ Field.prototype.getSize = function() {
* @package
*/
Field.prototype.getScaledBBox = function() {
let scaledWidth, scaledHeight, xy;
let scaledWidth;
let scaledHeight;
let xy;
if (!this.borderRect_) {
// Browsers are inconsistent in what they return for a bounding box.
// - Webkit / Blink: fill-box / object bounding box
Expand Down
6 changes: 3 additions & 3 deletions core/field_multilineinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ FieldMultilineInput.prototype.render_ = function() {
const span = dom.createSvgElement(
Svg.TEXT, {
'class': 'blocklyText blocklyMultilineText',
x: this.getConstants().FIELD_BORDER_RECT_X_PADDING,
y: y + this.getConstants().FIELD_BORDER_RECT_Y_PADDING,
dy: this.getConstants().FIELD_TEXT_BASELINE,
'x': this.getConstants().FIELD_BORDER_RECT_X_PADDING,
'y': y + this.getConstants().FIELD_BORDER_RECT_Y_PADDING,
'dy': this.getConstants().FIELD_TEXT_BASELINE,
},
this.textGroup_);
span.appendChild(document.createTextNode(lines[i]));
Expand Down
5 changes: 2 additions & 3 deletions core/insertion_marker_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,9 @@ InsertionMarkerManager.prototype.hideInsertionMarker_ = function() {
// anything in that case. Instead, unplug the following block.
if (isFirstInStatementStack || isFirstInOutputStack) {
imConn.targetBlock().unplug(false);
}
// Inside of a C-block, first statement connection.
else if (
} else if (
imConn.type === ConnectionType.NEXT_STATEMENT && imConn !== markerNext) {
// Inside of a C-block, first statement connection.
const innerConnection = imConn.targetConnection;
innerConnection.getSourceBlock().unplug(false);

Expand Down
2 changes: 1 addition & 1 deletion core/interfaces/i_registrable_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const {Field} = goog.requireType('Blockly.Field');
* }}
* @alias Blockly.IRegistrableField
*/
let IRegistrableField = {};
const IRegistrableField = {};

/**
* @typedef {function(!Object): Field}
Expand Down
3 changes: 1 addition & 2 deletions core/keyboard_nav/ast_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,9 @@ ASTNode.prototype.getOutAstNodeForBlock_ = function(block) {
if (!block) {
return null;
}
let topBlock;
// If the block doesn't have a previous connection then it is the top of the
// substack.
topBlock = block.getTopStackBlock();
const topBlock = block.getTopStackBlock();
const topConnection =
topBlock.previousConnection || topBlock.outputConnection;
// If the top connection has a parentInput, create an AST node pointing to
Expand Down
3 changes: 2 additions & 1 deletion core/mutator.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ Mutator.prototype.setVisible = function(visible) {
// The root block should not be draggable or deletable.
this.rootBlock_.setMovable(false);
this.rootBlock_.setDeletable(false);
let margin, x;
let margin;
let x;
if (flyout) {
margin = flyout.CORNER_RADIUS * 2;
x = this.rootBlock_.RTL ? flyout.getWidth() + margin : margin;
Expand Down
7 changes: 7 additions & 0 deletions core/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ const flyoutCategory = function(workspace) {
xmlList[xmlList.length - 1].setAttribute('gap', 24);
}

/**
* Add items to xmlList for each listed procedure.
* @param {!Array<!Array>} procedureList A list of procedures, each of which
* is defined by a three-element list of name, parameter list, and return
* value boolean.
* @param {string} templateName The type of the block to generate.
*/
function populateProcedures(procedureList, templateName) {
for (let i = 0; i < procedureList.length; i++) {
const name = procedureList[i][0];
Expand Down
2 changes: 1 addition & 1 deletion core/rendered_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ RenderedConnection.prototype.highlight = function() {
Svg.PATH, {
'class': 'blocklyHighlightedConnectionPath',
'd': steps,
transform: 'translate(' + x + ',' + y + ')' +
'transform': 'translate(' + x + ',' + y + ')' +
(this.sourceBlock_.RTL ? ' scale(-1 1)' : ''),
},
this.sourceBlock_.getSvgRoot());
Expand Down
26 changes: 19 additions & 7 deletions core/renderers/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,16 @@ ConstantProvider.prototype.makePuzzleTab = function() {
const width = this.TAB_WIDTH;
const height = this.TAB_HEIGHT;

// The main path for the puzzle tab is made out of a few curves (c and s).
// Those curves are defined with relative positions. The 'up' and 'down'
// versions of the paths are the same, but the Y sign flips. Forward and back
// are the signs to use to move the cursor in the direction that the path is
// being drawn.
/**
* Make the main path for the puzzle tab made out of a few curves (c and s).
* Those curves are defined with relative positions. The 'up' and 'down'
* versions of the paths are the same, but the Y sign flips. Forward and back
* are the signs to use to move the cursor in the direction that the path is
* being drawn.
* @param {boolean} up True if the path should be drawn from bottom to top,
* false otherwise.
* @return {string} A path fragment describing a puzzle tab.
*/
function makeMainPath(up) {
const forward = up ? -1 : 1;
const back = -forward;
Expand Down Expand Up @@ -870,6 +875,13 @@ ConstantProvider.prototype.makeNotch = function() {
const height = this.NOTCH_HEIGHT;
const innerWidth = 3;
const outerWidth = (width - innerWidth) / 2;

/**
* Make the main path for the notch.
* @param {number} dir Direction multiplier to apply to horizontal offsets
* along the path. Either 1 or -1.
* @return {string} A path fragment describing a notch.
*/
function makeMainPath(dir) {
return svgPaths.line([
svgPaths.point(dir * outerWidth, height),
Expand Down Expand Up @@ -1087,8 +1099,8 @@ ConstantProvider.prototype.createDebugFilter = function() {
'id': 'blocklyDebugFilter' + this.randomIdentifier,
'height': '160%',
'width': '180%',
y: '-30%',
x: '-40%',
'y': '-30%',
'x': '-40%',
},
this.defs_);
// Set all gaussian blur pixels to 1 opacity before applying flood
Expand Down
4 changes: 2 additions & 2 deletions core/renderers/common/marker_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ MarkerSvg.prototype.showWithBlockPrevOutput_ = function(curNode) {
const markerOffset = this.constants_.CURSOR_BLOCK_PADDING;

if (block.previousConnection) {
let connectionShape = this.constants_.shapeFor(block.previousConnection);
const connectionShape = this.constants_.shapeFor(block.previousConnection);
this.positionPrevious_(width, markerOffset, markerHeight, connectionShape);
} else if (block.outputConnection) {
let connectionShape = this.constants_.shapeFor(block.outputConnection);
const connectionShape = this.constants_.shapeFor(block.outputConnection);
this.positionOutput_(width, height, connectionShape);
} else {
this.positionBlock_(width, markerOffset, markerHeight);
Expand Down
Loading

0 comments on commit f14a1c8

Please sign in to comment.