Set up the package, compiler and quality gates before any app code so every later change lands under the same rules: Node 26 via .nvmrc and engines, TypeScript 7 in strict mode with the extra strictness flags, swc for transpiling, oxlint with type-aware, Unicorn and security rules (eslint-plugin-security and no-unsanitized loaded as JS plugins), oxfmt, Vitest with a 100% coverage gate, and husky hooks that run the checks and commitlint. Type escape hatches, lint suppressions and coverage exemptions are banned unless registered in exceptions.json. scripts/audit-exceptions enforces that, and its test runs it against this repository, so an unregistered suppression fails both the pre-commit hook and CI. npm 11 blocks dependency install scripts by default. None are needed: Electron downloads its binary on first use, swc's native binding comes from optionalDependencies, fsevents ships prebuilt, and electron-winstaller only serves Squirrel installers, which aren't used. They are recorded as denied in allowScripts.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
|
|
import { playwright } from '@vitest/browser-playwright';
|
|
import { defineConfig } from 'vitest/config';
|
|
|
|
import { parseRegistry, unitCoverageExemptPaths } from './scripts/lib/exceptions.ts';
|
|
|
|
const registry = parseRegistry(JSON.parse(readFileSync('exceptions.json', 'utf8')));
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
testTimeout: 10_000,
|
|
projects: [
|
|
{
|
|
test: {
|
|
name: 'node',
|
|
environment: 'node',
|
|
include: ['src/**/*.test.ts', 'scripts/**/*.test.ts'],
|
|
exclude: ['src/renderer/**'],
|
|
},
|
|
},
|
|
{
|
|
test: {
|
|
name: 'renderer',
|
|
include: ['src/renderer/**/*.test.ts'],
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: playwright(),
|
|
instances: [{ browser: 'chromium' }],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
coverage: {
|
|
provider: 'v8',
|
|
include: ['src/**/*.ts', 'scripts/**/*.ts'],
|
|
exclude: ['**/*.test.ts', '**/*.d.ts', ...unitCoverageExemptPaths(registry)],
|
|
reporter: ['text', 'html', 'lcov'],
|
|
thresholds: { lines: 100, branches: 100, functions: 100, statements: 100 },
|
|
},
|
|
},
|
|
});
|