Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Biome Svelte issues #14

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 200,
"attributePosition": "auto"
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"style": {
"noParameterAssign": "off",
"noArguments": "off"
}
}
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
}
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 200,
"attributePosition": "auto"
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"style": {
"noParameterAssign": "off",
"noArguments": "off"
}
},
"ignore": ["**/*.svelte"]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "single",
"trailingCommas": "es5",
"semicolons": "always",
"quoteStyle": "single"
}
}
}
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@
"format": "biome format --write src/ && biome check --write src/"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@tailwindcss/typography": "^0.5.15",
"@biomejs/biome": "^1.8.3",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@tailwindcss/typography": "^0.5.13",
"@tsconfig/svelte": "^5.0.4",
"autoprefixer": "^10.4.20",
"daisyui": "^4.12.10",
"postcss": "^8.4.45",
"publish-browser-extension": "^2.2.1",
"svelte": "^4.2.19",
"svelte-check": "^4.0.1",
"tailwindcss": "^3.4.10",
"tslib": "^2.7.0",
"typescript": "^5.5.4",
"vite": "^5.4.3",
"wxt": "^0.19.9"
"autoprefixer": "^10.4.19",
"daisyui": "^4.11.1",
"postcss": "^8.4.38",
"publish-browser-extension": "^2.1.3",
"svelte": "^4.2.17",
"svelte-check": "^3.7.1",
"tailwindcss": "^3.4.3",
"tslib": "^2.6.2",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"wxt": "^0.18.2"
},
"dependencies": {
"@types/chrome": "^0.0.270",
"bits-ui": "^0.21.13",
"@types/chrome": "^0.0.268",
"bits-ui": "^0.21.9",
"clsx": "^2.1.1",
"decimal": "^0.0.2",
"decimal.js": "^10.4.3",
"svelte-radix": "^1.1.1",
"tailwind-merge": "^2.5.2",
"svelte-radix": "^1.1.0",
"tailwind-merge": "^2.3.0",
"tailwind-variants": "^0.2.1"
}
}
95 changes: 84 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions src/entrypoints/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export default defineUnlistedScript({
});

function adjustWindow() {
window.addEventListener("message", (event) => {
if (event.data?.type === "toast") {
window.addEventListener('message', (event) => {
if (event.data?.type === 'toast') {
// @ts-ignore
Buff.toast(event.data.text, {
type: event.data?.success ? "success" : "error",
type: event.data?.success ? 'success' : 'error',
});
}
});
Expand All @@ -21,32 +21,32 @@ function adjustWindow() {
}

function betterbuff_forceNewestReload() {
const reloadKey = "bb_reload";
const reloadKey = 'bb_reload';

// @ts-ignore
const hash = getParamsFromHash();

let currentReload = +(hash[reloadKey] ?? "0");
let currentReload = +(hash[reloadKey] ?? '0');

currentReload++;

// @ts-ignore
updateHashData({
page: 1,
sort_by: "created.desc",
sort_by: 'created.desc',
[reloadKey]: currentReload,
});
}

function openIntercept() {
const open = window.XMLHttpRequest.prototype.open;
console.log("[BetterBuff] Activating HttpRequest Intercept...");
console.log('[BetterBuff] Activating HttpRequest Intercept...');

window.XMLHttpRequest.prototype.open = function () {
(<XMLHttpRequest>this).addEventListener("load", (e) => {
(<XMLHttpRequest>this).addEventListener('load', (e) => {
const target = <XMLHttpRequest>e.currentTarget;
if (!target.responseURL.includes(location.hostname)) {
console.debug(`[BetterBuff] Ignoring HTTP request to: ${target.responseURL}`);
console.debug('[BetterBuff] Ignoring HTTP request to: ' + target.responseURL);
return;
}

Expand All @@ -61,21 +61,21 @@ function openIntercept() {
}

// request finished loading
if (target.readyState === 4) {
if (loadNumber++ === 0) {
const globalG = window["g" as any];
if (target.readyState == 4) {
if (loadNumber++ == 0) {
const globalG = window['g' as any];
document.dispatchEvent(
new CustomEvent("BetterBuff_INTERCEPTED_REQUEST", {
new CustomEvent('BetterBuff_INTERCEPTED_REQUEST', {
detail: {
status: 200,
url: "betterbuff_global_data",
url: 'betterbuff_global_data',
data: globalG,
},
})
);
}
document.dispatchEvent(
new CustomEvent("BetterBuff_INTERCEPTED_REQUEST", {
new CustomEvent('BetterBuff_INTERCEPTED_REQUEST', {
detail: {
status: target.status,
url: target.responseURL,
Expand Down
22 changes: 11 additions & 11 deletions src/lib/components/InfoTooltip.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script lang="ts">
import Decimal from "decimal.js";
import type { BuffTypes } from "../@types/BuffTypes";
import Decimal from 'decimal.js';
import type { BuffTypes } from '../@types/BuffTypes';

export let data: BuffTypes.PriceHistory.Data;
let isHovered = false;
let isClicked = false;
export let data: BuffTypes.PriceHistory.Data;
let isHovered = false,
isClicked = false;

const minPrice = data.price_history.reduce((a, b) => Math.min(a, b[1]), Number.POSITIVE_INFINITY);
const maxPrice = data.price_history.reduce((a, b) => Math.max(a, b[1]), Number.NEGATIVE_INFINITY);
const priceChange = new Decimal(data.price_history[data.price_history.length - 1][1]).minus(data.price_history[0][1]);
const priceChangePercentage = priceChange.div(data.price_history[0][1]).times(100);
const minPrice = data.price_history.reduce((a, b) => Math.min(a, b[1]), Infinity);
const maxPrice = data.price_history.reduce((a, b) => Math.max(a, b[1]), -Infinity);
const priceChange = new Decimal(data.price_history[data.price_history.length - 1][1]).minus(data.price_history[0][1]);
const priceChangePercentage = priceChange.div(data.price_history[0][1]).times(100);

const minElement = data.price_history.find((e) => e[1] === minPrice)!;
const maxElement = data.price_history.find((e) => e[1] === maxPrice)!;
const minElement = data.price_history.find((e) => e[1] === minPrice)!;
const maxElement = data.price_history.find((e) => e[1] === maxPrice)!;
</script>

<!-- svelte-ignore a11y-mouse-events-have-key-events -->
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/NavLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { openLink } from '../util/svelteUtil';

export let src: string;
export let link: string;
export const imgStyle = '';
export let imgStyle: string = '';
</script>
<button class="btn-ghost rounded-full" on:click={() => openLink(link)}>
<img {src} alt="Social Link" class={imgStyle} />
Expand Down
Loading