https://github.com/gah-code/leetcode-practice
A structured JavaScript practice environment for solving LeetCode problems efficiently with ESLint, Jest, and Quokka.js.
https://github.com/gah-code/leetcode-practice
exercises javascript jest leetcode
Last synced: 9 months ago
JSON representation
A structured JavaScript practice environment for solving LeetCode problems efficiently with ESLint, Jest, and Quokka.js.
- Host: GitHub
- URL: https://github.com/gah-code/leetcode-practice
- Owner: gah-code
- License: mit
- Created: 2025-02-14T07:40:19.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-02-14T08:17:22.000Z (9 months ago)
- Last Synced: 2025-02-14T08:32:13.781Z (9 months ago)
- Topics: exercises, javascript, jest, leetcode
- Language: JavaScript
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ LeetCode JavaScript Practice
A structured JavaScript practice environment for solving **LeetCode problems** efficiently with **ESLint, Jest, and Quokka.js**.
## ๐ Project Overview
This project is designed to **streamline problem-solving in JavaScript** by integrating:
- **ESLint** for code quality and best practices.
- **Jest** for testing solutions automatically.
- **Quokka.js** for real-time execution and debugging.
- **Automated script** for quickly creating new problems.
---
## ๐ ๏ธ Project Setup
### 1๏ธโฃ **Clone the Repository**
```sh
git clone https://github.com/gah-code/leetcode-practice.git
cd leetcode-practice
```
### 2๏ธโฃ **Install Dependencies**
```sh
npm install
```
### 3๏ธโฃ **Setup ESLint for Linting**
```sh
npx eslint --init
```
๐น **Custom ESLint Config** (`eslint.config.mjs`) is already set up to support Jest and Quokka.js.
---
## ๐งช Testing with Jest
Run all tests:
```sh
npm test
```
Run tests for a specific file:
```sh
npm test problems/fetch-with-retry.test.js
```
---
## โก Using Quokka.js for Live Debugging
### **Installation**
1. Open **VS Code**.
2. Press **Cmd + Shift + X** (Mac) or **Ctrl + Shift + X** (Windows/Linux).
3. Search for **"Quokka.js"** and install the extension.
### **Quokka.js Commands**
| Command | Description |
|---------|-------------|
| `Cmd + Shift + P` โ "Quokka.js: Start on Current File" | Runs Quokka in the open file |
| `Cmd + Shift + P` โ "Quokka.js: Start on Current Project" | Runs Quokka for all configured files |
| `Cmd + K Q` | Stops Quokka |
| `Cmd + Shift + P` โ "Quokka.js: Toggle Value Display" | Shows inline execution results |
---
## ๐ Folder Structure
```
leetcode-practice/
โโโ .quokka/ # Quokka.js config
โโโ problems/ # LeetCode problems
โ โโโ fetch-with-retry.js # Example problem solution
โ โโโ fetch-with-retry.test.js # Jest test for the problem
โโโ eslint.config.mjs # ESLint flat config setup
โโโ package.json # Project dependencies
โโโ problem-template.js # Template for new problems
โโโ new-problem.sh # Automation script for creating new problems
โโโ README.md # Project documentation
```
---
## ๐ Workflow: How to Add a New Problem
1๏ธโฃ **Create a New Problem File**
Run the following script:
```sh
./new-problem.sh fetch-with-retry
```
This will:
- Create a new problem file inside `problems/`
- Pre-fill the file with the standard **problem template**
- Open it automatically in **VS Code**
2๏ธโฃ **Implement the Solution**
- Write the function inside the newly created `.js` file.
- Use **Quokka.js** for real-time debugging.
3๏ธโฃ **Write Tests**
- Create a test file in `problems/` (if not generated automatically).
- Use **Jest** to write test cases.
4๏ธโฃ **Run Tests**
```sh
npm test
```
- Verify the solution with Jest before submitting.
---
## โ
To-Do List & Future Enhancements V 1.1.0
- [ ] **Auto-generate Jest test files** when creating new problems.
- [ ] **Integrate Prettier** for automatic code formatting.
- [ ] **Improve error handling** for the `new-problem.sh` script.
---
## โ
To-Do List & Future Enhancements V 1.2.0
- [ ] **Add TypeScript support** for stronger typing in solutions.
- [ ] **Implement GitHub Actions** for continuous integration.
- [ ] **Create a VS Code snippet extension** for inserting the problem template easily.
---
## ๐ Recommendations for Best Learning Experience
โ
**Follow a structured approach:** Start with an easy problem, read the description carefully, implement, and test.
โ
**Use Quokka.js:** Debug functions before running full Jest tests.
โ
**Write detailed solution approaches:** Add comments to document thought processes.
โ
**Refactor frequently:** Aim for clean, efficient, and readable code.
โ
**Keep the repo organized:** Each problem should have a corresponding test file.
---
## ๐ก Have Suggestions?
Feel free to **contribute** or open an **issue** if youโd like to see additional features! ๐
---