Skip to content

Conversation

@ammario
Copy link
Member

@ammario ammario commented Oct 5, 2025

Summary

Converts all relative imports (../, ../../, etc.) to absolute imports using the @/ alias across the entire codebase.

Changes

Systematically converted imports for all major directories:

  • ../types/@/types/
  • ../utils/@/utils/
  • ../services/@/services/
  • ../components/@/components/
  • ../contexts/@/contexts/
  • ../constants/@/constants/
  • ../hooks/@/hooks/
  • ../styles/@/styles/

Files affected: 22 files
Net change: 0 lines (86 insertions, 86 deletions - pure refactor)

Benefits

  • No more import path hell: Say goodbye to ../../../types/message
  • Easier refactoring: Moving files doesn't break dozens of import statements
  • Consistency: All imports follow the same @/ pattern
  • Clarity: Import paths are clearer and easier to understand
  • Maintainability: New developers can find imports more easily

Example

Before:

import type { CmuxMessage } from "../../../types/message";
import { StreamManager } from "../../services/streamManager";
import { keybinds } from "../utils/keybinds";

After:

import type { CmuxMessage } from "@/types/message";
import { StreamManager } from "@/services/streamManager";
import { keybinds } from "@/utils/keybinds";

Testing

  • bun typecheck passes
  • ✅ All imports resolve correctly
  • No functional changes, only import path updates

Notes

This builds on PR #33 which:

  • Reorganized utils/ into domain-specific subdirectories
  • Added the @/ path alias configuration

Generated with cmux

Convert all relative imports (../, ../../, etc.) to use absolute @/ imports
across the entire codebase for better maintainability and consistency.

Changes:
- Convert ../types/ → @/types/
- Convert ../utils/ → @/utils/
- Convert ../services/ → @/services/
- Convert ../components/ → @/components/
- Convert ../contexts/ → @/contexts/
- Convert ../constants/ → @/constants/
- Convert ../hooks/ → @/hooks/
- Convert ../styles/ → @/styles/

Benefits:
- No more import path hell with ../../../
- Easier refactoring - file moves don't break imports
- Consistent import style across the entire codebase
- Clearer, more maintainable code

_Generated with `cmux`_
@ammario ammario force-pushed the fix-relative-imports branch from 5e1acdb to cb85b50 Compare October 5, 2025 23:48
@ammario ammario merged commit 439b5f5 into main Oct 5, 2025
6 checks passed
@ammario ammario deleted the fix-relative-imports branch October 5, 2025 23:51
ammario added a commit that referenced this pull request Oct 6, 2025
## Summary

Adds ESLint rule that enforces absolute imports with `@/` alias for
cross-directory imports while allowing pragmatic same-directory relative
imports.

## Changes

Added `no-restricted-imports` rule to `eslint.config.mjs`:
- **Blocks**: `../*`, `../../*`, `../../../*` (parent directory imports)
- **Allows**: `./foo` (same-directory imports)  
- **Requires**: `@/types/foo` (absolute imports for cross-directory)

## Benefits

- **Prevents regression**: Can't accidentally add relative imports
- **Immediate feedback**: ESLint catches violations during development
- **CI enforcement**: Violations block PR merges
- **Pragmatic**: Allows same-directory imports for better code
organization

## Note

Does not add documentation to CLAUDE.md as ESLint enforcement makes
documentation redundant.

This rule will catch existing violations in files not yet converted to
absolute imports. Those files will need to be updated in PR #34 or
future PRs.

_Generated with `cmux`_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant