Skip to content

Commit

Permalink
docs(contribute): debug linter in vscode (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
1zumii authored Jan 8, 2025
1 parent c50b0e1 commit 1961e60
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/docs/contribute/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 1961e60

Please sign in to comment.