Fix/typescript problems (#60)

* fix: extended typescript checking to main and fixed all typescript errors

* fix: removed unnecessary type

---------

Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
Georg Bauer
2026-03-23 18:09:37 +01:00
committed by GitHub
parent 9cf6cbaa18
commit 8ea88b67ec
69 changed files with 3690 additions and 1894 deletions

View File

@@ -1,22 +1,17 @@
import tsParser from '@typescript-eslint/parser';
import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
import i18next from 'eslint-plugin-i18next';
import tsParser from "@typescript-eslint/parser";
import tsEslintPlugin from "@typescript-eslint/eslint-plugin";
import i18next from "eslint-plugin-i18next";
export default [
{
ignores: [
'dist/**',
'coverage/**',
'drizzle/**',
'node_modules/**',
],
ignores: ["dist/**", "coverage/**", "drizzle/**", "node_modules/**"],
},
{
files: ['src/renderer/**/*.{ts,tsx}'],
files: ["src/renderer/**/*.{ts,tsx}"],
languageOptions: {
parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
ecmaVersion: "latest",
sourceType: "module",
parserOptions: {
ecmaFeatures: {
jsx: true,
@@ -24,77 +19,118 @@ export default [
},
},
plugins: {
'@typescript-eslint': tsEslintPlugin,
"@typescript-eslint": tsEslintPlugin,
i18next,
},
rules: {
'i18next/no-literal-string': ['error', {
mode: 'jsx-text-only',
'jsx-components': {
exclude: ['Trans'],
"i18next/no-literal-string": [
"error",
{
mode: "jsx-text-only",
"jsx-components": {
exclude: ["Trans"],
},
"jsx-attributes": {
exclude: [
"className",
"styleName",
"style",
"type",
"key",
"id",
"width",
"height",
"viewBox",
"d",
"fill",
"stroke",
"xmlns",
"data-testid",
"role",
"tabIndex",
"aria-hidden",
"mode",
"theme",
"lineNumbers",
"cursorStyle",
"cursorBlinking",
"value",
],
},
callees: {
exclude: [
"i18n(ext)?",
"t",
"tr",
"require",
"addEventListener",
"removeEventListener",
"postMessage",
"getElementById",
"dispatch",
"commit",
"includes",
"indexOf",
"endsWhen",
"startsWith",
],
},
words: {
exclude: [
"[0-9!-/:-@[-`{-~]+",
"[A-Z_-]+",
/^\p{Emoji}+$/u,
/^[\s\p{Emoji}\uFE0F]+$/u,
/^[\s0-9%—()\-+.]+$/,
/^[\s+ו○●⊘→←↶↷―✕✖✔❝]+$/,
/^H[1-6]$/,
/^(DB\s*→\s*File|File\s*→\s*DB)$/,
/^\/posts\/$/,
"bDS",
"[✓✗▼▶◀▲]+",
],
},
message: "i18n literal string",
},
'jsx-attributes': {
exclude: [
'className',
'styleName',
'style',
'type',
'key',
'id',
'width',
'height',
'viewBox',
'd',
'fill',
'stroke',
'xmlns',
'data-testid',
'role',
'tabIndex',
'aria-hidden',
'mode',
'theme',
'lineNumbers',
'cursorStyle',
'cursorBlinking',
'value',
],
],
},
},
{
files: ["src/main/**/*.{ts,js}"],
languageOptions: {
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
parserOptions: {
ecmaFeatures: {
jsx: false,
},
callees: {
exclude: [
'i18n(ext)?',
't',
'tr',
'require',
'addEventListener',
'removeEventListener',
'postMessage',
'getElementById',
'dispatch',
'commit',
'includes',
'indexOf',
'endsWith',
'startsWith',
],
},
words: {
exclude: [
'[0-9!-/:-@[-`{-~]+',
'[A-Z_-]+',
/^\p{Emoji}+$/u,
/^[\s\p{Emoji}\uFE0F]+$/u,
/^[\s0-9%—()\-+.]+$/,
/^[\s+ו○●⊘→←↶↷―✕✖✔❝]+$/,
/^H[1-6]$/,
/^(DB\s*→\s*File|File\s*→\s*DB)$/,
/^\/posts\/$/,
'bDS',
'[✓✗▼▶◀▲]+'
],
},
message: 'i18n literal string',
}],
project: "./tsconfig.main.json",
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
"@typescript-eslint": tsEslintPlugin,
},
rules: {
// TypeScript best practices for main process
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
// General best practices
"no-console": ["error", { allow: ["warn", "error"] }],
eqeqeq: "error",
curly: "error",
"no-var": "error",
"prefer-const": "error",
// Code style
quotes: ["error", "single"],
semi: ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
indent: ["error", 2],
},
},
];