A Terminal User Interface (TUI) Calculator application built with Ink (React for CLIs) and TypeScript.
- Interactive terminal-based calculator interface
- Built with React-like components using Ink
- TypeScript for type safety
- Multiple calculation modes (sum, subtract, multiply, divide)
- Division by zero error handling
- Live result updates as you type (no need to press "continue")
- Clean, responsive terminal UI
- Multi-language support (English, Español, Français) with persistent preference
The calculator supports multiple languages:
- English (default)
- Español (Spanish)
- Français (French)
Press Ctrl+L anywhere in the app to open the language selector modal. Use ↑/↓ to choose a language, Enter to confirm, Esc to cancel.
Your preference is saved to ~/.calculator/config.json and persists across sessions.
src/
├── App.tsx # Main application component (rendering only)
├── index.tsx # Entry point (renders App)
├── components/
│ └── LanguageSelector.tsx # Language selector modal overlay
├── hooks/
│ ├── useAppInput.ts # Custom hook with state and input handling
│ └── useLanguage.ts # Language state, Ctrl+L handler, selector logic
├── locales/
│ ├── index.ts # Translation loader and t() helper
│ ├── en.json # English translations
│ ├── es.json # Spanish translations
│ └── fr.json # French translations
└── utils/
├── calculator.ts # Calculation logic
└── config.ts # Config file read/write (~/.calculator/config.json)
npm run build # Compile TypeScript to dist/
npm run start # Run the compiled app
npm run dev # Build and run in one commandnpm run lint # Run ESLint on src/
npm run format # Format code with Prettiernpm run test # Run tests in watch mode
npm run test:run # Run tests once
npm run test:coverage # Run with coverage reportTests are located in src/utils/__tests__/ and use Vitest with happy-dom.
npm run dist # Build all binaries (Linux, Windows, macOS)
npm run build:linux # Linux x64
npm run build:win # Windows x64
npm run build:mac # macOS ARMBinaries are created in dist/:
calculator-linux- Linux executablecalculator.exe- Windows executablecalculator-macos- macOS executable (ARM)
These are portable, standalone executables (no installation required).
- Target: ES2020
- JSX: react
- Strict mode: enabled
- Module resolution: bundler
- Semicolons: Yes
- Single quotes: Yes
- Tab width: 2 spaces
- Trailing commas: es5 style
Run npm run format before committing.
- React JSX scope: disabled (use JSX without importing React)
- No unused variables (errors)
- TypeScript recommended rules enabled
- React hooks rules enabled
- React imports
- External libraries (ink)
- Internal imports (if any)
- Type definitions
- Files: PascalCase for components (
App.tsx,Calculator.tsx) - Variables & Functions: camelCase (
goToMenu,calculateResult) - Components: PascalCase (
App,Menu) - Interfaces: PascalCase with descriptive names (
AppState,KeyInput) - Constants: UPPER_SNAKE_CASE for true constants, camelCase for configuration objects
The project uses Husky with lint-staged. On every git commit:
- ESLint runs on staged
.tsand.tsxfiles - Prettier formats staged files
- If either fails, the commit is blocked
Always run npm run lint and npm run format before committing, or let the pre-commit hook handle it automatically.
- Designed for Node.js 18+
- Current development: Node 24
- ink
- react
- react-dom
- react-devtools-core
- typescript
- eslint
- prettier
- husky
- lint-staged