diff --git a/src/docs/contribute/debugging.md b/src/docs/contribute/debugging.md index fd2e6e23bb..6229f7b3bd 100644 --- a/src/docs/contribute/debugging.md +++ b/src/docs/contribute/debugging.md @@ -44,3 +44,36 @@ According to their [debugging guide](https://github.com/microsoft/TypeScript/blo - while debugging, tsc will evaluate global `.d.ts` files before the targeted test file - `Debug.formatXXX(value)` from `src/compiler/debug.ts` can be used to print out enum values - use the "WATCH" section to "see" value of interest + +## Debug Linter in VSCode + +It's easy to debug Linter for a npm project somewhere else with [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb). + +In `.vscode/launch.json`, change config fields to your need: + +- `cwd`: absolute path to the npm project +- `args`: arguments passed to linter + +```json +{ + "type": "lldb", + "request": "launch", + "name": "Debug Oxlint", + "cargo": { + "env": { + "RUSTFLAGS": "-g" + }, + "args": ["build", "--bin=oxlint", "--package=oxlint"], + "filter": { + "name": "oxlint", + "kind": "bin" + } + }, + "cwd": "PATH-TO-TEST-PROJECT", // [!code focus] + "args": ["--ARGS-TO-OXLINT"] // [!code focus] +} +``` + +Open VS Code Debugging panel and select `Debug Oxlint`, then start debugging. + +The debug process will be launched with specified `cwd`, like running linter in testing project and attaching debugger into it.