style: fix hasOwnProperty lint complaints

This commit is contained in:
Christopher Willis-Ford 2023-12-15 17:25:23 -08:00
parent b1cc55e680
commit 8dbcc1fc8f
29 changed files with 207 additions and 180 deletions

View file

@ -142,11 +142,11 @@ const testReporter = function (t, reporter) {
t.equal(reporter.json.checkboxInFlyout, true);
t.equal(reporter.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_ROUND);
t.equal(reporter.json.output, 'String');
t.notOk(reporter.json.hasOwnProperty('previousStatement'));
t.notOk(reporter.json.hasOwnProperty('nextStatement'));
t.notOk(Object.prototype.hasOwnProperty.call(reporter.json, 'previousStatement'));
t.notOk(Object.prototype.hasOwnProperty.call(reporter.json, 'nextStatement'));
t.same(reporter.json.extensions, ['scratch_extension']);
t.equal(reporter.json.message0, '%1 %2simple text'); // "%1 %2" from the block icon
t.notOk(reporter.json.hasOwnProperty('message1'));
t.notOk(Object.prototype.hasOwnProperty.call(reporter.json, 'message1'));
t.same(reporter.json.args0, [
// %1 in message0: the block icon
{
@ -160,7 +160,7 @@ const testReporter = function (t, reporter) {
type: 'field_vertical_separator'
}
]);
t.notOk(reporter.json.hasOwnProperty('args1'));
t.notOk(Object.prototype.hasOwnProperty.call(reporter.json, 'args1'));
t.equal(reporter.xml, '<block type="test_reporter"></block>');
};
@ -170,11 +170,11 @@ const testInlineImage = function (t, inlineImage) {
t.equal(inlineImage.json.checkboxInFlyout, true);
t.equal(inlineImage.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_ROUND);
t.equal(inlineImage.json.output, 'String');
t.notOk(inlineImage.json.hasOwnProperty('previousStatement'));
t.notOk(inlineImage.json.hasOwnProperty('nextStatement'));
t.notOk(Object.prototype.hasOwnProperty.call(inlineImage.json, 'previousStatement'));
t.notOk(Object.prototype.hasOwnProperty.call(inlineImage.json, 'nextStatement'));
t.notOk(inlineImage.json.extensions && inlineImage.json.extensions.length); // OK if it's absent or empty
t.equal(inlineImage.json.message0, 'text and %1'); // block text followed by inline image
t.notOk(inlineImage.json.hasOwnProperty('message1'));
t.notOk(Object.prototype.hasOwnProperty.call(inlineImage.json, 'message1'));
t.same(inlineImage.json.args0, [
// %1 in message0: the block icon
{
@ -185,7 +185,7 @@ const testInlineImage = function (t, inlineImage) {
flip_rtl: false // False by default
}
]);
t.notOk(inlineImage.json.hasOwnProperty('args1'));
t.notOk(Object.prototype.hasOwnProperty.call(inlineImage.json, 'args1'));
t.equal(inlineImage.xml, '<block type="test_inlineImage"></block>');
};
@ -198,16 +198,16 @@ const testCommand = function (t, command) {
t.equal(command.json.type, 'test_command');
testCategoryInfo(t, command);
t.equal(command.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE);
t.assert(command.json.hasOwnProperty('previousStatement'));
t.assert(command.json.hasOwnProperty('nextStatement'));
t.assert(Object.prototype.hasOwnProperty.call(command.json, 'previousStatement'));
t.assert(Object.prototype.hasOwnProperty.call(command.json, 'nextStatement'));
t.notOk(command.json.extensions && command.json.extensions.length); // OK if it's absent or empty
t.equal(command.json.message0, 'text with %1 %2');
t.notOk(command.json.hasOwnProperty('message1'));
t.notOk(Object.prototype.hasOwnProperty.call(command.json, 'message1'));
t.strictSame(command.json.args0[0], {
type: 'input_value',
name: 'ARG'
});
t.notOk(command.json.hasOwnProperty('args1'));
t.notOk(Object.prototype.hasOwnProperty.call(command.json, 'args1'));
t.equal(command.xml,
'<block type="test_command"><value name="ARG"><shadow type="text"></shadow></value>' +
'<value name="ARG_WITH_DEFAULT"><shadow type="text"><field name="TEXT">' +
@ -218,14 +218,14 @@ const testConditional = function (t, conditional) {
t.equal(conditional.json.type, 'test_ifElse');
testCategoryInfo(t, conditional);
t.equal(conditional.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE);
t.ok(conditional.json.hasOwnProperty('previousStatement'));
t.ok(conditional.json.hasOwnProperty('nextStatement'));
t.ok(Object.prototype.hasOwnProperty.call(conditional.json, 'previousStatement'));
t.ok(Object.prototype.hasOwnProperty.call(conditional.json, 'nextStatement'));
t.notOk(conditional.json.extensions && conditional.json.extensions.length); // OK if it's absent or empty
t.equal(conditional.json.message0, 'test if %1 is spiffy and if so then');
t.equal(conditional.json.message1, '%1'); // placeholder for substack #1
t.equal(conditional.json.message2, 'or elsewise');
t.equal(conditional.json.message3, '%1'); // placeholder for substack #2
t.notOk(conditional.json.hasOwnProperty('message4'));
t.notOk(Object.prototype.hasOwnProperty.call(conditional.json, 'message4'));
t.strictSame(conditional.json.args0[0], {
type: 'input_value',
name: 'THING',
@ -235,12 +235,12 @@ const testConditional = function (t, conditional) {
type: 'input_statement',
name: 'SUBSTACK'
});
t.notOk(conditional.json.hasOwnProperty(conditional.json.args2));
t.notOk(Object.prototype.hasOwnProperty.call(conditional.json, conditional.json.args2));
t.strictSame(conditional.json.args3[0], {
type: 'input_statement',
name: 'SUBSTACK2'
});
t.notOk(conditional.json.hasOwnProperty('args4'));
t.notOk(Object.prototype.hasOwnProperty.call(conditional.json, 'args4'));
t.equal(conditional.xml, '<block type="test_ifElse"><value name="THING"></value></block>');
};
@ -248,13 +248,13 @@ const testLoop = function (t, loop) {
t.equal(loop.json.type, 'test_loop');
testCategoryInfo(t, loop);
t.equal(loop.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE);
t.ok(loop.json.hasOwnProperty('previousStatement'));
t.notOk(loop.json.hasOwnProperty('nextStatement')); // isTerminal is set on this block
t.ok(Object.prototype.hasOwnProperty.call(loop.json, 'previousStatement'));
t.notOk(Object.prototype.hasOwnProperty.call(loop.json, 'nextStatement')); // isTerminal is set on this block
t.notOk(loop.json.extensions && loop.json.extensions.length); // OK if it's absent or empty
t.equal(loop.json.message0, 'loopty %1 loops');
t.equal(loop.json.message1, '%1'); // placeholder for substack
t.equal(loop.json.message2, '%1'); // placeholder for loop arrow
t.notOk(loop.json.hasOwnProperty('message3'));
t.notOk(Object.prototype.hasOwnProperty.call(loop.json, 'message3'));
t.strictSame(loop.json.args0[0], {
type: 'input_value',
name: 'MANY'
@ -266,7 +266,7 @@ const testLoop = function (t, loop) {
t.equal(loop.json.lastDummyAlign2, 'RIGHT'); // move loop arrow to right side
t.equal(loop.json.args2[0].type, 'field_image');
t.equal(loop.json.args2[0].flip_rtl, true);
t.notOk(loop.json.hasOwnProperty('args3'));
t.notOk(Object.prototype.hasOwnProperty.call(loop.json, 'args3'));
t.equal(loop.xml,
'<block type="test_loop"><value name="MANY"><shadow type="math_number"></shadow></value></block>');
};