A structured JavaScript practice environment for solving LeetCode problems efficiently with ESLint, Jest, and Quokka.js.
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.
git clone https://github.com/gah-code/leetcode-practice.git
cd leetcode-practicenpm installnpx eslint --init🔹 Custom ESLint Config (eslint.config.mjs) is already set up to support Jest and Quokka.js.
Run all tests:
npm testRun tests for a specific file:
npm test problems/fetch-with-retry.test.js- Open VS Code.
- Press Cmd + Shift + X (Mac) or Ctrl + Shift + X (Windows/Linux).
- Search for "Quokka.js" and install the extension.
| 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 |
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
1️⃣ Create a New Problem File
Run the following script:
./new-problem.sh fetch-with-retryThis 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
.jsfile. - 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
npm test- Verify the solution with Jest before submitting.
- Auto-generate Jest test files when creating new problems.
- Integrate Prettier for automatic code formatting.
- Improve error handling for the
new-problem.shscript.
- 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.
✅ 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.
Feel free to contribute or open an issue if you’d like to see additional features! 🚀