From 437ae2c16cced1ea0d7d1b0b341a61cf7d8de56b Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Fri, 6 Mar 2026 20:53:05 +0200 Subject: [PATCH] style: some minor style improvements --- frontend/eslint.config.js | 16 +++++++++++--- frontend/package.json | 22 +++++++++---------- frontend/src/api/client/Client.ts | 2 +- frontend/src/components/layout/AppLayout.tsx | 2 +- frontend/vite.config.ts | 14 ++++++------ src/ahriman/core/auth/auth.py | 2 +- src/ahriman/web/schemas/auth_info_schema.py | 10 +++++---- .../schemas/auto_refresh_interval_schema.py | 2 ++ src/ahriman/web/schemas/info_v2_schema.py | 1 + .../web/schemas/repository_id_schema.py | 2 +- 10 files changed, 44 insertions(+), 29 deletions(-) diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index 94c510ab..6bcbcdf2 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -27,21 +27,26 @@ export default tseslint.config( "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], // imports - "simple-import-sort/imports": "error", "simple-import-sort/exports": "error", + "simple-import-sort/imports": "error", - // brackets + // core "curly": "error", - "@stylistic/brace-style": ["error", "1tbs"], + "eqeqeq": "error", + "no-console": "error", + "no-eval": "error", // stylistic "@stylistic/array-bracket-spacing": ["error", "never"], "@stylistic/arrow-parens": ["error", "as-needed"], + "@stylistic/brace-style": ["error", "1tbs"], "@stylistic/comma-dangle": ["error", "always-multiline"], "@stylistic/comma-spacing": ["error", { before: false, after: true }], "@stylistic/eol-last": ["error", "always"], "@stylistic/indent": ["error", 4], + "@stylistic/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }], "@stylistic/jsx-quotes": ["error", "prefer-double"], + "@stylistic/jsx-self-closing-comp": ["error", { component: true, html: true }], "@stylistic/max-len": ["error", { code: 120, ignoreComments: true, @@ -49,6 +54,7 @@ export default tseslint.config( ignoreTemplateLiterals: true, ignoreUrls: true, }], + "@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "semi" } }], "@stylistic/no-extra-parens": ["error", "all"], "@stylistic/no-multi-spaces": "error", "@stylistic/no-multiple-empty-lines": ["error", { max: 1 }], @@ -58,10 +64,14 @@ export default tseslint.config( "@stylistic/semi": ["error", "always"], // typescript + "@typescript-eslint/consistent-type-definitions": ["error", "interface"], "@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports" }], "@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }], "@typescript-eslint/no-deprecated": "error", "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], + "@typescript-eslint/prefer-nullish-coalescing": "error", + "@typescript-eslint/prefer-optional-chain": "error", + "@typescript-eslint/switch-exhaustiveness-check": "error", }, }, ); diff --git a/frontend/package.json b/frontend/package.json index 3035895f..cddb5f99 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -11,30 +11,30 @@ "preview": "vite preview" }, "dependencies": { - "@emotion/react": "^11.11.0", - "@emotion/styled": "^11.11.0", - "@mui/icons-material": "^7.3.8", - "@mui/material": "^7.3.8", - "@mui/x-data-grid": "^8.27.3", - "@tanstack/react-query": "^5.0.0", - "chart.js": "^4.5.0", + "@emotion/react": "^11.14.0", + "@emotion/styled": "^11.14.1", + "@mui/icons-material": "^7.3.9", + "@mui/material": "^7.3.9", + "@mui/x-data-grid": "^8.27.4", + "@tanstack/react-query": "^5.90.21", + "chart.js": "^4.5.1", "react": "^19.2.4", - "react-chartjs-2": "^5.2.0", + "react-chartjs-2": "^5.3.1", "react-dom": "^19.2.4", "react-syntax-highlighter": "^16.1.1" }, "devDependencies": { "@eslint/js": "^9.39.3", - "@stylistic/eslint-plugin": "^5.9.0", + "@stylistic/eslint-plugin": "^5.10.0", "@types/react": "^19.2.14", "@types/react-dom": "^19.2.3", "@types/react-syntax-highlighter": "^15.5.13", - "@vitejs/plugin-react": "^5.0.0", + "@vitejs/plugin-react": "^5.1.4", "eslint": "^9.39.3", "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.5.2", "eslint-plugin-simple-import-sort": "^12.1.1", - "typescript": "^5.3.0", + "typescript": "^5.9.3", "typescript-eslint": "^8.56.1", "vite": "^7.3.1", "vite-tsconfig-paths": "^6.1.1" diff --git a/frontend/src/api/client/Client.ts b/frontend/src/api/client/Client.ts index 6ba636d7..c96be413 100644 --- a/frontend/src/api/client/Client.ts +++ b/frontend/src/api/client/Client.ts @@ -49,7 +49,7 @@ export class Client { const timeoutId = setTimeout(() => controller.abort(), timeout); const requestInit: RequestInit = { - method: method || (json ? "POST" : "GET"), + method: method ?? (json ? "POST" : "GET"), headers, signal: controller.signal, }; diff --git a/frontend/src/components/layout/AppLayout.tsx b/frontend/src/components/layout/AppLayout.tsx index 0b53caa5..38205773 100644 --- a/frontend/src/components/layout/AppLayout.tsx +++ b/frontend/src/components/layout/AppLayout.tsx @@ -52,7 +52,7 @@ export default function AppLayout(): React.JSX.Element { return - + diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 65a11cb1..61ff64e7 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,22 +1,22 @@ -import { defineConfig, type Plugin } from "vite"; import react from "@vitejs/plugin-react"; -import tsconfigPaths from "vite-tsconfig-paths"; import path from "path"; +import { defineConfig, type Plugin } from "vite"; +import tsconfigPaths from "vite-tsconfig-paths"; -function renameHtml(newName: string): Plugin { +function rename(oldName: string, newName: string): Plugin { return { - name: "rename-html", + name: "rename", enforce: "post", generateBundle(_, bundle) { - if (bundle["index.html"]) { - bundle["index.html"].fileName = newName; + if (bundle[oldName]) { + bundle[oldName].fileName = newName; } }, }; } export default defineConfig({ - plugins: [react(), tsconfigPaths(), renameHtml("build-status.jinja2")], + plugins: [react(), tsconfigPaths(), rename("index.html", "build-status.jinja2")], base: "/", build: { chunkSizeWarningLimit: 10000, diff --git a/src/ahriman/core/auth/auth.py b/src/ahriman/core/auth/auth.py index 19f78efd..4aaed2f9 100644 --- a/src/ahriman/core/auth/auth.py +++ b/src/ahriman/core/auth/auth.py @@ -58,7 +58,7 @@ class Auth(LazyLogging): Returns: str: login control as html code to insert """ - return """""" + return "" @property def is_external(self) -> bool: diff --git a/src/ahriman/web/schemas/auth_info_schema.py b/src/ahriman/web/schemas/auth_info_schema.py index 7a3de497..c1b8817b 100644 --- a/src/ahriman/web/schemas/auth_info_schema.py +++ b/src/ahriman/web/schemas/auth_info_schema.py @@ -25,9 +25,11 @@ class AuthInfoSchema(Schema): authorization information schema """ - control = fields.String(required=True, metadata={ - "description": "HTML control for login interface", - }) + control = fields.String( + metadata={ + "description": "HTML control for login interface", + "example": "", + }) enabled = fields.Boolean(required=True, metadata={ "description": "Whether authentication is enabled or not", }) @@ -35,5 +37,5 @@ class AuthInfoSchema(Schema): "description": "Whether authorization provider is external (e.g. OAuth)", }) username = fields.String(metadata={ - "description": "Currently authenticated username if any", + "description": "Currently authenticated username if available", }) diff --git a/src/ahriman/web/schemas/auto_refresh_interval_schema.py b/src/ahriman/web/schemas/auto_refresh_interval_schema.py index 83d01b86..e38e0bf1 100644 --- a/src/ahriman/web/schemas/auto_refresh_interval_schema.py +++ b/src/ahriman/web/schemas/auto_refresh_interval_schema.py @@ -27,10 +27,12 @@ class AutoRefreshIntervalSchema(Schema): interval = fields.Integer(required=True, metadata={ "description": "Auto refresh interval in milliseconds", + "example": "60000", }) is_active = fields.Boolean(required=True, metadata={ "description": "Whether this interval is the default active one", }) text = fields.String(required=True, metadata={ "description": "Human readable interval description", + "example": "1 minute", }) diff --git a/src/ahriman/web/schemas/info_v2_schema.py b/src/ahriman/web/schemas/info_v2_schema.py index ea8f7007..82eaeb00 100644 --- a/src/ahriman/web/schemas/info_v2_schema.py +++ b/src/ahriman/web/schemas/info_v2_schema.py @@ -40,6 +40,7 @@ class InfoV2Schema(Schema): }) index_url = fields.String(metadata={ "description": "URL to the repository index page", + "example": "https://ahriman.readthedocs.io/", }) repositories = fields.Nested(RepositoryIdSchema(many=True), required=True, metadata={ "description": "List of loaded repositories", diff --git a/src/ahriman/web/schemas/repository_id_schema.py b/src/ahriman/web/schemas/repository_id_schema.py index 5a0606cb..61688c9e 100644 --- a/src/ahriman/web/schemas/repository_id_schema.py +++ b/src/ahriman/web/schemas/repository_id_schema.py @@ -31,7 +31,7 @@ class RepositoryIdSchema(Schema): }) id = fields.String(metadata={ "description": "Unique repository identifier", - "example": "aur-x86_64", + "example": "x86_64-aur", }) repository = fields.String(metadata={ "description": "Repository name",