From 43721f493121fa4e143df87a0ae289139d3eb994 Mon Sep 17 00:00:00 2001 From: mrredo Date: Thu, 30 May 2024 12:15:22 +0300 Subject: [PATCH] less eslint errors --- src/lib/blocks/Test Blocks/variables.ts | 10 ++++------ src/lib/types/CategoryDefinition.ts | 1 + src/lib/utils/ToolboxGen/CallBacks.ts | 19 ------------------- src/lib/utils/ToolboxGen/Toolbox.ts | 6 +++--- 4 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 src/lib/utils/ToolboxGen/CallBacks.ts diff --git a/src/lib/blocks/Test Blocks/variables.ts b/src/lib/blocks/Test Blocks/variables.ts index f1284bd..daf9ccd 100644 --- a/src/lib/blocks/Test Blocks/variables.ts +++ b/src/lib/blocks/Test Blocks/variables.ts @@ -6,9 +6,7 @@ import { BlockShape, BlockType, DropdownType } from "$lib/enums/BlockTypes"; import DropdownInput from "$lib/utils/BlockGen/Inputs/Dropdown"; import ValueInput from "$lib/utils/BlockGen/Inputs/ValueInput"; import VariableInput from "$lib/utils/BlockGen/Inputs/VariableInput"; -// import { xml } from "blockly/core/utils"; -// import BaseInput from "$lib/utils/BlockGen/Inputs/BaseInput"; -// let variableBlockDef: BaseInput = new BaseInput() + function fixVariableName(variable: string): string { // Remove non-alphabetic characters from the start and end let fixedVariable = variable.replace(/^[^a-zA-Z]+|[^a-zA-Z0-9]+$/g, ''); @@ -35,7 +33,7 @@ const blocks: BlockDefinition[] = [ args: [ new VariableInput("VAR", "") ], - code(args, block) { + code(args) { const varName = fixVariableName(args.VAR as string) console.log(varName, args.VAR) @@ -56,7 +54,7 @@ const blocks: BlockDefinition[] = [ new VariableInput("VAR", ""), new ValueInput("INPUT", BlockType.Any) ], - code(args, block) { + code(args) { const varName = fixVariableName(args.VAR as string) return `${varName}${args.INPUT !== ""? " =" : ";"} ${args.INPUT !== ""? args.INPUT+";": ""}\n` @@ -83,7 +81,7 @@ const blocks: BlockDefinition[] = [ new ValueInput("INPUT", BlockType.Any) ], - code(args, block) { + code(args) { const varName = fixVariableName(args.VAR as string) console.log(varName) return `${varName}${args.INPUT !== ""? " "+ args.DROPDOWN + "=" : ";"} ${args.INPUT !== ""? args.INPUT+";": ""}\n` diff --git a/src/lib/types/CategoryDefinition.ts b/src/lib/types/CategoryDefinition.ts index e77d22b..e0c2e93 100644 --- a/src/lib/types/CategoryDefinition.ts +++ b/src/lib/types/CategoryDefinition.ts @@ -5,5 +5,6 @@ export type CategoryDefinition = { hidden?: boolean; weight?: number; custom?: string; // add if you want to make dynamic categories + // eslint-disable-next-line no-use-before-define customFunction?: (workspace: Blockly.WorkspaceSvg) => any[]; // used in pair with custom }; diff --git a/src/lib/utils/ToolboxGen/CallBacks.ts b/src/lib/utils/ToolboxGen/CallBacks.ts deleted file mode 100644 index 86bdd44..0000000 --- a/src/lib/utils/ToolboxGen/CallBacks.ts +++ /dev/null @@ -1,19 +0,0 @@ -import Blockly from "blockly/core"; -import toolbox from "blockly/core/utils/toolbox"; - - - -class CallBacks { - private categoryCallBacks: Record toolbox.FlyoutDefinition>; - private buttonCallbacks: Record toolbox.FlyoutDefinition>; - - constructor() { - this.categoryCallBacks = {}; - this.buttonCallbacks = {}; - }; - addCategoryCallback(name: string, func:(p1: Blockly.WorkspaceSvg) => toolbox.FlyoutDefinition) {} - register(workspace: Blockly.WorkspaceSvg) { - workspace.reg - } - -} diff --git a/src/lib/utils/ToolboxGen/Toolbox.ts b/src/lib/utils/ToolboxGen/Toolbox.ts index 028d496..13df6cb 100644 --- a/src/lib/utils/ToolboxGen/Toolbox.ts +++ b/src/lib/utils/ToolboxGen/Toolbox.ts @@ -1,11 +1,11 @@ import type { BlockDefinition } from "$lib/types/BlockDefinition"; import type { ToolboxDefinition, ToolboxItemInfo } from "blockly/core/utils/toolbox"; -import type {FlyoutButton} from "blockly"; import Blockly from "blockly/core"; export default class Toolbox { - private callbackCategory: Record; - private callbackOther: Record; + // eslint-disable-next-line no-use-before-define + private callbackCategory: Record any[]>; + private callbackOther: Record void>; constructor() { this.callbackCategory = {};