mirror of
https://github.com/Xevion/Pac-Man.git
synced 2026-01-31 08:25:06 -06:00
fix: address ESLint warnings and add Vitest configuration
- Add ESLint flat config with Svelte and TypeScript support - Fix unused variables and component prop naming - Add Vitest browser testing setup with Playwright - Configure separate test projects for client and server code
This commit is contained in:
+55
-11
@@ -1,13 +1,16 @@
|
||||
import devtoolsJson from 'vite-plugin-devtools-json';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { playwright } from '@vitest/browser-playwright';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import { defineConfig, type Plugin } from 'vite';
|
||||
import { type Plugin } from 'vite';
|
||||
import { execSync } from 'child_process';
|
||||
import { fontSubsetPlugin, type FontSubsetConfig } from './vite-plugin-font-subset';
|
||||
|
||||
// Character sets for font subsetting
|
||||
const TITLE_CHARS = 'PACMN-';
|
||||
const COMMON_CHARS =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,!?':;-_()\/@#&*+=%<>";
|
||||
|
||||
const COMMON_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,!?':;-_()/@#&*+=%<>";
|
||||
|
||||
const fontConfig: FontSubsetConfig = {
|
||||
fonts: [
|
||||
@@ -15,11 +18,13 @@ const fontConfig: FontSubsetConfig = {
|
||||
source: '@fontsource/russo-one/files/russo-one-latin-400-normal.woff2',
|
||||
whitelist: TITLE_CHARS
|
||||
},
|
||||
|
||||
{
|
||||
source: '@fontsource/outfit/files/outfit-latin-400-normal.woff2',
|
||||
whitelist: COMMON_CHARS,
|
||||
family: 'Outfit'
|
||||
},
|
||||
|
||||
{
|
||||
source: '@fontsource/outfit/files/outfit-latin-500-normal.woff2',
|
||||
whitelist: COMMON_CHARS,
|
||||
@@ -39,10 +44,7 @@ function pacmanVersionPlugin(): Plugin {
|
||||
}
|
||||
|
||||
try {
|
||||
const hash = execSync('git rev-parse --short HEAD', {
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
}).trim();
|
||||
const hash = execSync('git rev-parse --short HEAD', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
||||
|
||||
if (hash) {
|
||||
return hash;
|
||||
@@ -56,8 +58,10 @@ function pacmanVersionPlugin(): Plugin {
|
||||
|
||||
return {
|
||||
name: 'pacman-version',
|
||||
|
||||
config(_, { mode }) {
|
||||
const version = getVersion(mode);
|
||||
|
||||
console.log(`[pacman-version] Using version: ${version}`);
|
||||
|
||||
return {
|
||||
@@ -70,10 +74,16 @@ function pacmanVersionPlugin(): Plugin {
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [fontSubsetPlugin(fontConfig), pacmanVersionPlugin(), sveltekit(), tailwindcss()],
|
||||
build: {
|
||||
target: 'es2022'
|
||||
},
|
||||
plugins: [
|
||||
fontSubsetPlugin(fontConfig),
|
||||
pacmanVersionPlugin(),
|
||||
sveltekit(),
|
||||
tailwindcss(),
|
||||
devtoolsJson()
|
||||
],
|
||||
|
||||
build: { target: 'es2022' },
|
||||
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
@@ -81,5 +91,39 @@ export default defineConfig({
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
test: {
|
||||
expect: { requireAssertions: true },
|
||||
|
||||
projects: [
|
||||
{
|
||||
extends: './vite.config.ts',
|
||||
|
||||
test: {
|
||||
name: 'client',
|
||||
|
||||
browser: {
|
||||
enabled: true,
|
||||
provider: playwright(),
|
||||
instances: [{ browser: 'chromium', headless: true }]
|
||||
},
|
||||
|
||||
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
|
||||
exclude: ['src/lib/server/**']
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
extends: './vite.config.ts',
|
||||
|
||||
test: {
|
||||
name: 'server',
|
||||
environment: 'node',
|
||||
include: ['src/**/*.{test,spec}.{js,ts}'],
|
||||
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user