Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"env": {
"node": true,
"es2020": true
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-case-declarations": "off",
"no-empty": "off",
"no-constant-condition": "off",
"no-async-promise-executor": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/ban-types": "off"
}
}
56 changes: 25 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,39 @@ on:
pull_request:
branches: [master]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
linux:
name: Linux
runs-on: ubuntu-latest
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install Node.js modules
run: npm install

- name: Lint
run: npm run lint

- name: VSCE Packge
run: npx vsce package
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

windows:
name: Windows
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Install Node.js modules
run: npm install
- name: Typecheck
run: npm run typecheck

- name: Lint
run: npm run lint

- name: VSCE Packge
run: npx vsce package
- name: Unit tests
run: npm test

- name: Package VSIX
run: npm run package
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ typings/

# Output
out
out-test
dist
*.vsix
.vscode-test

# Mac
.DS_Store

# Local secrets (never commit cookies or tokens)
cookie.txt
.secrets/
14 changes: 12 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
.vscode/**
.vscode-test/**
out/test/**
out/**
out-test/**
test/**
src/**
dist/**/*.map
**/*.map
.gitignore
.gitattributes
.githooks/**
package-lock.json
tsconfig.json
repo-rules.json
tsconfig*.json
tslint.json
.eslintrc.json
esbuild.js
**/*.gif
ACKNOWLEDGEMENTS.md
docs
.github
scripts/**
node_modules/**
_config.yml
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ All notable changes to the "leetcode" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]
### Changed
- Replaced the bundled `vsc-leetcode-cli` with direct GraphQL/REST calls for authentication, problems, statements, solutions, tests, submissions, and favorites.
- Store cookies in `SecretStorage` and support local multi-account sessions.
- Require VS Code 1.90; removed the Node.js, `leetcode.nodePath`, and `leetcode.useWsl` requirements.
- Modernize webviews and add English/Simplified Chinese localization.

## [0.18.4]
### Added
- change graphql path
Expand Down
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,25 @@

- English Document | [中文文档](https://github.com/LeetCode-OpenSource/vscode-leetcode/blob/master/docs/README_zh-CN.md)

## ❗️ Attention ❗️- Workaround to login to LeetCode endpoint
## Login

> Note: If you are using `leetcode.cn`, you can just ignore this section.
> Note: If you are using `leetcode.cn`, switch the endpoint to `leetcode-cn` first.

Recently we observed that [the extension cannot login to leetcode.com endpoint anymore](https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478). The root cause of this issue is that leetcode.com changed its login mechanism and so far there is no ideal way to fix that issue.

Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround which can somehow mitigate this. Now you can simply click the `Sign In` button and then select `Third Party` login or `Cookie` login.

> Note: If you want to use third-party login(**Recommended**), please make sure your account has been connected to the third-party. If you want to use `Cookie` login, click [here](https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478#issuecomment-564757098) to see the steps.
Run **LeetCode: Sign in** and choose **LeetCode Cookie** (paste the `Cookie` request header from a signed-in browser session) or **Web Authorization**. Cookies are stored in VS Code `SecretStorage`, not in plain text settings.

## Requirements

- [VS Code 1.30.1+](https://code.visualstudio.com/)
- [Node.js 10+](https://nodejs.org)
> NOTE: Please make sure that `Node` is in your `PATH` environment variable. You can also use the setting `leetcode.nodePath` to specify the location of your `Node.js` executable.
- [VS Code 1.90+](https://code.visualstudio.com/)
- No Node.js installation is required; the extension calls LeetCode's HTTPS APIs directly.

## Quick Start

![demo](https://raw.githubusercontent.com/LeetCode-OpenSource/vscode-leetcode/master/docs/gifs/demo.gif)

## Features

> The bundled LeetCode CLI and Node.js dependency were removed; authentication, problems, statements, solutions, tests, and submissions use LeetCode's GraphQL/REST endpoints directly.

### Sign In/Out

<p align="center">
Expand Down Expand Up @@ -134,19 +131,17 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` |
| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`,`rust`, `scala`, `swift`, `typescript` | `N/A` |
| `leetcode.useWsl` | Specify whether to use WSL or not | `false` |
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
| `leetcode.workspaceFolder` | Specify the path of the workspace folder to store the problem files. | `""` |
| `leetcode.filePath` | Specify the relative path under the workspace and the file name to save the problem files. More details can be found [here](https://github.com/LeetCode-OpenSource/vscode-leetcode/wiki/Customize-the-Relative-Folder-and-the-File-Name-of-the-Problem-File). | |
| `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` |
| `leetcode.editor.shortcuts` | Specify the customized shortcuts in editors. Supported values are: `submit`, `test`, `star`, `solution` and `description`. | `["submit, test"]` |
| `leetcode.enableSideMode` | Specify whether `preview`, `solution` and `submission` tab should be grouped into the second editor column when solving a problem. | `true` |
| `leetcode.nodePath` | Specify the `Node.js` executable path. for example, C:\Program Files\nodejs\node.exe | `node` |
| `leetcode.showCommentDescription` | Specify whether to include the problem description in the comments | `false` |
| `leetcode.useEndpointTranslation` | Use endpoint's translation (if available) | `true` |
| `leetcode.colorizeProblems` | Add difficulty badge and colorize problems files in explorer tree | `true` |
| `leetcode.problems.sortStrategy` | Specify sorting strategy for problems list | `None` |
| `leetcode.allowReportData` | Allow LeetCode to report anonymous usage data to improve the product. list | `true` |
| `leetcode.allowReportData` | Allow LeetCode to report anonymous usage data to improve the product. list | `false` |

## Want Help?

Expand Down
21 changes: 8 additions & 13 deletions docs/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,25 @@

- [English Document](https://github.com/LeetCode-OpenSource/vscode-leetcode#requirements) | 中文文档

## ❗️ 注意 ❗️- 无法登录 LeetCode 节点的临时解决办法
## 登录

> 注意:如果使用的是 `leetcode.cn` 账户,可以跳过此段落。
> 注意:使用 `leetcode.cn` 时请先把站点切换为 `leetcode-cn`。

近期我们发现插件出现了[无法登录 leetcode.com 节点的问题](https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478)。原因是因为近期 leetcode.com 改变了登录机制,目前我们暂时没有找到解决该问题的完美解决方案。

感谢 [@yihong0618](https://github.com/yihong0618) 提供了一个临时解决办法。现在你可以直接点击登录按钮并选择第三方登录或者 `Cookie` 登录。

> 注意:如果你希望使用第三方登录(**推荐**),请确保你的账户已经与第三方账户连接。如果你希望通过 `Cookie` 登录,请点击[该连接](https://github.com/LeetCode-OpenSource/vscode-leetcode/issues/478#issuecomment-564757098)查看登录步骤。
执行 **LeetCode: Sign in**,选择 **LeetCode Cookie**(粘贴已登录浏览器里的 `Cookie` 请求头)或 **Web Authorization**。Cookie 保存在 VS Code `SecretStorage` 中,不会写入明文设置。

## 运行条件

- [VS Code 1.23.0+](https://code.visualstudio.com/)
- [Node.js 10+](https://nodejs.org)
> 注意:请确保`Node`在`PATH`环境变量中。您也可以通过设定 `leetcode.nodePath` 选项来指定 `Node.js` 可执行文件的路径。
- [VS Code 1.90+](https://code.visualstudio.com/)
- 不需要安装 Node.js;扩展直接调用 LeetCode 的 HTTPS API。

## 快速开始

![demo](https://raw.githubusercontent.com/LeetCode-OpenSource/vscode-leetcode/master/docs/gifs/demo.gif)

## 功能

> 已移除内置的 LeetCode CLI 与 Node.js 依赖;登录、题库、题干、题解、测试和提交均直接使用 LeetCode 的 GraphQL/REST 接口。

### 登入登出

<p align="center">
Expand Down Expand Up @@ -134,17 +131,15 @@
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `leetcode.hideSolved` | 指定是否要隐藏已解决的问题 | `false` |
| `leetcode.defaultLanguage` | 指定答题时使用的默认语言,可选语言有:`bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`, `rust`, `scala`, `swift`, `typescript` | `N/A` |
| `leetcode.useWsl` | 指定是否启用 WSL | `false` |
| `leetcode.endpoint` | 指定使用的终端,可用终端有:`leetcode`, `leetcode-cn` | `leetcode` |
| `leetcode.workspaceFolder` | 指定保存文件的工作区目录 | `""` |
| `leetcode.filePath` | 指定生成题目文件的相对文件夹路径名和文件名。点击查看[更多详细用法](https://github.com/LeetCode-OpenSource/vscode-leetcode/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A2%98%E7%9B%AE%E6%96%87%E4%BB%B6%E7%9A%84%E7%9B%B8%E5%AF%B9%E6%96%87%E4%BB%B6%E5%A4%B9%E8%B7%AF%E5%BE%84%E5%92%8C%E6%96%87%E4%BB%B6%E5%90%8D)。 | |
| `leetcode.enableStatusBar` | 指定是否在 VS Code 下方显示插件状态栏。 | `true` |
| `leetcode.editor.shortcuts` | 指定在编辑器内所自定义的快捷方式。可用的快捷方式有: `submit`, `test`, `star`, `solution`, `description`。 | `["submit, test"]` |
| `leetcode.enableSideMode` | 指定在解决一道题时,是否将`问题预览`、`高票答案`与`提交结果`窗口集中在编辑器的第二栏。 | `true` |
| `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。如:C:\Program Files\nodejs\node.exe | `node` |
| `leetcode.showCommentDescription` | 指定是否要在注释中显示题干。 | `false` |
| `leetcode.useEndpointTranslation` | 是否显示翻译版本内容。 | `true` |
| `leetcode.allowReportData` | 为了更好的产品体验允许上报用户埋数据 | `true` |
| `leetcode.allowReportData` | 为了更好的产品体验允许上报用户埋数据 | `false` |

## 需要帮助?

Expand Down
20 changes: 20 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const esbuild = require("esbuild");

const watch = process.argv.includes("--watch");
const options = {
entryPoints: ["src/extension.ts"],
bundle: true,
outfile: "dist/extension.js",
external: ["vscode"],
format: "cjs",
platform: "node",
target: "node18",
sourcemap: true,
logLevel: "info",
};

if (watch) {
esbuild.context(options).then((context) => context.watch());
} else {
esbuild.build(options).catch(() => process.exit(1));
}
Loading