From a769bbf57e2309131efb28668f6b79fc05b060c1 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Sat, 24 May 2025 08:04:14 +1000 Subject: [PATCH] chore: add linting --- .vscode/extensions.json | 2 +- biome.json | 46 +++++++++++ package-lock.json | 165 ++++++++++++++++++++++++++++++++++++++++ package.json | 44 ++++++----- public/content.js | 41 +--------- public/manifest.json | 36 ++++----- src/main.ts | 22 ------ src/style.css | 79 ------------------- tsconfig.app.json | 44 +++++------ tsconfig.json | 10 +-- tsconfig.node.json | 40 +++++----- vite.config.ts | 42 +++++----- 12 files changed, 320 insertions(+), 251 deletions(-) create mode 100644 biome.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index a7cea0b..7e0dd92 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["Vue.volar"] + "recommendations": ["Vue.volar"] } diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..55fad2f --- /dev/null +++ b/biome.json @@ -0,0 +1,46 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": false, + "ignore": [] + }, + "formatter": { + "enabled": true, + "indentStyle": "tab" + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedVariables": "error", + "noUndeclaredVariables": "error", + "noUnreachable": "error", + "noUnsafeFinally": "error" + }, + "security": { + "noDangerouslySetInnerHtml": "error", + "noGlobalEval": "error" + }, + "style": { + "noVar": "error", + "useBlockStatements": "error", + "useConst": "error" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "asNeeded" + } + } +} diff --git a/package-lock.json b/package-lock.json index 57b2aa4..9a72cfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "vue": "^3.5.13" }, "devDependencies": { + "@biomejs/biome": "1.9.4", "@vitejs/plugin-vue": "^5.2.1", "typescript": "~5.6.2", "vite": "^6.0.1", @@ -78,6 +79,170 @@ "node": ">=6.9.0" } }, + "node_modules/@biomejs/biome": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz", + "integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==", + "dev": true, + "hasInstallScript": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.9.4", + "@biomejs/cli-darwin-x64": "1.9.4", + "@biomejs/cli-linux-arm64": "1.9.4", + "@biomejs/cli-linux-arm64-musl": "1.9.4", + "@biomejs/cli-linux-x64": "1.9.4", + "@biomejs/cli-linux-x64-musl": "1.9.4", + "@biomejs/cli-win32-arm64": "1.9.4", + "@biomejs/cli-win32-x64": "1.9.4" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz", + "integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz", + "integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz", + "integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz", + "integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz", + "integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz", + "integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz", + "integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz", + "integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.4", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.4.tgz", diff --git a/package.json b/package.json index 602e988..45ec998 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,25 @@ { - "name": "msr-mod", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "vue-tsc -b && vite build && cp -r public/* dist/", - "build:watch": "vite build --watch", - "preview": "vite preview" - }, - "dependencies": { - "@tailwindcss/vite": "^4.1.7", - "tailwindcss": "^4.1.7", - "vue": "^3.5.13" - }, - "devDependencies": { - "@vitejs/plugin-vue": "^5.2.1", - "typescript": "~5.6.2", - "vite": "^6.0.1", - "vue-tsc": "^2.1.10" - } + "name": "msr-mod", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vue-tsc -b && vite build && cp -r public/* dist/", + "build:watch": "vite build --watch", + "preview": "vite preview", + "lint": "biome format --write ." + }, + "dependencies": { + "@tailwindcss/vite": "^4.1.7", + "tailwindcss": "^4.1.7", + "vue": "^3.5.13" + }, + "devDependencies": { + "@biomejs/biome": "1.9.4", + "@vitejs/plugin-vue": "^5.2.1", + "typescript": "~5.6.2", + "vite": "^6.0.1", + "vue-tsc": "^2.1.10" + } } diff --git a/public/content.js b/public/content.js index 913b134..4f26e78 100644 --- a/public/content.js +++ b/public/content.js @@ -1,38 +1,3 @@ -// Replace the body content with the Vue app -function replaceBodyContent() { - console.log('replaceBodyContent') - // Remove existing body content - document.body.innerHTML = '' - // Create a new container for the Vue app - const container = document.createElement('div') - container.id = 'app' - document.body.appendChild(container) - - console.log('content.js') - -// Run the replacement -replaceBodyContent() - -// remove all script and link tags -const scripts = document.getElementsByTagName('script') -console.log(scripts) -const links = document.getElementsByTagName('link') -for (let i in scripts) { - console.log(scripts[i]) - scripts[i].remove() -} -for (let i in links) { - console.log(links[i]) - links[i].remove() -} - -// insert assets/index.js and assets/index.css -const script = document.createElement('script') -script.src = chrome.runtime.getURL('assets/index.js') -document.head.appendChild(script) -const link = document.createElement('link') -link.rel = 'stylesheet' -link.href = chrome.runtime.getURL('assets/index.css') -document.head.appendChild(link) -} - +// redirect to extension's index.html +const extensonUrl = chrome.extension.getURL('index.html') +const url = window.location.href diff --git a/public/manifest.json b/public/manifest.json index e20846e..6bdff86 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,19 +1,19 @@ { - "manifest_version": 3, - "name": "MSR Mod", - "version": "0.0.1", - "description": "A Vue-based browser extension.", - "content_scripts": [ - { - "matches": ["https://monster-siren.hypergryph.com/"], - "js": ["assets/index.js"], - "run_at": "document_end" - } - ], - "icons": { - "16": "vite.svg", - "48": "vite.svg", - "128": "vite.svg" - }, - "permissions": [] -} \ No newline at end of file + "manifest_version": 3, + "name": "MSR Mod", + "version": "0.0.1", + "description": "A Vue-based browser extension.", + "content_scripts": [ + { + "matches": ["https://monster-siren.hypergryph.com/"], + "js": ["content.js"], + "run_at": "document_end" + } + ], + "permissions": ["webRequest", "webRequestBlocking"], + "icons": { + "16": "vite.svg", + "48": "vite.svg", + "128": "vite.svg" + } +} diff --git a/src/main.ts b/src/main.ts index a98c6ef..2425c0f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,26 +2,4 @@ import { createApp } from 'vue' import './style.css' import App from './App.vue' -// Replace the body content with the Vue app -// Remove existing body content -document.getElementsByTagName('html')[0].innerHTML = ` - - - - Popup - - -
- -` - -if ('serviceWorker' in navigator) { - navigator.serviceWorker.getRegistrations().then(registrations => { - for (let registration of registrations) { - registration.unregister() - } - }) -} - -// mount Vue app createApp(App).mount('#app') diff --git a/src/style.css b/src/style.css index bb131d6..e69de29 100644 --- a/src/style.css +++ b/src/style.css @@ -1,79 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -.card { - padding: 2em; -} - -#app { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/tsconfig.app.json b/tsconfig.app.json index 0a1fffd..f3c500c 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -1,26 +1,22 @@ { - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - "jsx": "preserve", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "preserve", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] } diff --git a/tsconfig.json b/tsconfig.json index 1ffef60..fb12418 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { - "files": [], - "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } - ] + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] } diff --git a/tsconfig.node.json b/tsconfig.node.json index db0becc..5a2a3a0 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,24 +1,20 @@ { - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2022", - "lib": ["ES2023"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["vite.config.ts"] + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2022", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["vite.config.ts"] } diff --git a/vite.config.ts b/vite.config.ts index 9143202..3638531 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,25 +3,25 @@ import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig({ - plugins: [vue()], - base: './', // Ensure relative paths work - build: { - outDir: 'dist', - rollupOptions: { - // Optional: configure input if you have multiple HTML files (e.g., options page) - // input: { - // popup: resolve(__dirname, 'index.html'), - // // options: resolve(__dirname, 'options.html'), // If you have an options page - // }, - output: { - entryFileNames: `assets/[name].js`, - chunkFileNames: `assets/[name].js`, - assetFileNames: `assets/[name].[ext]` - // Optional: to disable hashing for specific assets if needed - // entryFileNames: `assets/[name].js`, - // chunkFileNames: `assets/[name].js`, - // assetFileNames: `assets/[name].[ext]` - } - } - } + plugins: [vue()], + base: './', // Ensure relative paths work + build: { + outDir: 'dist', + rollupOptions: { + // Optional: configure input if you have multiple HTML files (e.g., options page) + // input: { + // popup: resolve(__dirname, 'index.html'), + // // options: resolve(__dirname, 'options.html'), // If you have an options page + // }, + output: { + entryFileNames: `assets/[name].js`, + chunkFileNames: `assets/[name].js`, + assetFileNames: `assets/[name].[ext]`, + // Optional: to disable hashing for specific assets if needed + // entryFileNames: `assets/[name].js`, + // chunkFileNames: `assets/[name].js`, + // assetFileNames: `assets/[name].[ext]` + }, + }, + }, })