Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 committed Jun 11, 2024
1 parent 61c19b8 commit 50846ce
Show file tree
Hide file tree
Showing 96 changed files with 814 additions and 847 deletions.
708 changes: 346 additions & 362 deletions .dependency-cruiser.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
"organizeImports": {
"enabled": true
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig tsconfig.json --watch",
"lint": "npx @biomejs/biome check --apply ./src",
"lint": "npx @biomejs/biome check --write ./src",
"lint:deps": "npx depcruise apps"
},
"type": "module",
Expand Down Expand Up @@ -38,30 +38,30 @@
"@twurple/auth": "7.1.0",
"@twurple/easy-bot": "7.1.0",
"@twurple/pubsub": "7.1.0",
"hono": "4.4.4",
"hono": "4.4.5",
"howler": "2.2.4",
"jsonwebtoken": "9.0.2",
"pixi.js": "8.1.6",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@biomejs/biome": "1.8.0",
"@biomejs/biome": "1.8.1",
"@sveltejs/kit": "2.5.10",
"@sveltejs/vite-plugin-svelte": "3.1.1",
"@tailwindcss/vite": "4.0.0-alpha.15",
"@tailwindcss/vite": "4.0.0-alpha.16",
"@types/bun": "1.1.3",
"@types/howler": "2.2.11",
"@types/jsonwebtoken": "9.0.6",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.3.0",
"dependency-cruiser": "16.3.2",
"@vitejs/plugin-react": "4.3.1",
"dependency-cruiser": "16.3.3",
"prisma": "5.15.0",
"svelte": "4.2.18",
"svelte-adapter-bun": "0.5.2",
"svelte-check": "3.8.0",
"tailwindcss": "4.0.0-alpha.15",
"tailwindcss": "4.0.0-alpha.16",
"tslib": "2.6.3",
"typescript": "5.4.5",
"vite": "5.2.13"
Expand Down
4 changes: 1 addition & 3 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
import type { IProfile } from "$lib/types";
import type { IProfile } from "$lib/types"

declare global {
namespace App {
Expand All @@ -14,5 +14,3 @@ declare global {
// interface Platform {}
}
}

export type {}
30 changes: 15 additions & 15 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { env as privateEnv } from "$env/dynamic/private";
import { env as publicEnv } from "$env/dynamic/public";
import { type Handle, error } from "@sveltejs/kit";
import jwt from "jsonwebtoken";
import type { IProfile } from "$lib/types";
import { env as privateEnv } from "$env/dynamic/private"
import { env as publicEnv } from "$env/dynamic/public"
import type { IProfile } from "$lib/types"
import { type Handle, error } from "@sveltejs/kit"
import jwt from "jsonwebtoken"

export const handle: Handle = async ({ event, resolve }) => {
const cookieKey = publicEnv.PUBLIC_COOKIE_KEY
const jwtSecret = privateEnv.PRIVATE_JWT_SECRET_KEY

if (jwtSecret && cookieKey && event.cookies.get(cookieKey)) {
const token = event.cookies.get(cookieKey);
const token = event.cookies.get(cookieKey)
if (!token) {
event.locals.profile = null;
return resolve(event);
event.locals.profile = null
return resolve(event)
}

try {
const payload = jwt.verify(token, jwtSecret);
const payload = jwt.verify(token, jwtSecret)
if (typeof payload === "string") {
error(400, "Something went wrong");
error(400, "Something went wrong")
}
if (!payload.profile) {
error(400, "Token is not valid");
error(400, "Token is not valid")
}

const profile = payload.profile as IProfile

event.locals.profile = {
...profile
};
...profile,
}
} catch (error) {
if (error instanceof jwt.TokenExpiredError) {
event.cookies.delete(cookieKey, { path: "/" })
}
}
}

return resolve(event);
};
return resolve(event)
}
7 changes: 6 additions & 1 deletion src/lib/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<script>
import {DISCORD_SERVER_INVITE_URL, DONATE_URL, GITHUB_REPO_URL, TWITCH_URL} from "$lib/config";
import {
DISCORD_SERVER_INVITE_URL,
DONATE_URL,
GITHUB_REPO_URL,
TWITCH_URL,
} from "$lib/config"
</script>

<footer>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import {page} from "$app/stores";
import unit from '$lib/assets/website/unit-64.png';
import Profile from "$lib/components/Profile.svelte";
import { page } from "$app/stores"
import unit from "$lib/assets/website/unit-64.png"
import Profile from "$lib/components/Profile.svelte"
</script>

<header>
Expand Down
42 changes: 21 additions & 21 deletions src/lib/components/Profile.svelte
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<script>
import {page} from "$app/stores";
import {env} from '$env/dynamic/public';
import twitchIcon from "$lib/assets/website/icons/twitch/112.png"
import { page } from "$app/stores"
import { env } from "$env/dynamic/public"
import twitchIcon from "$lib/assets/website/icons/twitch/112.png"
let url = new URL("https://id.twitch.tv/oauth2/authorize")
url.searchParams.set("client_id", env.PUBLIC_TWITCH_CLIENT_ID)
url.searchParams.set("redirect_uri", env.PUBLIC_SIGNIN_REDIRECT_URL)
url.searchParams.set("response_type", "token")
url.searchParams.set("scope", "chat:read channel:read:redemptions")
const url = new URL("https://id.twitch.tv/oauth2/authorize")
url.searchParams.set("client_id", env.PUBLIC_TWITCH_CLIENT_ID)
url.searchParams.set("redirect_uri", env.PUBLIC_SIGNIN_REDIRECT_URL)
url.searchParams.set("response_type", "token")
url.searchParams.set("scope", "chat:read channel:read:redemptions")
let isSignedIn = !!$page.data.profile
const isSignedIn = !!$page.data.profile
const handleSignOut = () => {
void fetch('/auth/profile', {
method: 'DELETE',
headers: {
'content-type': 'application/json',
},
}).finally(() => location.assign("/"))
}
const handleSignOut = () => {
void fetch("/auth/profile", {
method: "DELETE",
headers: {
"content-type": "application/json",
},
}).finally(() => location.assign("/"))
}
let menuOpened = false
let menuOpened = false
const handleMenuClick = () => {
menuOpened = !menuOpened
}
const handleMenuClick = () => {
menuOpened = !menuOpened
}
</script>

<div class="wrapper">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/game/actions/action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IGameAction, IGameActionResponse, } from "$lib/game/types"
import type { IGameAction, IGameActionResponse } from "$lib/game/types"
import type { Player } from "../objects/units"

interface IActionOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/game/actions/donateWoodToVillageAction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ANSWER } from "$lib/game/services/actionService"
import { Village } from "../chunks"
import type { Warehouse } from "../objects/buildings/warehouse"
import type { Player } from "../objects/units"
import type { GameScene } from "../scenes/gameScene"
import { Action } from "./action"
import { ANSWER } from "$lib/game/services/actionService";

interface IDonateWoodToVillageActionOptions {
scene: GameScene
Expand Down
2 changes: 1 addition & 1 deletion src/lib/game/actions/plantTreeAction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ANSWER } from "$lib/game/services/actionService"
import { Village } from "../chunks"
import type { Player } from "../objects/units"
import type { GameScene } from "../scenes/gameScene"
import { PlantNewTreeScript } from "../scripts/plantNewTreeScript"
import { Action } from "./action"
import { ANSWER } from "$lib/game/services/actionService";

interface IPlantTreeActionOptions {
scene: GameScene
Expand Down
2 changes: 1 addition & 1 deletion src/lib/game/actions/voteAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ANSWER } from "$lib/game/services/actionService"
import type { Poll } from "../common"
import type { Player } from "../objects/units"
import { Action } from "./action"
import { ANSWER } from "$lib/game/services/actionService";

interface IVoteActionOptions {
poll: Poll
Expand Down
4 changes: 2 additions & 2 deletions src/lib/game/chunks/forest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type IGameChunkTheme, type IGameForestChunk, } from "$lib/game/types"
import type { IGameChunkTheme, IGameForestChunk } from "$lib/game/types"
import { getRandomInRange } from "$lib/random"
import { Stone, Tree } from "../objects"
import type { GameScene } from "../scenes/gameScene.ts"
import { GameChunk } from "./gameChunk"
import { getRandomInRange } from "$lib/random";

interface IForestOptions {
center: IGameForestChunk["center"]
Expand Down
31 changes: 15 additions & 16 deletions src/lib/game/chunks/gameChunk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IGameChunk, IGameChunkTheme } from "$lib/game/types"
import { getRandomInRange } from "$lib/random"
import { createId } from "@paralleldrive/cuid2"
import { type IGameChunk, type IGameChunkTheme, } from "$lib/game/types"
import { Area, type GameObject, Tree } from "../objects"
import type { GameScene } from "../scenes/gameScene.ts"
import { getRandomInRange } from "$lib/random";

interface IGameChunkOptions {
center: IGameChunk["center"]
Expand All @@ -25,14 +25,14 @@ export class GameChunk implements IGameChunk {
public objects: GameObject[] = []

constructor({
title,
type,
theme,
width,
height,
center,
scene,
}: IGameChunkOptions) {
title,
type,
theme,
width,
height,
center,
scene,
}: IGameChunkOptions) {
this.id = createId()
this.center = center
this.title = title
Expand All @@ -43,14 +43,13 @@ export class GameChunk implements IGameChunk {
this.initArea({ width, height, theme })
}

public live() {
}
public live() {}

private initArea({
width,
height,
theme,
}: {
width,
height,
theme,
}: {
width: number
height: number
theme: IGameChunkTheme
Expand Down
12 changes: 6 additions & 6 deletions src/lib/game/chunks/lake.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type IGameChunkTheme, type IGameLakeChunk, } from "$lib/game/types"
import type { IGameChunkTheme, IGameLakeChunk } from "$lib/game/types"
import { getRandomInRange } from "$lib/random"
import { Lake, Stone, Tree } from "../objects"
import type { GameScene } from "../scenes/gameScene.ts"
import { GameChunk } from "./gameChunk"
import type { GameScene } from "../scenes/gameScene.ts";
import { getRandomInRange } from "$lib/random";

interface ILakeOptions {
scene: GameScene
Expand Down Expand Up @@ -44,12 +44,12 @@ export class LakeChunk extends GameChunk implements IGameLakeChunk {
const lake = new Lake({
scene: this.scene,
x: this.center.x - 100,
y: this.center.y + 400
y: this.center.y + 400,
})
const lake2 = new Lake({
scene: this.scene,
x: this.center.x - 600,
y: this.center.y + 500
y: this.center.y + 500,
})
this.objects.push(lake, lake2)
}
Expand Down Expand Up @@ -78,7 +78,7 @@ export class LakeChunk extends GameChunk implements IGameLakeChunk {
scene: this.scene,
x: point.x,
y: point.y,
resource: 1
resource: 1,
})
this.objects.push(stone)
}
Expand Down
14 changes: 6 additions & 8 deletions src/lib/game/chunks/village.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
type IGameChunkTheme,
type IGameObjectFlag,
type IGameVillageChunk,
import type {
IGameChunkTheme,
IGameObjectFlag,
IGameVillageChunk,
} from "$lib/game/types"
import { getRandomInRange } from "$lib/random"
import { Flag, Stone, Tree } from "../objects"
import { Campfire } from "../objects/buildings/campfire"
import { ConstructionArea } from "../objects/buildings/constructionArea"
Expand All @@ -14,12 +15,9 @@ import type { GameScene } from "../scenes/gameScene"
import { BuildScript } from "../scripts/buildScript"
import { ChopTreeScript } from "../scripts/chopTreeScript"
import { MoveToTargetScript } from "../scripts/moveToTargetScript"
import {
PlaceItemInWarehouseScript
} from "../scripts/placeItemInWarehouseScript"
import { PlaceItemInWarehouseScript } from "../scripts/placeItemInWarehouseScript"
import { PlantNewTreeScript } from "../scripts/plantNewTreeScript"
import { GameChunk } from "./gameChunk"
import { getRandomInRange } from "$lib/random";

interface IVillageOptions {
scene: GameScene
Expand Down
22 changes: 11 additions & 11 deletions src/lib/game/common/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getDatePlusSeconds } from "$lib/date"
import type { GameSceneType, IGameEvent } from "$lib/game/types"
import { createId } from "@paralleldrive/cuid2"
import { type GameSceneType, type IGameEvent, } from "$lib/game/types"
import { getDatePlusSeconds } from "$lib/date";

interface IEventOptions {
title: IGameEvent["title"]
Expand All @@ -27,15 +27,15 @@ export class Event implements IGameEvent {
public offers?: IGameEvent["offers"]

constructor({
title,
description,
type,
secondsToEnd,
scene,
poll,
quest,
offers,
}: IEventOptions) {
title,
description,
type,
secondsToEnd,
scene,
poll,
quest,
offers,
}: IEventOptions) {
this.id = createId()
this.title = title
this.description = description
Expand Down
Loading

0 comments on commit 50846ce

Please sign in to comment.