chore: Fix inadvertent block migration inconsistencies (#5780)

* chore: Fix inadvertent block migration inconsistencies

  - Reinstate `goog.require`s-for-side-effects that were inadvertently
    removed.
  - Always use a destructuring import for `defineBlocksWithJsonArray`.
  - Consistently use `CONSTANT_CASE` names for block-common objects.
    (We could alternatively always use `camelCase` names, but since
    all the `MIXIN`s and `EXTENSIONS` remain all-uppercase this seems
    the more consistent.)

* chore: Fix import ordering
This commit is contained in:
Christopher Allen
2021-12-03 02:45:47 +00:00
committed by GitHub
parent b08187cd0a
commit b52c0179cb
6 changed files with 18 additions and 14 deletions

View File

@@ -12,6 +12,8 @@
goog.module('Blockly.blocks.colour');
const {defineBlocksWithJsonArray} = goog.require('Blockly.common');
/** @suppress {extraRequire} */
goog.require('Blockly.FieldColour');
defineBlocksWithJsonArray([

View File

@@ -24,6 +24,8 @@ const {Mutator} = goog.require('Blockly.Mutator');
/* eslint-disable-next-line no-unused-vars */
const {Workspace} = goog.requireType('Blockly.Workspace');
const {defineBlocksWithJsonArray} = goog.require('Blockly.common');
/** @suppress {extraRequire} */
goog.require('Blockly.FieldDropdown');
defineBlocksWithJsonArray([

View File

@@ -16,7 +16,6 @@ goog.module('Blockly.blocks.logic');
const AbstractEvent = goog.requireType('Blockly.Events.Abstract');
const Events = goog.require('Blockly.Events');
const Extensions = goog.require('Blockly.Extensions');
const common = goog.require('Blockly.common');
const xmlUtils = goog.require('Blockly.utils.xml');
/* eslint-disable-next-line no-unused-vars */
const {Block} = goog.requireType('Blockly.Block');
@@ -26,13 +25,14 @@ const {Mutator} = goog.require('Blockly.Mutator');
const {RenderedConnection} = goog.requireType('Blockly.RenderedConnection');
/* eslint-disable-next-line no-unused-vars */
const {Workspace} = goog.requireType('Blockly.Workspace');
const {defineBlocksWithJsonArray} = goog.require('Blockly.common');
/** @suppress {extraRequire} */
goog.require('Blockly.FieldDropdown');
/** @suppress {extraRequire} */
goog.require('Blockly.FieldLabel');
common.defineBlocksWithJsonArray([
defineBlocksWithJsonArray([
// Block for boolean data type: true and false.
{
'type': 'logic_boolean',

View File

@@ -13,13 +13,13 @@
goog.module('Blockly.blocks.math');
const Extensions = goog.require('Blockly.Extensions');
/* eslint-disable-next-line no-unused-vars */
const xmlUtils = goog.require('Blockly.utils.xml');
/* eslint-disable-next-line no-unused-vars */
const {Block} = goog.requireType('Blockly.Block');
// N.B.: Blockly.FieldDropdown needed for type AND side-effects.
/* eslint-disable-next-line no-unused-vars */
const FieldDropdown = goog.require('Blockly.FieldDropdown');
const xmlUtils = goog.require('Blockly.utils.xml');
/* eslint-disable-next-line no-unused-vars */
const {Block} = goog.requireType('Blockly.Block');
/* eslint-disable-next-line no-unused-vars */
const {defineBlocksWithJsonArray} = goog.require('Blockly.common');
/** @suppress {extraRequire} */
goog.require('Blockly.FieldLabel');

View File

@@ -46,7 +46,7 @@ goog.require('Blockly.Warning');
* Common properties for the procedure_defnoreturn and
* procedure_defreturn blocks.
*/
const procedureDef = {
const PROCEDURE_DEF_COMMON = {
/**
* Add or remove the statement block from this function definition.
* @param {boolean} hasStatements True if a statement block is needed.
@@ -438,7 +438,7 @@ const procedureDef = {
};
Blocks['procedures_defnoreturn'] = {
...procedureDef,
...PROCEDURE_DEF_COMMON,
/**
* Block for defining a procedure with no return value.
* @this {Block}
@@ -480,7 +480,7 @@ Blocks['procedures_defnoreturn'] = {
};
Blocks['procedures_defreturn'] = {
...procedureDef,
...PROCEDURE_DEF_COMMON,
/**
* Block for defining a procedure with a return value.
* @this {Block}
@@ -659,7 +659,7 @@ Blocks['procedures_mutatorarg'] = {
* Common properties for the procedure_callnoreturn and
* procedure_callreturn blocks.
*/
const procedureCall = {
const PROCEDURE_CALL_COMMON = {
/**
* Returns the name of the procedure this block calls.
* @return {string} Procedure name.
@@ -1034,7 +1034,7 @@ const procedureCall = {
};
Blocks['procedures_callnoreturn'] = {
...procedureCall,
...PROCEDURE_CALL_COMMON,
/**
* Block for calling a procedure with no return value.
* @this {Block}
@@ -1057,7 +1057,7 @@ Blocks['procedures_callnoreturn'] = {
};
Blocks['procedures_callreturn'] = {
...procedureCall,
...PROCEDURE_CALL_COMMON,
/**
* Block for calling a procedure with a return value.
* @this {Block}

View File

@@ -1,6 +1,6 @@
goog.addDependency('../../blocks/all.js', ['Blockly.blocks.all'], ['Blockly.blocks.colour', 'Blockly.blocks.lists', 'Blockly.blocks.logic', 'Blockly.blocks.loops', 'Blockly.blocks.math', 'Blockly.blocks.procedures', 'Blockly.blocks.texts', 'Blockly.blocks.variables', 'Blockly.blocks.variablesDynamic'], {'module': 'goog'});
goog.addDependency('../../blocks/colour.js', ['Blockly.blocks.colour'], ['Blockly.common'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../blocks/lists.js', ['Blockly.blocks.lists'], ['Blockly.ConnectionType', 'Blockly.FieldDropdown', 'Blockly.Input', 'Blockly.Msg', 'Blockly.Mutator', 'Blockly.blocks', 'Blockly.common', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../blocks/colour.js', ['Blockly.blocks.colour'], ['Blockly.FieldColour', 'Blockly.common'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../blocks/lists.js', ['Blockly.blocks.lists'], ['Blockly.ConnectionType', 'Blockly.FieldDropdown', 'Blockly.FieldDropdown', 'Blockly.Input', 'Blockly.Msg', 'Blockly.Mutator', 'Blockly.blocks', 'Blockly.common', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../blocks/logic.js', ['Blockly.blocks.logic'], ['Blockly.Events', 'Blockly.Extensions', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Msg', 'Blockly.Mutator', 'Blockly.common', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../blocks/loops.js', ['Blockly.blocks.loops'], ['Blockly.ContextMenu', 'Blockly.Events', 'Blockly.Extensions', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.Msg', 'Blockly.Variables', 'Blockly.Warning', 'Blockly.common', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../blocks/math.js', ['Blockly.blocks.math'], ['Blockly.Extensions', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.common', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});