From 4e7e3843752d3da2c5a08350eb0ee30c238a5786 Mon Sep 17 00:00:00 2001 From: JackUait Date: Fri, 7 Nov 2025 01:57:29 +0300 Subject: [PATCH] fix: lint issues in dom.ts --- .cursor/rules/do-not-modify-configs.mdc | 23 +++ .cursor/rules/fix-problems.mdc | 23 +++ .cursor/rules/src/frontend/accessibility.mdc | 119 ++++++++++++++ .../rules/src/frontend/code-style-eslint.mdc | 27 ++++ .../src/frontend/fix-typescript-errors.mdc | 22 +++ .../src/frontend/frontend-simplicity.mdc | 69 ++++++++ .../rules/src/frontend/lint-fix-policy.mdc | 24 +++ .cursor/rules/test/e2e-best-practices.mdc | 37 +++++ .eslintrc | 4 +- src/components/dom.ts | 150 ++++++++++-------- 10 files changed, 434 insertions(+), 64 deletions(-) create mode 100644 .cursor/rules/do-not-modify-configs.mdc create mode 100644 .cursor/rules/fix-problems.mdc create mode 100644 .cursor/rules/src/frontend/accessibility.mdc create mode 100644 .cursor/rules/src/frontend/code-style-eslint.mdc create mode 100644 .cursor/rules/src/frontend/fix-typescript-errors.mdc create mode 100644 .cursor/rules/src/frontend/frontend-simplicity.mdc create mode 100644 .cursor/rules/src/frontend/lint-fix-policy.mdc create mode 100644 .cursor/rules/test/e2e-best-practices.mdc diff --git a/.cursor/rules/do-not-modify-configs.mdc b/.cursor/rules/do-not-modify-configs.mdc new file mode 100644 index 00000000..bc24d21d --- /dev/null +++ b/.cursor/rules/do-not-modify-configs.mdc @@ -0,0 +1,23 @@ +--- +alwaysApply: true +--- + +# Rule: DO NOT MODIFY configuration files unless explicitly instructed + +## Description +You MUST **never modify any configuration files** (such as `vite.config.ts`, `tsconfig.json`, `.eslintrc`, `package.json`, `.env`, etc.) **unless explicitly told to do so** in the current request or accompanying instructions. + +## Examples + +✅ **Allowed** +- Editing TypeScript source files, tests, or component code. +- Updating imports, logic, or styles within non-config files. +- Adding configuration changes **only when explicitly requested** (e.g., “Add a new alias in `vite.config.ts`”). + +❌ **Not Allowed** +- Modifying or creating any config files without explicit instruction. +- Automatically adding dependencies or changing build/test settings. +- Altering environment variables or global project settings without being told to. + +## Enforcement +If you believe a configuration change might be required, **ask for confirmation first** before proceeding. diff --git a/.cursor/rules/fix-problems.mdc b/.cursor/rules/fix-problems.mdc new file mode 100644 index 00000000..2964987d --- /dev/null +++ b/.cursor/rules/fix-problems.mdc @@ -0,0 +1,23 @@ +--- +alwaysApply: true +--- + +# Fix Problems Policy + +## Core Principle +VERY IMPORTANT: When encountering ANY problem in the code—such as TypeScript errors, linting issues, runtime bugs, accessibility violations, or performance problems—you or any other problem MUST find a proper way to fix it. Do NOT silence, suppress, or avoid the problem using workarounds like `// @ts-ignore`, `any` types, or ignoring linter warnings. + +## Preferred Approaches +- **Refactor for correctness**: Resolve issues by improving the code structure, using precise types, type guards, proper error handling, and best practices. +- **Investigate root causes**: Use tools like debugging, logging, or code searches to understand why the problem occurs before fixing it. +- **Align with existing rules**: Follow related policies such as the Fix TypeScript Errors Policy (adapt for other languages), ESLint configurations, and accessibility guidelines. +- **Test the fix**: After fixing, verify with tests, linting runs (e.g., `yarn lint:fix`), or manual checks to ensure the problem is truly resolved without introducing new issues. + +## When to Apply +- During any code editing, reviewing, or generation task. +- Proactively scan for and fix problems in affected files using available tools (e.g., read_lints, grep, codebase_search). +- If a problem persists after reasonable efforts, document it clearly and suggest next steps rather than suppressing it. + +## Notes +- This policy promotes robust, high-quality code that is easier to maintain and less prone to future issues. +- If unsure how to fix a problem, use tools to gather more information or break it into smaller, solvable parts rather than bypassing it. diff --git a/.cursor/rules/src/frontend/accessibility.mdc b/.cursor/rules/src/frontend/accessibility.mdc new file mode 100644 index 00000000..085ff843 --- /dev/null +++ b/.cursor/rules/src/frontend/accessibility.mdc @@ -0,0 +1,119 @@ +--- +alwaysApply: true +description: Enforce accessibility best practices so all users can use the application +--- + +### Accessibility guidance (must follow) + +- Semantics first + - Prefer semantic HTML (`button`, `a`, `nav`, `main`, `header`, `footer`, `ul/ol/li`, `table/th/td`) over generic `div`/`span`. + - Use `button` for actions and `a`/`Link` for navigation. Do not use click handlers on non-interactive elements. If unavoidable, add `role="button"`, `tabIndex={0}`, and keyboard handlers for Enter/Space. + +- Keyboard support + - All interactive controls must be reachable via Tab and operable via keyboard. + - Do not remove focus outlines. If customizing, ensure visible `:focus-visible` styles with sufficient contrast. + - Preserve a logical tab order; avoid `tabIndex` > 0. + +- Focus management + - On opening modals/drawers/popovers: move focus inside, trap focus, and restore focus to the trigger on close. + - Provide a skip link to main content (e.g., `href="#main"`) and landmark roles (`
`, `