Skip to content

Commit

Permalink
fix various minor lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
towerofnix committed Dec 16, 2023
1 parent 02a091f commit 89ee610
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/BlockInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export interface SoundEffect extends Base {

export interface GoToTarget extends Base {
type: "goToTarget";
value: "_random_" | "_mouse_" | string;
value: string; // Specially handled: _mouse_, _random_
}

export interface PointTowardsTarget extends Base {
Expand Down Expand Up @@ -236,7 +236,7 @@ export interface CloneTarget extends Base {

export interface TouchingTarget extends Base {
type: "touchingTarget";
value: "_mouse_" | string;
value: string; // Specially handled: _mouse_
}

export interface DistanceToMenu extends Base {
Expand Down
14 changes: 7 additions & 7 deletions src/io/leopard/toLeopard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Project from "../../Project";
import Script from "../../Script";
import Block, { BlockBase } from "../../Block";
import Block from "../../Block";
import * as BlockInput from "../../BlockInput";
import { OpCode } from "../../OpCode";

Expand Down Expand Up @@ -398,15 +398,15 @@ export default function toLeopard(
desiredInputShape?: InputShape
): string {
// Short-circuit for string inputs. These must never return number syntax.
if (desiredInputShape === "string") {
if (desiredInputShape === InputShape.String) {
return JSON.stringify(value);
}

// Other input shapes which static inputs may fulfill: number, index, any.
// These are all OK to return JavaScript number literals for.
const asNum = Number(value as string);
if (!isNaN(asNum) && value !== "") {
if (desiredInputShape === "index") {
if (desiredInputShape === InputShape.Index) {
return JSON.stringify(asNum - 1);
} else {
return JSON.stringify(asNum);
Expand Down Expand Up @@ -1835,19 +1835,19 @@ export default function toLeopard(
return blockSource;
}

if (desiredInputShape === "boolean") {
if (desiredInputShape === InputShape.Boolean) {
return `(this.toBoolean(${blockSource}))`;
}

if (desiredInputShape === "string") {
if (desiredInputShape === InputShape.String) {
return `(this.toString(${blockSource}))`;
}

if (desiredInputShape === "number") {
if (desiredInputShape === InputShape.Number) {
return `(this.toNumber(${blockSource}))`;
}

if (desiredInputShape === "index") {
if (desiredInputShape === InputShape.Index) {
return `((${blockSource}) - 1)`;
}

Expand Down
4 changes: 2 additions & 2 deletions src/io/sb3/fromSb3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as BlockInput from "../../BlockInput";
import Costume from "../../Costume";
import Project from "../../Project";
import Sound from "../../Sound";
import Target, { Sprite, Stage, TargetOptions } from "../../Target";
import { Sprite, Stage, TargetOptions } from "../../Target";
import { List, Variable } from "../../Data";
import Script from "../../Script";

Expand Down Expand Up @@ -104,7 +104,7 @@ function getBlockScript(blocks: { [key: string]: sb3.Block }) {
// We basically just want to copy the important
// information from the shadow block down into
// the block containing the shadow.
if (block.opcode === "procedures_prototype") {
if (block.opcode === OpCode.procedures_prototype) {
const mutation = (block as sb3.Block<OpCode.procedures_prototype>).mutation;

// Split proccode (such as "letter %n of %s") into ["letter", "%n", "of", "%s"]
Expand Down

0 comments on commit 89ee610

Please sign in to comment.