mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-03 00:54:57 -04:00
Add .eslintrc rule to check JSDoc syntax
And fix the broken syntax rules
This commit is contained in:
parent
8081ec3a16
commit
1f1a4941f3
7 changed files with 17 additions and 11 deletions
|
@ -8,7 +8,8 @@
|
||||||
"max-len": [2, 80, 4],
|
"max-len": [2, 80, 4],
|
||||||
"semi": [2, "always"],
|
"semi": [2, "always"],
|
||||||
"strict": [2, "never"],
|
"strict": [2, "never"],
|
||||||
"no-console": [2, {"allow": ["log", "warn", "error"]}]
|
"no-console": [2, {"allow": ["log", "warn", "error"]}],
|
||||||
|
"valid-jsdoc": ["error", {"requireReturn": false}]
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
|
|
|
@ -41,9 +41,9 @@ WeDo2Blocks.prototype.getPrimitives = function() {
|
||||||
/**
|
/**
|
||||||
* Clamp a value between a minimum and maximum value.
|
* Clamp a value between a minimum and maximum value.
|
||||||
* @todo move this to a common utility class.
|
* @todo move this to a common utility class.
|
||||||
* @param val The value to clamp.
|
* @param {number} val The value to clamp.
|
||||||
* @param min The minimum return value.
|
* @param {number} min The minimum return value.
|
||||||
* @param max The maximum return value.
|
* @param {number} max The maximum return value.
|
||||||
* @returns {number} The clamped value.
|
* @returns {number} The clamped value.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -53,9 +53,9 @@ WeDo2Blocks.prototype._clamp = function(val, min, max) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common implementation for motor blocks.
|
* Common implementation for motor blocks.
|
||||||
* @param direction The direction to turn ('left' or 'right').
|
* @param {string} direction The direction to turn ('left' or 'right').
|
||||||
* @param durationSeconds The number of seconds to run.
|
* @param {number} durationSeconds The number of seconds to run.
|
||||||
* @param util The util instance to use for yielding and finishing.
|
* @param {Object} util The util instance to use for yielding and finishing.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
WeDo2Blocks.prototype._motorOnFor = function(direction, durationSeconds, util) {
|
WeDo2Blocks.prototype._motorOnFor = function(direction, durationSeconds, util) {
|
||||||
|
@ -108,7 +108,7 @@ WeDo2Blocks.prototype.motorSpeed = function(argValues) {
|
||||||
/**
|
/**
|
||||||
* Convert a color name to a WeDo color index.
|
* Convert a color name to a WeDo color index.
|
||||||
* Supports 'mystery' for a random hue.
|
* Supports 'mystery' for a random hue.
|
||||||
* @param colorName The color to retrieve.
|
* @param {string} colorName The color to retrieve.
|
||||||
* @returns {number} The WeDo color index.
|
* @returns {number} The WeDo color index.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -52,8 +52,8 @@ function domToBlocks (blocksDOM) {
|
||||||
* Convert and an individual block DOM to the representation tree.
|
* Convert and an individual block DOM to the representation tree.
|
||||||
* Based on Blockly's `domToBlockHeadless_`.
|
* Based on Blockly's `domToBlockHeadless_`.
|
||||||
* @param {Element} blockDOM DOM tree for an individual block.
|
* @param {Element} blockDOM DOM tree for an individual block.
|
||||||
* @param {Boolean} isTopBlock Whether blocks at this level are "top blocks."
|
|
||||||
* @param {Object} blocks Collection of blocks to add to.
|
* @param {Object} blocks Collection of blocks to add to.
|
||||||
|
* @param {Boolean} isTopBlock Whether blocks at this level are "top blocks."
|
||||||
*/
|
*/
|
||||||
function domToBlock (blockDOM, blocks, isTopBlock) {
|
function domToBlock (blockDOM, blocks, isTopBlock) {
|
||||||
// Block skeleton.
|
// Block skeleton.
|
||||||
|
|
|
@ -83,6 +83,7 @@ Blocks.prototype.getOpcode = function (id) {
|
||||||
/**
|
/**
|
||||||
* Block management: create blocks and stacks from a `create` event
|
* Block management: create blocks and stacks from a `create` event
|
||||||
* @param {!Object} block Blockly create event to be processed
|
* @param {!Object} block Blockly create event to be processed
|
||||||
|
* @param {boolean} opt_isFlyoutBlock Whether the block is in the flyout.
|
||||||
*/
|
*/
|
||||||
Blocks.prototype.createBlock = function (block, opt_isFlyoutBlock) {
|
Blocks.prototype.createBlock = function (block, opt_isFlyoutBlock) {
|
||||||
// Create new block
|
// Create new block
|
||||||
|
|
|
@ -10,7 +10,7 @@ var defaultBlockPackages = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages blocks, stacks, and the sequencer.
|
* Manages blocks, stacks, and the sequencer.
|
||||||
* @param blocks Blocks instance for this runtime.
|
* @param {!Blocks} blocks Blocks instance for this runtime.
|
||||||
*/
|
*/
|
||||||
function Runtime (blocks) {
|
function Runtime (blocks) {
|
||||||
// Bind event emitter
|
// Bind event emitter
|
||||||
|
|
|
@ -26,6 +26,7 @@ Sequencer.WORK_TIME = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Step through all threads in `this.threads`, running them in order.
|
* Step through all threads in `this.threads`, running them in order.
|
||||||
|
* @param {Array.<Thread>} threads List of which threads to step.
|
||||||
* @return {Array.<Thread>} All threads which have finished in this iteration.
|
* @return {Array.<Thread>} All threads which have finished in this iteration.
|
||||||
*/
|
*/
|
||||||
Sequencer.prototype.stepThreads = function (threads) {
|
Sequencer.prototype.stepThreads = function (threads) {
|
||||||
|
@ -139,6 +140,9 @@ Sequencer.prototype.stepThread = function (thread) {
|
||||||
/**
|
/**
|
||||||
* A callback for the primitive to start hats.
|
* A callback for the primitive to start hats.
|
||||||
* @todo very hacked...
|
* @todo very hacked...
|
||||||
|
* Provide a callback that is passed in a block and returns true
|
||||||
|
* if it is a hat that should be triggered.
|
||||||
|
* @param {Function} callback Provided callback.
|
||||||
*/
|
*/
|
||||||
var startHats = function(callback) {
|
var startHats = function(callback) {
|
||||||
var stacks = instance.runtime.blocks.getStacks();
|
var stacks = instance.runtime.blocks.getStacks();
|
||||||
|
|
|
@ -23,7 +23,7 @@ function VirtualMachine () {
|
||||||
* Event listener for blocks. Handles validation and serves as a generic
|
* Event listener for blocks. Handles validation and serves as a generic
|
||||||
* adapter between the blocks and the runtime interface.
|
* adapter between the blocks and the runtime interface.
|
||||||
*
|
*
|
||||||
* @param {Object} Blockly "block" event
|
* @param {Object} e Blockly "block" event
|
||||||
*/
|
*/
|
||||||
instance.blockListener = function (e) {
|
instance.blockListener = function (e) {
|
||||||
// Validate event
|
// Validate event
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue