chore: add linting

This commit is contained in:
Astrian Zheng 2025-05-24 08:04:14 +10:00
parent d9587d3e9d
commit a769bbf57e
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA
12 changed files with 320 additions and 251 deletions

View File

@ -1,3 +1,3 @@
{ {
"recommendations": ["Vue.volar"] "recommendations": ["Vue.volar"]
} }

46
biome.json Normal file
View File

@ -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"
}
}
}

165
package-lock.json generated
View File

@ -13,6 +13,7 @@
"vue": "^3.5.13" "vue": "^3.5.13"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.9.4",
"@vitejs/plugin-vue": "^5.2.1", "@vitejs/plugin-vue": "^5.2.1",
"typescript": "~5.6.2", "typescript": "~5.6.2",
"vite": "^6.0.1", "vite": "^6.0.1",
@ -78,6 +79,170 @@
"node": ">=6.9.0" "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": { "node_modules/@esbuild/aix-ppc64": {
"version": "0.25.4", "version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.4.tgz", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.4.tgz",

View File

@ -1,23 +1,25 @@
{ {
"name": "msr-mod", "name": "msr-mod",
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vue-tsc -b && vite build && cp -r public/* dist/", "build": "vue-tsc -b && vite build && cp -r public/* dist/",
"build:watch": "vite build --watch", "build:watch": "vite build --watch",
"preview": "vite preview" "preview": "vite preview",
}, "lint": "biome format --write ."
"dependencies": { },
"@tailwindcss/vite": "^4.1.7", "dependencies": {
"tailwindcss": "^4.1.7", "@tailwindcss/vite": "^4.1.7",
"vue": "^3.5.13" "tailwindcss": "^4.1.7",
}, "vue": "^3.5.13"
"devDependencies": { },
"@vitejs/plugin-vue": "^5.2.1", "devDependencies": {
"typescript": "~5.6.2", "@biomejs/biome": "1.9.4",
"vite": "^6.0.1", "@vitejs/plugin-vue": "^5.2.1",
"vue-tsc": "^2.1.10" "typescript": "~5.6.2",
} "vite": "^6.0.1",
"vue-tsc": "^2.1.10"
}
} }

View File

@ -1,38 +1,3 @@
// Replace the body content with the Vue app // redirect to extension's index.html
function replaceBodyContent() { const extensonUrl = chrome.extension.getURL('index.html')
console.log('replaceBodyContent') const url = window.location.href
// 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)
}

View File

@ -1,19 +1,19 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "MSR Mod", "name": "MSR Mod",
"version": "0.0.1", "version": "0.0.1",
"description": "A Vue-based browser extension.", "description": "A Vue-based browser extension.",
"content_scripts": [ "content_scripts": [
{ {
"matches": ["https://monster-siren.hypergryph.com/"], "matches": ["https://monster-siren.hypergryph.com/"],
"js": ["assets/index.js"], "js": ["content.js"],
"run_at": "document_end" "run_at": "document_end"
} }
], ],
"icons": { "permissions": ["webRequest", "webRequestBlocking"],
"16": "vite.svg", "icons": {
"48": "vite.svg", "16": "vite.svg",
"128": "vite.svg" "48": "vite.svg",
}, "128": "vite.svg"
"permissions": [] }
} }

View File

@ -2,26 +2,4 @@ import { createApp } from 'vue'
import './style.css' import './style.css'
import App from './App.vue' import App from './App.vue'
// Replace the body content with the Vue app
// Remove existing body content
document.getElementsByTagName('html')[0].innerHTML = `
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Popup</title>
</head>
<body>
<div id="app"></div>
</body>
`
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(registrations => {
for (let registration of registrations) {
registration.unregister()
}
})
}
// mount Vue app
createApp(App).mount('#app') createApp(App).mount('#app')

View File

@ -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;
}
}

View File

@ -1,26 +1,22 @@
{ {
"compilerOptions": { "compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020", "target": "ES2020",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"module": "ESNext", "module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true, "skipLibCheck": true,
"moduleResolution": "bundler",
/* Bundler mode */ "allowImportingTsExtensions": true,
"moduleResolution": "bundler", "isolatedModules": true,
"allowImportingTsExtensions": true, "moduleDetection": "force",
"isolatedModules": true, "noEmit": true,
"moduleDetection": "force", "jsx": "preserve",
"noEmit": true, "strict": true,
"jsx": "preserve", "noUnusedLocals": true,
"noUnusedParameters": true,
/* Linting */ "noFallthroughCasesInSwitch": true,
"strict": true, "noUncheckedSideEffectImports": true
"noUnusedLocals": true, },
"noUnusedParameters": true, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
} }

View File

@ -1,7 +1,7 @@
{ {
"files": [], "files": [],
"references": [ "references": [
{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" } { "path": "./tsconfig.node.json" }
] ]
} }

View File

@ -1,24 +1,20 @@
{ {
"compilerOptions": { "compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022", "target": "ES2022",
"lib": ["ES2023"], "lib": ["ES2023"],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"moduleResolution": "bundler",
/* Bundler mode */ "allowImportingTsExtensions": true,
"moduleResolution": "bundler", "isolatedModules": true,
"allowImportingTsExtensions": true, "moduleDetection": "force",
"isolatedModules": true, "noEmit": true,
"moduleDetection": "force", "strict": true,
"noEmit": true, "noUnusedLocals": true,
"noUnusedParameters": true,
/* Linting */ "noFallthroughCasesInSwitch": true,
"strict": true, "noUncheckedSideEffectImports": true
"noUnusedLocals": true, },
"noUnusedParameters": true, "include": ["vite.config.ts"]
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
} }

View File

@ -3,25 +3,25 @@ import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [vue()], plugins: [vue()],
base: './', // Ensure relative paths work base: './', // Ensure relative paths work
build: { build: {
outDir: 'dist', outDir: 'dist',
rollupOptions: { rollupOptions: {
// Optional: configure input if you have multiple HTML files (e.g., options page) // Optional: configure input if you have multiple HTML files (e.g., options page)
// input: { // input: {
// popup: resolve(__dirname, 'index.html'), // popup: resolve(__dirname, 'index.html'),
// // options: resolve(__dirname, 'options.html'), // If you have an options page // // options: resolve(__dirname, 'options.html'), // If you have an options page
// }, // },
output: { output: {
entryFileNames: `assets/[name].js`, entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`, chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]` assetFileNames: `assets/[name].[ext]`,
// Optional: to disable hashing for specific assets if needed // Optional: to disable hashing for specific assets if needed
// entryFileNames: `assets/[name].js`, // entryFileNames: `assets/[name].js`,
// chunkFileNames: `assets/[name].js`, // chunkFileNames: `assets/[name].js`,
// assetFileNames: `assets/[name].[ext]` // assetFileNames: `assets/[name].[ext]`
} },
} },
} },
}) })