Skip to content
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
45 changes: 3 additions & 42 deletions bun.lock

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"lucide-vue-next": "^1.0.0",
"prettier": "^3.9.10",
"sass-embedded": "^1.105.1",
"typescript": "^7.0.2",
"typescript": "~5.9.3",
"typescript-eslint": "^8.71.2",
"vite": "^8",
"vite-tsconfig-paths": "^5",
Expand Down
5 changes: 2 additions & 3 deletions src/i18n/gen_trans.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const f = 'D:/压缩/tech-detector-extension/src/i18n/evidence_translations.json'
import fs from 'node:fs'
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
const f = new URL('./evidence_translations.json', import.meta.url)
const d = {}
Object.assign(d, {
'Server 响应头包含 PostgREST': 'Server response header contains PostgREST',
Expand Down Expand Up @@ -210,7 +210,6 @@ Object.assign(d, {
'响应 URL 指向 Beehiiv': 'Response URL points to Beehiiv',
'响应 URL 指向 Better Stack 状态页': 'Response URL points to Better Stack status page'
})
fs.writeFileSync(f, JSON.stringify(d, null, 2), 'utf8')
Object.assign(d, {
'响应 URL 指向 BigDataCloud IP Geolocation': 'Response URL points to BigDataCloud IP Geolocation',
'响应 URL 指向 BigMarker': 'Response URL points to BigMarker',
Expand Down
1 change: 0 additions & 1 deletion src/ui/popup/Popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@
import {
CACHE_REFRESH_DELAYS,
FOCUS_CATEGORY,
REPOSITORY_URL,
RAW_PLACEHOLDER,
SETTINGS_STORAGE_KEY,
STATUS_HIDE_DELAY,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@
import { applyCustomCss } from '@/utils/apply-custom-css'
import { cleanCustomRules, cleanStringArray, defaultSettings, normalizeSettings } from '@/utils/normalize-settings'
import { buildRuleContributionUrl } from '@/utils/build-issue-url'
import { REPOSITORY_URL, SETTINGS_STORAGE_KEY, STATUS_HIDE_DELAY, getReadmeUrl } from '@/utils/constants'
import { SETTINGS_STORAGE_KEY, STATUS_HIDE_DELAY, getReadmeUrl } from '@/utils/constants'
import { ALLOWED_CONFIDENCES, ALLOWED_MATCH_TARGETS, ALLOWED_MATCH_TYPES, CUSTOM_RULE_LIMITS } from '@/types/settings'
import { cycleTheme, getStoredTheme, setStoredTheme, themeLabel, type ThemeMode } from '@/utils/theme'
import { cycleTheme, getStoredTheme, setStoredTheme, type ThemeMode } from '@/utils/theme'

const { t, tm, locale } = useI18n()

Expand Down
4 changes: 2 additions & 2 deletions src/utils/build-issue-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const fallbackT: TFn = key => {
export const buildCorrectionIssueUrl = (
tech: TechnologyRecord,
ctx: CorrectionContext = {},
t: TFn = fallbackT,
_t: TFn = fallbackT,
locale?: string
): string => {
const feedbackUrl = new URL(`${DOCS_URL}/feedback`)
Expand All @@ -54,7 +54,7 @@ export const buildCorrectionIssueUrl = (
return feedbackUrl.toString()
}

export const buildRuleContributionUrl = (name?: string, category?: string, t: TFn = fallbackT, locale?: string): string => {
export const buildRuleContributionUrl = (name?: string, category?: string, _t: TFn = fallbackT, locale?: string): string => {
const trimmedName = (name ?? '').trim()
const trimmedCategory = (category ?? '').trim()
const feedbackUrl = new URL(`${DOCS_URL}/feedback`)
Expand Down
11 changes: 3 additions & 8 deletions tests/format-tech-stack.test.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { test } from 'node:test'
import ts from 'typescript'
import { transform } from 'esbuild'

const loadFormatter = async () => {
const source = await readFile(new URL('../src/utils/format-tech-stack.ts', import.meta.url), 'utf8')
const { outputText } = ts.transpileModule(source, {
compilerOptions: {
module: ts.ModuleKind.ES2022,
target: ts.ScriptTarget.ES2022
}
})
const encoded = Buffer.from(outputText, 'utf8').toString('base64')
const { code } = await transform(source, { loader: 'ts', format: 'esm', target: 'es2022' })
const encoded = Buffer.from(code, 'utf8').toString('base64')
return import(`data:text/javascript;base64,${encoded}`)
}

Expand Down
24 changes: 24 additions & 0 deletions tests/translation-generation.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import assert from 'node:assert/strict'
import { execFile } from 'node:child_process'
import { copyFile, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import path from 'node:path'
import { test } from 'node:test'
import { promisify } from 'node:util'

const exec = promisify(execFile)

test('translation generator runs as ESM and writes beside its module from another working directory', async () => {
const directory = await mkdtemp(new URL('./translation-fixture-', import.meta.url))
try {
const script = path.join(directory, 'gen_trans.js')
await copyFile(new URL('../src/i18n/gen_trans.js', import.meta.url), script)
await writeFile(path.join(directory, 'package.json'), '{"type":"module"}')
await exec(process.execPath, [script], { cwd: path.dirname(directory) })
const translations = JSON.parse(await readFile(path.join(directory, 'evidence_translations.json'), 'utf8'))
assert.equal(translations['Server 响应头包含 PostgREST'], 'Server response header contains PostgREST')
assert.equal(translations['存在 x-runtime 响应头'], 'x-runtime response header present')
} finally {
// mkdtemp owns this exact directory; never remove the repository's translations.
await rm(directory, { recursive: true, force: true })
}
})
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"moduleResolution": "Bundler",
"lib": ["ES2022", "DOM", "DOM.Iterable", "WebWorker"],
"types": ["chrome", "node", "vite/client"],
"allowImportingTsExtensions": false,
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
Expand Down