Update leetcode extension#28432
Conversation
- added new eslint config file - updated roadmap and changelog - updated eslint version - Used hide/show stats in problem search command - Used hide/show stats preference in formatting problem - Added preference for hiding/showing stats
|
Thank you for your contribution! 🎉 🔔 @justin0u0 @xmok @doxxx93 you might want to have a look. You can use this guide to learn how to check out the Pull Request locally in order to test it. 📋 Quick checkout commandsBRANCH="ext/leetcode"
FORK_URL="https://github.com/svenhofman/raycast-extensions.git"
EXTENSION_NAME="leetcode"
REPO_NAME="raycast-extensions"
git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run devWe're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. |
Greptile SummaryThis PR adds a
Confidence Score: 4/5Safe to merge with minor fixes — the new preference feature works correctly and the ESLint upgrade is straightforward. The core feature logic (preference gating of stats display) is correct and consistent across both commands. The ESLint config deviates from the repository's required defineConfig pattern. Both problem-search.tsx and utils.ts call JSON.parse(problem.stats) without a try/catch, so a null or malformed stats field from the API would throw and crash the view — a latent risk worth addressing before merge. extensions/leetcode/eslint.config.mjs (non-standard config pattern) and extensions/leetcode/src/problem-search.tsx / src/utils.ts (unguarded JSON.parse calls) Important Files Changed
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
extensions/leetcode/eslint.config.mjs:1-3
This config uses `raycast.flat()` instead of the `defineConfig` wrapper from `eslint/config`, which is the required pattern for ESLint v9+ in this repository. Without `defineConfig`, nested arrays from config presets may not be flattened correctly across all ESLint environments.
```suggestion
import { defineConfig } from "eslint/config";
import raycast from "@raycast/eslint-config";
export default defineConfig([...raycast]);
```
### Issue 2 of 2
extensions/leetcode/src/problem-search.tsx:143
`JSON.parse(problem.stats)` is called inline without error handling. While the LeetCode API is expected to return valid JSON, a malformed or null `stats` value would throw a runtime error and crash the list render. Wrapping with optional chaining or a safe parse guard would be more defensive.
```suggestion
subtitle={showProblemStats ? (JSON.parse(problem.stats) as { acRate: string }).acRate : undefined}
```
Reviews (1): Last reviewed commit: "Update leetcode extension" | Re-trigger Greptile |
| import raycast from "@raycast/eslint-config"; | ||
|
|
||
| export default raycast.flat(); |
There was a problem hiding this comment.
This config uses
raycast.flat() instead of the defineConfig wrapper from eslint/config, which is the required pattern for ESLint v9+ in this repository. Without defineConfig, nested arrays from config presets may not be flattened correctly across all ESLint environments.
| import raycast from "@raycast/eslint-config"; | |
| export default raycast.flat(); | |
| import { defineConfig } from "eslint/config"; | |
| import raycast from "@raycast/eslint-config"; | |
| export default defineConfig([...raycast]); |
Rule Used: What: In ESLint v9+, defineConfig is exported fr... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/leetcode/eslint.config.mjs
Line: 1-3
Comment:
This config uses `raycast.flat()` instead of the `defineConfig` wrapper from `eslint/config`, which is the required pattern for ESLint v9+ in this repository. Without `defineConfig`, nested arrays from config presets may not be flattened correctly across all ESLint environments.
```suggestion
import { defineConfig } from "eslint/config";
import raycast from "@raycast/eslint-config";
export default defineConfig([...raycast]);
```
**Rule Used:** What: In ESLint v9+, `defineConfig` is exported fr... ([source](https://app.greptile.com/raycast/github/raycast/extensions/-/custom-context?memory=ded2e079-95d0-44a7-80b5-83bbe04916f5))
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| id={problem.questionFrontendId} | ||
| title={`${problem.questionFrontendId}. ${problem.title}`} | ||
| subtitle={JSON.parse(problem.stats).acRate} | ||
| subtitle={showProblemStats ? JSON.parse(problem.stats).acRate : undefined} |
There was a problem hiding this comment.
JSON.parse(problem.stats) is called inline without error handling. While the LeetCode API is expected to return valid JSON, a malformed or null stats value would throw a runtime error and crash the list render. Wrapping with optional chaining or a safe parse guard would be more defensive.
| subtitle={showProblemStats ? JSON.parse(problem.stats).acRate : undefined} | |
| subtitle={showProblemStats ? (JSON.parse(problem.stats) as { acRate: string }).acRate : undefined} |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/leetcode/src/problem-search.tsx
Line: 143
Comment:
`JSON.parse(problem.stats)` is called inline without error handling. While the LeetCode API is expected to return valid JSON, a malformed or null `stats` value would throw a runtime error and crash the list render. Wrapping with optional chaining or a safe parse guard would be more defensive.
```suggestion
subtitle={showProblemStats ? (JSON.parse(problem.stats) as { acRate: string }).acRate : undefined}
```
How can I resolve this? If you propose a fix, please make it concise.
Description
Show Problem Statspreference to toggle difficulty, likes, dislikes, and acceptance rate visibility in both the daily challenge and problem search viewsChecklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder