Class components#1
Conversation
… Search Functionality with Local Storage
Elena-lucky
left a comment
There was a problem hiding this comment.
Perfect work! There are some suggestions for improvements, but most of them are minor. Keep it up!
There was a problem hiding this comment.
Your config is modern (flat config + TypeScript + React), which is great)
But it is too lightweight and misses many important rules that are standard in real production projects.
Below is a list of what should be added and why it matters.
- Import rules (project structure & maintainability)
You are missing eslint-plugin-import, which is critical.
Add:
import/order
import/no-cycle
import/prefer-default-export (optional)
disable import/extensions
Why:
Prevents circular dependencies
Keeps imports clean and predictable
Enforces consistent module structure
2. Strict TypeScript rules (code safety)
Add:
@typescript-eslint/consistent-type-imports
@typescript-eslint/consistent-type-exports
@typescript-eslint/explicit-function-return-type
@typescript-eslint/no-explicit-any
@typescript-eslint/no-non-null-assertion
@typescript-eslint/no-inferrable-types
Why:
Enforces strong typing discipline
Prevents hidden runtime errors
Makes code easier to refactor and scale
3. Unused variables handling (real-world standard)
Add:
@typescript-eslint/no-unused-vars with _ ignore pattern
Why:
Avoids noise from unused variables
Keeps flexibility for intentionally unused params (e.g. _event)
4. Safety rules (production readiness)
Add:
no-console (allow only warn and error)
no-debugger
curly
no-param-reassign
prefer-const
Why:
Prevents accidental debug code in production
Avoids subtle bugs
Encourages predictable code behavior
- Architectural constraints (very important)
Add:
max-lines-per-function
Why:
Prevents overly large components/functions
Encourages better separation of concerns
6. Type-aware linting (critical missing piece)
Update your config:
ecmaVersion: 'latest'
add parserOptions.project: './tsconfig.json'
Why:
Enables full TypeScript type-aware rules
Without this, many rules don’t work correctly
- Ignore patterns
Add:
node_modules
Why:
Avoid unnecessary linting of dependencies
These are strict (even "hardcore") rules, especially for a learning project.
You may feel that:
they slow you down
they are too restrictive
That’s normal.
But:
Learning to work with strict rules early = much faster growth as a developer.
| componentDidCatch(error: Error) { | ||
| console.error(error); | ||
| } |
There was a problem hiding this comment.
componentDidCatch should include errorInfo
Please, fix
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void { console.error(error, errorInfo.componentStack); }
errorInfo.componentStack is extremely useful for debugging
This is the standard React API usage
| static getDerivedStateFromError() { | ||
| return { isError: true }; | ||
| } |
There was a problem hiding this comment.
Missing explicit return type
Missing error argument
| static getDerivedStateFromError() { | |
| return { isError: true }; | |
| } | |
| static getDerivedStateFromError(_error: Error): ErrorBoundaryState) { | |
| return { isError: true }; | |
| } |
| }); | ||
| }; | ||
|
|
||
| #onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { |
There was a problem hiding this comment.
onKeyDown is attached to a div. Should be React.KeyboardEvent.
| import { KEYBOARD_KEYS } from '../consts/keyboard-keys.const.ts'; | ||
|
|
||
| export interface ErrorBoundaryState { | ||
| isError: boolean; |
There was a problem hiding this comment.
Minor improvement. May be, it's better to name hasError. It matches React docs convention.
feat: add coverage and new tests to error boundary
Pull Request Description
1. Task: React project setup. Class components. Error boundary
2. Screenshot:
3. Deployment: N/A
4. Done 28.04.2026 / deadline 05.05.2026
5. Score: ? / 100
Functional Requirements (100 / 100)
Technical Requirements Check
anyor@ts-ignoreused.class-componentsbranch.Implementation Details