update loose files and add vitest

This commit is contained in:
meepen 2024-03-28 16:07:58 -04:00
parent ff7258d9b6
commit 0d8f9b85ef
11 changed files with 1963 additions and 41 deletions

View File

@ -1,6 +0,0 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
index.html
.eslintrc.cjs

17
.eslintrc Normal file
View File

@ -0,0 +1,17 @@
{
"env": {
"browser": true,
"es2021": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"overrides": [
{
"files": ["src/**/*.ts"],
"extends": "eslint:recommended"
}
],
"rules": {}
}

View File

@ -1,13 +0,0 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: 'eslint:recommended',
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {},
}

2
.gitignore vendored
View File

@ -32,3 +32,5 @@ public/images/pokemon/icons/input/output/*
public/images/character/*/ public/images/character/*/
src/data/battle-anim-raw-data*.ts src/data/battle-anim-raw-data*.ts
src/data/battle-anim-data.ts src/data/battle-anim-data.ts
src/**/*.js

View File

@ -1,11 +0,0 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"resolveJsonModule": true,
"checkJs": true,
"esModuleInterop": true,
"strictNullChecks": false
}
}

1887
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,17 +6,20 @@
"scripts": { "scripts": {
"start": "vite", "start": "vite",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview",
"test": "vitest"
}, },
"devDependencies": { "devDependencies": {
"axios": "^1.6.2", "axios": "^1.6.2",
"axios-cache-interceptor": "^1.3.2", "axios-cache-interceptor": "^1.3.2",
"eslint": "^8.25.0", "eslint": "^8.25.0",
"happy-dom": "^14.3.9",
"json-beautify": "^1.1.1", "json-beautify": "^1.1.1",
"pokenode-ts": "^1.20.0", "pokenode-ts": "^1.20.0",
"typescript": "^5.0.3", "typescript": "^5.0.3",
"vite": "^4.5.0", "vite": "^4.5.0",
"vite-plugin-fs": "^0.4.4" "vite-plugin-fs": "^0.4.4",
"vitest": "^1.4.0"
}, },
"dependencies": { "dependencies": {
"@material/material-color-utilities": "^0.2.7", "@material/material-color-utilities": "^0.2.7",
@ -24,5 +27,12 @@
"json-stable-stringify": "^1.1.0", "json-stable-stringify": "^1.1.0",
"phaser": "^3.70.0", "phaser": "^3.70.0",
"phaser3-rex-plugins": "^1.1.84" "phaser3-rex-plugins": "^1.1.84"
},
"engines": {
"node": ">=18.0.0"
},
"imports": {
"#app": "./src/main.js",
"#app/*": "./src/*"
} }
} }

11
src/utils.test.ts Normal file
View File

@ -0,0 +1,11 @@
import { expect, describe, it } from "vitest";
import { randomString } from "./utils";
describe("utils", () => {
describe("randomString", () => {
it("should return a string of the specified length", () => {
const str = randomString(10);
expect(str.length).toBe(10);
});
});
});

19
tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"strictNullChecks": false,
"sourceMap": true,
"rootDir": "./src",
"baseUrl": "./src",
"paths": {
"#app/*": ["*.ts"],
"#app": ["."]
},
"outDir": "./build",
"noEmit": true
}
}

View File

@ -8,10 +8,11 @@ export default defineConfig(({ mode }) => {
clearScreen: false, clearScreen: false,
build: { build: {
minify: 'esbuild', minify: 'esbuild',
sourcemap: true
}, },
esbuild: { esbuild: {
pure: mode === 'production' ? [ 'console.log' ] : [], pure: mode === 'production' ? [ 'console.log' ] : [],
keepNames: true, keepNames: true,
} },
} }
}) })

21
vitest.config.js Normal file
View File

@ -0,0 +1,21 @@
import { defineConfig } from 'vite';
// import fs from 'vite-plugin-fs';
export default defineConfig(({ mode }) => {
return {
test: {
environment: 'happy-dom',
},
plugins: [/*fs()*/],
server: { host: '0.0.0.0', port: 8000 },
clearScreen: false,
build: {
minify: 'esbuild',
sourcemap: true
},
esbuild: {
pure: mode === 'production' ? [ 'console.log' ] : [],
keepNames: true,
},
}
})