Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-07 12:25:59 +01:00
parent 1db0e94b20
commit 862a361a3d
16 changed files with 14625 additions and 3 deletions

5
.eslintignore Normal file
View File

@@ -0,0 +1,5 @@
node_modules/
dist/
.yarn/
.pnp.cjs
.env

17
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true,
es2021: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
'prettier/prettier': 'error',
},
};

74
.github/copilot-instructions.md vendored Normal file
View File

@@ -0,0 +1,74 @@
# Instrucciones para GitHub Copilot 🔧
**Resumen breve**
Quasar es una aplicación web para gestionar una biblioteca personal de videojuegos. Este repositorio está en estado inicial: contiene `package.json` y `README.md` pero no hay código fuente ni tests aún. Prioridad: configurar pruebas (Playwright), scripts útiles y prácticas de seguridad para manejar claves/API.
## Estilo de código ✅
- Mantener **CommonJS** (`type: commonjs` en `package.json`).
- Añadir ESLint + Prettier para consistencia (recomendado si se añade código).
## Build y Test 🧪
- Instalación: `yarn install` (usar Yarn/local; `packageManager` se indica en `package.json`).
- `package.json` actual tiene un `test` placeholder. Reemplazar por un runner real tras inicializar Playwright. (recomendado)
- Inicializar Playwright: `npx playwright test --init`. (recomendado)
- Instalar dependencias de navegadores: `npm run test:install` (sugerido script abajo).
- En CI: `yarn install && yarn test:install && yarn test`.
## Convenciones 🔁
- Código fuente: `src/` (recomendado).
- Tests: `tests/*.spec.(js|ts)` (recomendado).
- Preferir tests reproducibles y ejemplo básico al iniciar el proyecto. (recomendado)
## Puntos de integración 🔗
- `README.md` menciona fuentes de metadatos: **IGDB**, **Screenscraper**, **MobyGames**. Documentar qué APIs se usarán y dónde se guardan claves. (recomendado)
- Guardar tokens en variables de entorno y no en el repositorio.
## Seguridad 🔒
- `.gitignore` ya incluye `.env`**no** commitear archivos con secretos.
- Usar GitHub Secrets para credenciales en workflows. (recomendado)
## Scripts sugeridos para `package.json` (ejemplo)
```json
"scripts": {
"test": "playwright test",
"test:install": "playwright install --with-deps",
"test:ci": "playwright test --reporter=github",
"lint": "eslint . --ext .js,.ts",
"format": "prettier --write .",
"start": "node src/index.js"
}
```
> Nota: el `test` actual es `echo "Error: no test specified" && exit 1`. Reemplazarlo por `playwright test` tras inicializar tests. (recomendado)
## Pasos rápidos iniciales ▶️
1. `yarn install`
2. `node -v` (asegurar **Node >= 18**)
3. `npx playwright test --init`
4. `yarn test:install`
5. `yarn test` (validar que al menos un test ejemplo pase)
## Estado actual (modificaciones aplicadas) ✅
- Añadidos: `.eslintrc.cjs`, `.prettierrc`, `tsconfig.json`, `.eslintignore`, `.prettierignore`.
- Inicializado Playwright: `playwright.config.ts` y `tests/example.spec.ts` (TypeScript).
- Actualizados: `package.json` — scripts (`test`, `test:install`, `lint`, `format`, `start`) y `packageManager` (ahora `yarn@4.12.0`).
- Dependencias dev instaladas con Yarn: ESLint, Prettier, TypeScript, `@typescript-eslint/*` y Playwright.
- Resultado: `yarn test` pasó (3 tests) en Chromium, Firefox y WebKit.
---
¿Feedback rápido? Si quieres, puedo:
- Scaffold inicial (crear `src/`, `tests/example.spec.js`, actualizar `package.json` con scripts).
- Añadir ESLint + Prettier y sus scripts.
- Proponer un workflow de GitHub Actions para ejecutar tests en PRs.
Por favor indica si prefieres **JavaScript** o **TypeScript** para el scaffold (recomendado: JavaScript si no quieres migrar a TS ahora).

27
.gitignore vendored
View File

@@ -6,6 +6,24 @@ yarn-error.log*
pnpm-debug.log*
coverage/
# Yarn (Berry / v2+)
# Ignore Yarn caches and build artifacts but keep releases/plugins/sdks committed
.yarn/cache/
.yarn/unplugged/
.yarn/build-state.yml
.yarn/install-state.gz
.yarn/patches/
# Keep releases, plugins and sdks (commit these)
!.yarn/releases/
!.yarn/releases/*
!.yarn/plugins/
!.yarn/plugins/*
!.yarn/sdks/
!.yarn/sdks/*
# Keep the PnP files committed
!.pnp.cjs
!.pnp.loader.mjs
# Production build
/dist/
/build/
@@ -37,6 +55,15 @@ Thumbs.db
.cache/
.parcel-cache/
*.local
.node_repl_history
# Playwright artifacts
playwright-report/
test-results/
.playwright/
# TypeScript
*.tsbuildinfo
# Optional: lockfiles (uncomment to ignore)
# package-lock.json

9749
.pnp.cjs generated Executable file

File diff suppressed because one or more lines are too long

2126
.pnp.loader.mjs generated Normal file

File diff suppressed because it is too large Load Diff

4
.prettierignore Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
dist/
.yarn/
.pnp.cjs

7
.prettierrc Normal file
View File

@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"printWidth": 100,
"trailingComma": "es5"
}

942
.yarn/releases/yarn-4.12.0.cjs vendored Executable file

File diff suppressed because one or more lines are too long

1
.yarnrc.yml Normal file
View File

@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-4.12.0.cjs

22
eslint.config.cjs Normal file
View File

@@ -0,0 +1,22 @@
module.exports = [
{
ignores: ['node_modules/**', 'dist/**', '.yarn/**', '.pnp.cjs'],
},
{
files: ['**/*.{js,ts,jsx,tsx}'],
languageOptions: {
parser: require('@typescript-eslint/parser'),
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
prettier: require('eslint-plugin-prettier'),
},
rules: {
'prettier/prettier': 'error',
},
},
];

View File

@@ -4,13 +4,28 @@
"description": "Quasar es una aplicación web para al gestión de una biblioteca personal de videjuegos. Permite a los usuarios catalogar, organizar y buscar sus juegos de manera eficiente. Se pueden agregar videjuegos físicos, digitales y roms de emuladores.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "playwright test",
"test:install": "playwright install --with-deps",
"test:ci": "playwright test --reporter=github",
"lint": "eslint . --ext .js,.ts",
"format": "prettier --write .",
"start": "node src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"devDependencies": {
"@playwright/test": "^1.58.0"
}
"@eslint/eslintrc": "^3.3.3",
"@playwright/test": "^1.58.0",
"@types/node": "^25.2.1",
"@typescript-eslint/eslint-plugin": "^8.54.0",
"@typescript-eslint/parser": "^8.54.0",
"eslint": "^10.0.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.5",
"prettier": "^3.8.1",
"typescript": "^5.9.3"
},
"packageManager": "yarn@4.12.0+sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8"
}

22
playwright.config.ts Normal file
View File

@@ -0,0 +1,22 @@
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: 'tests',
timeout: 30_000,
expect: {
timeout: 5000,
},
fullyParallel: true,
reporter: 'list',
use: {
headless: true,
viewport: { width: 1280, height: 720 },
actionTimeout: 0,
ignoreHTTPSErrors: true,
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
],
});

6
tests/example.spec.ts Normal file
View File

@@ -0,0 +1,6 @@
import { test, expect } from '@playwright/test';
test('homepage has expected title', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveTitle(/Example Domain/);
});

14
tsconfig.json Normal file
View File

@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}

1591
yarn.lock Normal file

File diff suppressed because it is too large Load Diff