chore: fix or ignore remaining lint (#5709)

* chore: fix or ignore remaining lint

* chore: fix bad annotations

* chore: use push for array concatenation

* chore: revert use of spread for array operations
This commit is contained in:
Rachel Fenichel
2021-11-17 08:39:00 -08:00
committed by GitHub
parent 335ff199d7
commit 5deed5a194
17 changed files with 164 additions and 73 deletions

View File

@@ -334,10 +334,16 @@ Blockly.Blocks['lists_getIndex'] = {
];
this.setHelpUrl(Blockly.Msg['LISTS_GET_INDEX_HELPURL']);
this.setStyle('list_blocks');
const modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
const isStatement = (value === 'REMOVE');
this.getSourceBlock().updateStatement_(isStatement);
});
const modeMenu = new Blockly.FieldDropdown(MODE,
/**
* @param {*} value The input value.
* @this {Blockly.FieldDropdown}
*/
function(value) {
const isStatement = (value === 'REMOVE');
this.getSourceBlock().updateStatement_(isStatement);
}
);
this.appendValueInput('VALUE')
.setCheck('Array')
.appendField(Blockly.Msg['LISTS_GET_INDEX_INPUT_IN_LIST']);
@@ -484,18 +490,28 @@ Blockly.Blocks['lists_getIndex'] = {
} else {
this.appendDummyInput('AT');
}
const menu = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a closure.
if (newAt !== isAt) {
const block = this.getSourceBlock();
block.updateAt_(newAt);
// This menu has been destroyed and replaced. Update the replacement.
block.setFieldValue(value, 'WHERE');
return null;
}
return undefined;
});
const menu = new Blockly.FieldDropdown(
this.WHERE_OPTIONS,
/**
* @param {*} value The input value.
* @this {Blockly.FieldDropdown}
* @returns {null|undefined} Null if the field has been replaced;
* otherwise undefined.
*/
function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a
// closure.
if (newAt !== isAt) {
const block = this.getSourceBlock();
block.updateAt_(newAt);
// This menu has been destroyed and replaced. Update the
// replacement.
block.setFieldValue(value, 'WHERE');
return null;
}
return undefined;
});
this.getInput('AT').appendField(menu, 'WHERE');
if (Blockly.Msg['LISTS_GET_INDEX_TAIL']) {
this.moveInputBefore('TAIL', null);
@@ -628,18 +644,28 @@ Blockly.Blocks['lists_setIndex'] = {
} else {
this.appendDummyInput('AT');
}
const menu = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a closure.
if (newAt !== isAt) {
const block = this.getSourceBlock();
block.updateAt_(newAt);
// This menu has been destroyed and replaced. Update the replacement.
block.setFieldValue(value, 'WHERE');
return null;
}
return undefined;
});
const menu = new Blockly.FieldDropdown(
this.WHERE_OPTIONS,
/**
* @param {*} value The input value.
* @this {Blockly.FieldDropdown}
* @returns {null|undefined} Null if the field has been replaced;
* otherwise undefined.
*/
function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a
// closure.
if (newAt !== isAt) {
const block = this.getSourceBlock();
block.updateAt_(newAt);
// This menu has been destroyed and replaced. Update the
// replacement.
block.setFieldValue(value, 'WHERE');
return null;
}
return undefined;
});
this.moveInputBefore('AT', 'TO');
if (this.getInput('ORDINAL')) {
this.moveInputBefore('ORDINAL', 'TO');
@@ -737,7 +763,14 @@ Blockly.Blocks['lists_getSublist'] = {
} else {
this.appendDummyInput('AT' + n);
}
const menu = new Blockly.FieldDropdown(this['WHERE_OPTIONS_' + n],
const menu = new Blockly.FieldDropdown(
this['WHERE_OPTIONS_' + n],
/**
* @param {*} value The input value.
* @this {Blockly.FieldDropdown}
* @returns {null|undefined} Null if the field has been replaced;
* otherwise undefined.
*/
function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a

View File

@@ -493,10 +493,16 @@ Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
* @package
*/
Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION = function() {
this.getField('PROPERTY').setValidator(function(option) {
const divisorInput = (option === 'DIVISIBLE_BY');
this.getSourceBlock().updateShape_(divisorInput);
});
this.getField('PROPERTY').setValidator(
/**
* @this {Blockly.FieldDropdown}
* @param {*} option The selected dropdown option.
*/
function(option) {
const divisorInput = (option === 'DIVISIBLE_BY');
this.getSourceBlock().updateShape_(divisorInput);
}
);
};
Blockly.Extensions.registerMutator('math_is_divisibleby_mutator',

View File

@@ -537,6 +537,9 @@ Blockly.Blocks['procedures_mutatorarg'] = {
// Hack: override showEditor to do just a little bit more work.
// We don't have a good place to hook into the start of a text edit.
field.oldShowEditorFn_ = field.showEditor_;
/**
* @this {Blockly.FieldTextInput}
*/
const newShowEditorFn = function() {
this.createdVariables_ = [];
this.oldShowEditorFn_();

View File

@@ -319,7 +319,14 @@ Blockly.Blocks['text_getSubstring'] = {
this.appendDummyInput('TAIL')
.appendField(Blockly.Msg['TEXT_GET_SUBSTRING_TAIL']);
}
const menu = new Blockly.FieldDropdown(this['WHERE_OPTIONS_' + n],
const menu = new Blockly.FieldDropdown(
this['WHERE_OPTIONS_' + n],
/**
* @param {*} value The input value.
* @this {Blockly.FieldDropdown}
* @returns {null|undefined} Null if the field has been replaced;
* otherwise undefined.
*/
function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a
@@ -922,13 +929,18 @@ Blockly.Constants.Text.TEXT_CHARAT_MUTATOR_MIXIN = {
*/
Blockly.Constants.Text.TEXT_CHARAT_EXTENSION = function() {
const dropdown = this.getField('WHERE');
dropdown.setValidator(function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
if (newAt !== this.isAt_) {
const block = this.getSourceBlock();
block.updateAt_(newAt);
}
});
dropdown.setValidator(
/**
* @param {*} value The input value.
* @this {Blockly.FieldDropdown}
*/
function(value) {
const newAt = (value === 'FROM_START') || (value === 'FROM_END');
if (newAt !== this.isAt_) {
const block = this.getSourceBlock();
block.updateAt_(newAt);
}
});
this.updateAt_(true);
// Assign 'this' to a variable for use in the tooltip closure below.
const thisBlock = this;