Skip to content

Refactor Editor component to eliminate ESLint config overrides #333

@coderabbitai

Description

@coderabbitai

Description

The src/components/Editor/index.tsx file currently requires ESLint config overrides to bypass code complexity limits:

  • max-lines: ["error", 400] (increased from 350)
  • max-lines-per-function: ["error", 180]
  • max-statements: ["error", 25]

These overrides indicate that the Editor component has grown too large and complex, making it difficult to maintain and understand.

Proposed Solution

Refactor the Editor component by:

  1. Extract utility functions: Move standalone functions like getSelectedLogEventNum, handleCopyLogEventAction, handleToggleWordWrapAction, and handleEditorCustomAction to separate utility files
  2. Create smaller sub-components: Break down the main Editor component into focused sub-components (e.g., EditorActions, EditorDecorations, etc.)
  3. Custom hooks: Extract complex useEffect logic into custom hooks for better separation of concerns
  4. Separate constants: Move configuration and constants to dedicated files

Benefits

  • Improved code maintainability and readability
  • Better testability with smaller, focused units
  • Elimination of ESLint overrides
  • Enhanced developer experience

Context

Referenced from PR #305 and comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions