Skip to content

Update leetcode extension#28432

Open
svenhofman wants to merge 1 commit into
raycast:mainfrom
svenhofman:ext/leetcode
Open

Update leetcode extension#28432
svenhofman wants to merge 1 commit into
raycast:mainfrom
svenhofman:ext/leetcode

Conversation

@svenhofman
Copy link
Copy Markdown
Contributor

@svenhofman svenhofman commented May 30, 2026

Description

  • Add Show Problem Stats preference to toggle difficulty, likes, dislikes, and acceptance rate visibility in both the daily challenge and problem search views

Checklist

- 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
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: leetcode Issues related to the leetcode extension platform: macOS OP is contributor The OP of the PR is a contributor of the extension labels May 30, 2026
@raycastbot
Copy link
Copy Markdown
Collaborator

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 commands
BRANCH="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 dev

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR adds a showProblemStats checkbox preference to the LeetCode extension, toggling visibility of difficulty, likes, dislikes, and acceptance rate in both the daily challenge and problem search views. It also upgrades ESLint from v8 to v9 by replacing .eslintrc.json with a flat eslint.config.mjs.

  • New preference: showProblemStats (checkbox, default true) gates stats display via getPreferenceValues in both utils.ts and problem-search.tsx.
  • ESLint upgrade: Old .eslintrc.json removed; new eslint.config.mjs uses raycast.flat() rather than the repository-standard defineConfig([...raycast]) pattern.
  • Stats parsing: JSON.parse(problem.stats) is called without error handling in both problem-search.tsx and utils.ts; a malformed API response would cause a runtime crash.

Confidence Score: 4/5

Safe 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

Filename Overview
extensions/leetcode/eslint.config.mjs New ESLint v9 flat config using raycast.flat() instead of the required defineConfig pattern from eslint/config
extensions/leetcode/src/utils.ts Adds showProblemStats preference reading and stats rendering in formatProblemMarkdown; JSON.parse used without error handling
extensions/leetcode/src/problem-search.tsx Reads showProblemStats preference to conditionally show difficulty tag and acceptance rate subtitle; JSON.parse used without error handling for stats
extensions/leetcode/package.json Adds showProblemStats checkbox preference; bumps @raycast/eslint-config to ^2.1.1 and eslint to ^9.39.4
extensions/leetcode/CHANGELOG.md Adds changelog entry for the new Show Problem Stats preference using the required {PR_MERGE_DATE} placeholder
Prompt To Fix All With AI
Fix 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

Comment on lines +1 to +3
import raycast from "@raycast/eslint-config";

export default raycast.flat();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension fix / improvement Label for PRs with extension's fix improvements extension: leetcode Issues related to the leetcode extension OP is contributor The OP of the PR is a contributor of the extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants