Skip to content

Commit 1961e60

Browse files
authored
docs(contribute): debug linter in vscode (#268)
1 parent c50b0e1 commit 1961e60

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/docs/contribute/debugging.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,36 @@ According to their [debugging guide](https://github.com/microsoft/TypeScript/blo
4444
- while debugging, tsc will evaluate global `.d.ts` files before the targeted test file
4545
- `Debug.formatXXX(value)` from `src/compiler/debug.ts` can be used to print out enum values
4646
- use the "WATCH" section to "see" value of interest
47+
48+
## Debug Linter in VSCode
49+
50+
It's easy to debug Linter for a npm project somewhere else with [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb).
51+
52+
In `.vscode/launch.json`, change config fields to your need:
53+
54+
- `cwd`: absolute path to the npm project
55+
- `args`: arguments passed to linter
56+
57+
```json
58+
{
59+
"type": "lldb",
60+
"request": "launch",
61+
"name": "Debug Oxlint",
62+
"cargo": {
63+
"env": {
64+
"RUSTFLAGS": "-g"
65+
},
66+
"args": ["build", "--bin=oxlint", "--package=oxlint"],
67+
"filter": {
68+
"name": "oxlint",
69+
"kind": "bin"
70+
}
71+
},
72+
"cwd": "PATH-TO-TEST-PROJECT", // [!code focus]
73+
"args": ["--ARGS-TO-OXLINT"] // [!code focus]
74+
}
75+
```
76+
77+
Open VS Code Debugging panel and select `Debug Oxlint`, then start debugging.
78+
79+
The debug process will be launched with specified `cwd`, like running linter in testing project and attaching debugger into it.

0 commit comments

Comments
 (0)