diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..bec109f --- /dev/null +++ b/biome.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.6.2/schema.json", + "organizeImports": { + "enabled": true + }, + "formatter": { + "indentStyle": "tab", + "indentWidth": 4 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "off", + "noShadowRestrictedNames": "off" + }, + "complexity": { + "useLiteralKeys": "off" + } + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 5e52b22..7886196 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,12 @@ "test": "vitest", "coverage": "vitest run --coverage" }, - "workspaces": [ - "packages/*" - ], + "workspaces": ["packages/*"], "devDependencies": { + "@biomejs/biome": "1.6.2", "@vitest/coverage-v8": "^0.34.2", "ts-node": "^10.9.1", "typescript": "^5.1.6", "vitest": "^0.34.2" } -} \ No newline at end of file +} diff --git a/packages/ramattra-cli/src/index.ts b/packages/ramattra-cli/src/index.ts index 7ffd287..d2212e5 100644 --- a/packages/ramattra-cli/src/index.ts +++ b/packages/ramattra-cli/src/index.ts @@ -2,7 +2,7 @@ import { Command } from "commander"; import { assemble, parse } from "@ramattra/ramattra-core"; import * as fs from "node:fs/promises"; -import { Error } from "@ramattra/ramattra-core/src/compiler/parser"; +import type { Error } from "@ramattra/ramattra-core/src/compiler/parser"; const program = new Command(); diff --git a/packages/ramattra-core/src/compiler/std.ts b/packages/ramattra-core/src/compiler/std.ts index 6f2cb29..5cbd025 100644 --- a/packages/ramattra-core/src/compiler/std.ts +++ b/packages/ramattra-core/src/compiler/std.ts @@ -147,7 +147,7 @@ export const CONSTANTS: Record = { "ROUND_DOWN": { ow: "Down", type: native("rounding") }, }; -export const FUNCTIONS: Record = { +export const FUNCTIONS: Record = { "disableGameModeHUD": { ow: "Disable Game Mode HUD", args: [{ type: native("player") }] }, "createHUDText": { diff --git a/packages/ramattra-language-server/src/server.ts b/packages/ramattra-language-server/src/server.ts index 45d7ea1..53f7104 100644 --- a/packages/ramattra-language-server/src/server.ts +++ b/packages/ramattra-language-server/src/server.ts @@ -1,11 +1,11 @@ import { FUNCTIONS, analyze, type Error, CONSTANTS, EVENTS, reprType } from "@ramattra/ramattra-core"; import { dedent } from "@ramattra/ramattra-util"; -import { CompletionItemKind, Connection, Diagnostic, DiagnosticSeverity, TextDocuments, TextDocumentSyncKind } from "vscode-languageserver"; +import { CompletionItemKind, type Connection, type Diagnostic, DiagnosticSeverity, TextDocuments, TextDocumentSyncKind } from "vscode-languageserver"; import { TextDocument } from "vscode-languageserver-textdocument"; export const onInit = (connection: Connection) => { connection.onInitialize(_params => { - connection.console.log(`[Server] Started and initialize received`); + connection.console.log("[Server] Started and initialize received"); return { capabilities: { @@ -83,7 +83,7 @@ export const onInit = (connection: Connection) => { const word = text.slice(start, end); if (FUNCTIONS[word]) { - const fn = FUNCTIONS[word]!; + const fn = FUNCTIONS[word]; return { contents: { @@ -96,7 +96,9 @@ export const onInit = (connection: Connection) => { ` }, } - } else if (CONSTANTS[word]) { + } + + if (CONSTANTS[word]) { const constant = CONSTANTS[word]; return { contents: { @@ -108,7 +110,9 @@ export const onInit = (connection: Connection) => { ` }, } - } else if (EVENTS[word]) { + } + + if (EVENTS[word]) { const event = EVENTS[word]; return { contents: { @@ -159,8 +163,8 @@ export const onInit = (connection: Connection) => { connection.onCompletionResolve(item => { const data = item.data as [CompletionItemKind, string]; - if (data[0] == CompletionItemKind.Function) { - const fn = FUNCTIONS[data[1]]!; + if (data[0] === CompletionItemKind.Function) { + const fn = FUNCTIONS[data[1]]; item.detail = `${data[1]}(${fn?.args.map(x => x.default ? `${reprType(x.type)} = ${x.default}` : reprType(x.type)).join(", ")})` item.documentation = { kind: "markdown", @@ -169,8 +173,8 @@ export const onInit = (connection: Connection) => { [workshop.codes](${WORKSHOP_CODES_HREF}${fn.ow.replaceAll(" ", "+").toLowerCase()}) ` } - } else if (data[0] == CompletionItemKind.Constant) { - const constant = CONSTANTS[data[1]]!; + } else if (data[0] === CompletionItemKind.Constant) { + const constant = CONSTANTS[data[1]]; item.detail = `${data[1]}: ${reprType(constant.type)}`; item.documentation = { kind: "markdown", @@ -178,8 +182,8 @@ export const onInit = (connection: Connection) => { **Overwatch Value**: \`${constant.ow}\` ` } - } else if (data[0] == CompletionItemKind.Event) { - const event = EVENTS[data[1]]!; + } else if (data[0] === CompletionItemKind.Event) { + const event = EVENTS[data[1]]; item.detail = `event ${data[1]}(${event.args.map(a => reprType(a.type)).join(", ")})` item.documentation = { kind: "markdown", diff --git a/packages/ramattra-playground/src/index.tsx b/packages/ramattra-playground/src/index.tsx index 20dc4e6..6d9aca4 100644 --- a/packages/ramattra-playground/src/index.tsx +++ b/packages/ramattra-playground/src/index.tsx @@ -1,7 +1,7 @@ import { render } from "preact"; import { useEffect, useState } from "preact/hooks"; -import { Error, assemble } from "@ramattra/ramattra-core"; +import { type Error, assemble } from "@ramattra/ramattra-core"; const urlParams = new URLSearchParams(window.location.search); const codeParam = urlParams.get("code"); @@ -67,9 +67,9 @@ const App = () => { return <>