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

Use biome instead of prettier to format the code #131

Merged
merged 1 commit into from
Sep 9, 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
12 changes: 12 additions & 0 deletions .changeset/seven-jobs-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"better-steam-rating": patch
"ghproxy-gist-raw": patch
"ghproxy-releases": patch
"douban2rarbg": patch
"ghproxy-raw": patch
"exclude-dv": patch
"template": patch
"down-git": patch
---

Use [`biome`](https://biomejs.dev) instead of [`prettier`](https://prettier.io) to format the code.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
node-version-file: package.json
cache: "pnpm"
- run: pnpm install -rw --frozen-lockfile
- run: pnpm lint
- run: pnpm cov
- run: pnpm biome ci --reporter=github
- run: pnpm run cov
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

16 changes: 16 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": { "enabled": true },
"linter": {
"rules": { "recommended": true }
},
"formatter": {
"indentStyle": "space"
},
"files": { "ignoreUnknown": true },
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"test": "turbo run test",
"cov": "turbo run cov",
"pkg": "vite-node ./scripts/pack.ts",
"lint": "turbo run lint",
"fmt": "turbo run fmt",
"lint": "biome check",
"fmt": "biome check --write",
"changeset": "changeset"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.8",
"@types/node": "^22.5.4",
"glob": "^11.0.0",
"prettier": "^3.3.3",
"turbo": "^2.1.1",
"typescript": "^5.5.4",
"vite-node": "^2.0.5"
Expand Down
9 changes: 2 additions & 7 deletions packages/_template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@
"url": "https://github.com/mogeko/userscripts/issues",
"email": "[email protected]"
},
"keywords": [
"userscript",
"tampermonkey"
],
"keywords": ["userscript", "tampermonkey"],
"license": "MIT",
"scripts": {
"build": "vite build",
"lint": "prettier --check .",
"fmt": "prettier --write ."
"build": "vite build"
},
"devDependencies": {
"@mogeko/tsconfig": "^0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/_template/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
console.log("Hello World");

export {};
export type {};
2 changes: 1 addition & 1 deletion packages/_template/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import monkey from "vite-plugin-monkey";

const baseURL = process.env["BASE_URL"] || "https://userscripts.mogeko.me";
const baseURL = process.env.BASE_URL || "https://userscripts.mogeko.me";

export default defineConfig({
plugins: [
Expand Down
10 changes: 2 additions & 8 deletions packages/better-steam-rating/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
"url": "https://github.com/mogeko/userscripts/issues",
"email": "[email protected]"
},
"keywords": [
"userscript",
"tampermonkey",
"steam"
],
"keywords": ["userscript", "tampermonkey", "steam"],
"license": "MIT",
"scripts": {
"build": "vite build",
"lint": "prettier --check .",
"fmt": "prettier --write ."
"build": "vite build"
},
"devDependencies": {
"@types/node": "^22.5.4",
Expand Down
15 changes: 8 additions & 7 deletions packages/better-steam-rating/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ function hideEle(item) {

function checkFn() {
const minRealNum = 100;
const items = document.querySelectorAll(".responsive_search_name_combined");

items.forEach((item2) => {
for (const item2 of document.querySelectorAll(
".responsive_search_name_combined",
)) {
if (item2.dataset.isCheck) return;

let days = 0;
Expand All @@ -36,7 +37,7 @@ function checkFn() {
gameDate.setDate(dateArr[2]);

days = (new Date().getTime() - gameDate.getTime()) / 86400000;
days = parseInt(days);
days = Number.parseInt(days);
}
}

Expand All @@ -63,9 +64,9 @@ function checkFn() {

const num = lastArr[0].replace(/\,/g, "");
const rate = lastArr[2].replace("%", "");
const realNum = parseInt((num * rate) / 100);
const realNum = Number.parseInt((num * rate) / 100);

if (isNaN(realNum)) {
if (Number.isNaN(realNum)) {
console.log(content);
return;
}
Expand All @@ -77,7 +78,7 @@ function checkFn() {
realRate = realRate > 10 ? realRate.toFixed(0) : realRate.toFixed(1);
}

const innerHtml = `<span style="padding-left: 0.5em;width: 2em;display: inline-block;">${rate}</span><span style="width: 4.5em;display:inline-block;">${parseInt(
const innerHtml = `<span style="padding-left: 0.5em;width: 2em;display: inline-block;">${rate}</span><span style="width: 4.5em;display:inline-block;">${Number.parseInt(
(num * rate) / 100,
)}</span><span style="width: 3em;display:inline-block;">${days}</span><span style="width:3em;display:inline-block;">${realRate}</span>`;

Expand All @@ -93,7 +94,7 @@ function checkFn() {
if (realNum && realNum < minRealNum && realRate !== "-" && realRate < 0.1) {
hideEle(item);
}
});
}
}

setInterval(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/better-steam-rating/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import monkey from "vite-plugin-monkey";

const baseURL = process.env["BASE_URL"] || "https://userscripts.mogeko.me";
const baseURL = process.env.BASE_URL || "https://userscripts.mogeko.me";

export default defineConfig({
plugins: [
Expand Down
11 changes: 2 additions & 9 deletions packages/douban2rarbg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@
"url": "https://github.com/mogeko/userscripts/issues",
"email": "[email protected]"
},
"keywords": [
"userscript",
"tampermonkey",
"douban",
"rarbg"
],
"keywords": ["userscript", "tampermonkey", "douban", "rarbg"],
"license": "MIT",
"scripts": {
"build": "vite build",
"test": "vitest run",
"cov": "vitest run --coverage",
"lint": "prettier --check .",
"fmt": "prettier --write ."
"cov": "vitest run --coverage"
},
"devDependencies": {
"@mogeko/tsconfig": "^0.0.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/douban2rarbg/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const META_DATA = {
},
};

(function () {
(() => {
const metaRoot = document.querySelector("#info");
const imdb = metaRoot?.textContent?.match(/tt[0-9]{4,}/)?.[0];
const doubanID = document.location.toString().split("/")[4];

if (!imdb || !doubanID) return;

Object.entries(META_DATA).forEach(([key, sites]) => {
for (const [key, sites] of Object.entries(META_DATA)) {
const metaNode = document.createElement("span");
const plNode = document.createElement("span");
const attrsNode = document.createElement("span");
Expand Down Expand Up @@ -61,7 +61,7 @@ const META_DATA = {

metaRoot.appendChild(metaNode);
metaRoot.appendChild(br);
});
}
})();

export {};
export type {};
2 changes: 1 addition & 1 deletion packages/douban2rarbg/test/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { JSDOM } from "jsdom";
import { describe, expect, it } from "vitest";

describe("douban2rarbg", () => {
it("should work", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/douban2rarbg/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import monkey from "vite-plugin-monkey";

const baseURL = process.env["BASE_URL"] || "https://userscripts.mogeko.me";
const baseURL = process.env.BASE_URL || "https://userscripts.mogeko.me";

export default defineConfig({
plugins: [
Expand Down
10 changes: 2 additions & 8 deletions packages/down-git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
"url": "https://github.com/mogeko/userscripts/issues",
"email": "[email protected]"
},
"keywords": [
"userscript",
"tampermonkey",
"github"
],
"keywords": ["userscript", "tampermonkey", "github"],
"license": "MIT",
"scripts": {
"build": "vite build",
"lint": "prettier --check .",
"fmt": "prettier --write ."
"build": "vite build"
},
"devDependencies": {
"@mogeko/tsconfig": "^0.0.4",
Expand Down
12 changes: 6 additions & 6 deletions packages/down-git/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function downloader(localUrl: string) {

if (flag === "tree") {
return `${DOWN_GIT}/#/home?url=${localUrl}`;
} else if (flag === "blob") {
}
if (flag === "blob") {
return `${JSDELIVR}/gh/${user}/${repo}@${branch}/${rest.join("/")}`;
} else {
return localUrl;
}
return localUrl;
}

function setButton(urlNode: HTMLAnchorElement) {
Expand All @@ -40,14 +40,14 @@ function setButton(urlNode: HTMLAnchorElement) {
}

requestIdleCallback(() => {
document.querySelectorAll("div.Box-row").forEach((node) => {
for (const node of document.querySelectorAll("div.Box-row")) {
const urlNode = node.querySelector("a");
const anchorNode = node.querySelector("div.text-right");

if (!urlNode || urlNode.querySelector("span")) return;

node.insertBefore(setButton(urlNode), anchorNode);
});
}
});

export {};
export type {};
2 changes: 1 addition & 1 deletion packages/down-git/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import monkey from "vite-plugin-monkey";

const baseURL = process.env["BASE_URL"] || "https://userscripts.mogeko.me";
const baseURL = process.env.BASE_URL || "https://userscripts.mogeko.me";

export default defineConfig({
plugins: [
Expand Down
10 changes: 2 additions & 8 deletions packages/exclude-dv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
"url": "https://github.com/mogeko/userscripts/issues",
"email": "[email protected]"
},
"keywords": [
"userscript",
"tampermonkey",
"rarbg"
],
"keywords": ["userscript", "tampermonkey", "rarbg"],
"license": "MIT",
"scripts": {
"build": "vite build",
"lint": "prettier --check .",
"fmt": "prettier --write ."
"build": "vite build"
},
"devDependencies": {
"@mogeko/tsconfig": "^0.0.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/exclude-dv/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const DV_TRAIT = /(\w+[\.\-\ \[\]])+DV[\.\-\ \[\]](\w+[\.\-\ \[\]]?)+/;

document.querySelectorAll("table.lista2t tr.lista2").forEach((tr) => {
for (const tr of document.querySelectorAll("table.lista2t tr.lista2")) {
const link = tr.querySelector<HTMLAnchorElement>("td:nth-child(2) > a");

if (DV_TRAIT.test(link?.innerHTML || "")) {
console.log("[Exclude DV] Remove: ", link?.title);
tr.remove();
}
});
}

export {};
export type {};
2 changes: 1 addition & 1 deletion packages/exclude-dv/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import monkey from "vite-plugin-monkey";

const baseURL = process.env["BASE_URL"] || "https://userscripts.mogeko.me";
const baseURL = process.env.BASE_URL || "https://userscripts.mogeko.me";

export default defineConfig({
plugins: [
Expand Down
11 changes: 2 additions & 9 deletions packages/ghproxy-gist-raw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@
"url": "https://github.com/mogeko/userscripts/issues",
"email": "[email protected]"
},
"keywords": [
"userscript",
"tampermonkey",
"github",
"gist"
],
"keywords": ["userscript", "tampermonkey", "github", "gist"],
"license": "MIT",
"scripts": {
"build": "vite build",
"lint": "prettier --check .",
"fmt": "prettier --write ."
"build": "vite build"
},
"devDependencies": {
"@mogeko/tsconfig": "^0.0.4",
Expand Down
10 changes: 4 additions & 6 deletions packages/ghproxy-gist-raw/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const PROXY_URL = "https://ghproxy.com/";

function agentGistRaw(proxy: string) {
const links = document.querySelectorAll<HTMLLinkElement>(
for (const link of document.querySelectorAll<HTMLLinkElement>(
".file-actions a, .ml-2:nth-last-child(1) a",
);

links.forEach((link) => {
)) {
link.href = proxy + link.href;
});
}
}

agentGistRaw(PROXY_URL);
Expand All @@ -16,4 +14,4 @@ document.addEventListener("pjax:success", () => {
agentGistRaw(PROXY_URL);
});

export {};
export type {};
2 changes: 1 addition & 1 deletion packages/ghproxy-gist-raw/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import monkey from "vite-plugin-monkey";

const baseURL = process.env["BASE_URL"] || "https://userscripts.mogeko.me";
const baseURL = process.env.BASE_URL || "https://userscripts.mogeko.me";

export default defineConfig({
plugins: [
Expand Down
Loading