chore: add TypeScript support

Added TypeScript configuration for Vite and Node (tsconfig.app.json and
tsconfig.node.json, referenced in tsconfig.json).
Vite configuration was migrated to TypeScript.
Added ESLint TypeScript rules and general ESLint TypeScript
configuration.
Npm scripts for type checking have been added and build script has been
updated to run type checking script before building.
This commit is contained in:
jakob.scheid committed 2026-10-25 02:36:10 +02:00
1 parent 7cb1c2a403
commit 3c9fd3052f
7 files changed
+141 -23

No files matched your search

-1
View File
@@ -1,3 +1,2 @@
.gitea/ .gitea/
.github/ .github/
eslint.config.js
+61 -18
View File
@@ -1,37 +1,23 @@
import js from '@eslint/js'; import js from '@eslint/js';
import { defineConfig } from 'eslint/config'; import { defineConfig } from 'eslint/config';
import pluginVue from 'eslint-plugin-vue'; import pluginVue from 'eslint-plugin-vue';
import tseslint from 'typescript-eslint';
import vueParser from 'vue-eslint-parser';
import globals from 'globals'; import globals from 'globals';
export default defineConfig([ const commonRules = {
{ 'eqeqeq': 'error', // prettier-ignore
files: ['**/*.{js,mjs,cjs,vue}'],
plugins: { js },
extends: ['js/recommended'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
'eqeqeq': 'error',
'no-unused-vars': 'error',
'no-undef': 'error',
'prefer-const': 'error', 'prefer-const': 'error',
'no-var': 'error', 'no-var': 'error',
'no-duplicate-imports': 'error', 'no-duplicate-imports': 'error',
'no-import-assign': 'error', 'no-import-assign': 'error',
'no-empty-function': 'error',
'default-param-last': 'error',
'prefer-arrow-callback': 'error', 'prefer-arrow-callback': 'error',
'require-await': 'warn', 'require-await': 'warn',
'no-async-promise-executor': 'error', 'no-async-promise-executor': 'error',
'no-unreachable': 'error', 'no-unreachable': 'error',
'no-constant-condition': 'error', 'no-constant-condition': 'error',
'no-debugger': 'error', 'no-debugger': 'error',
@@ -44,7 +30,64 @@ export default defineConfig([
'object-shorthand': 'error', 'object-shorthand': 'error',
'prefer-template': 'error', 'prefer-template': 'error',
};
export default defineConfig([
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts,vue}'],
plugins: { js },
extends: ['js/recommended'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
}, },
}, },
rules: commonRules,
},
pluginVue.configs['flat/essential'], pluginVue.configs['flat/essential'],
{
files: ['**/*.{js,mjs,cjs}'],
rules: {
'no-unused-vars': 'error',
'no-undef': 'error',
'no-empty-function': 'error',
'default-param-last': 'error',
},
},
{
files: ['**/*.{ts,mts,cts,vue}'],
extends: [tseslint.configs.recommended],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
'no-undef': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
},
},
{
files: ['**/*.vue'],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tseslint.parser,
extraFileExtensions: ['.vue'],
},
},
},
]); ]);
+3 -1
View File
@@ -5,8 +5,10 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "npm run type-check && vite build",
"preview": "vite preview", "preview": "vite preview",
"type-check": "vue-tsc --noEmit -p tsconfig.app.json && tsc --noEmit -p tsconfig.node.json",
"type-check:watch": "vue-tsc --noEmit -p tsconfig.app.json --watch",
"test": "vitest", "test": "vitest",
"test:run": "vitest run", "test:run": "vitest run",
"lint": "eslint .", "lint": "eslint .",
+32
View File
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"noEmit": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
"noImplicitAny": true,
"allowJs": true,
"checkJs": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"types": ["vite/client"],
"paths": {
"@/*": ["./src/*"]
},
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"useDefineForClassFields": true,
"jsx": "preserve",
"esModuleInterop": true
},
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.vue"]
}
+11
View File
@@ -0,0 +1,11 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
]
}
+31
View File
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2020",
"lib": ["ES2020"],
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"noEmit": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
"noImplicitAny": true,
"allowJs": true,
"checkJs": false,
"skipLibCheck": true,
"types": ["node"],
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
},
"include": [
"vite.config.js",
"vite.config.ts",
"vitest.config.js",
"vitest.config.ts",
"eslint.config.js",
"eslint.config.ts"
]
}
+3 -3
View File
@@ -15,8 +15,8 @@ limitations under the License.
*/ */
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import path from 'path'; import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite'; import { defineConfig } from 'vitest/config';
import { createHtmlPlugin } from 'vite-plugin-html'; import { createHtmlPlugin } from 'vite-plugin-html';
// https://vite.dev/config/ // https://vite.dev/config/
@@ -32,7 +32,7 @@ export default defineConfig({
], ],
resolve: { resolve: {
alias: { alias: {
'@': path.resolve(__dirname, './src'), '@': fileURLToPath(new URL('./src', import.meta.url)),
}, },
}, },
test: { test: {