I am trying to debug a eslint rule through console.log but it's not the most efficient way to debug. I am running eslint through command line.
How can I run eslint so that I can attach a debugger (either VSCode debugger or Chrome debugger) to it? I see I can pass a debug url to VSCode, but I don't know how to get the url.
I found this question which points to http://eslint.org/docs/developer-guide/development, but I get a page not found and I've tried looking for debug/debugger/development/inspector, but didn't find anything in the docs.
Running eslint is running a NodeJS script so you can run node with --inspect switch.
eslint script (likely node_modules/.bin/eslint)node --inspect-brk {eslint_path} {file_path}For example : node --inspect-brk node_modules/.bin/eslint .
Debugger listening on {url}, this is your debug url.chrome://inspect in the url barnode_modules/.bin/eslint ... under "Remote targets"

Set up (only needs to be done once)
Click on "Run and Debug" on the left
This step depends if you already configured your launch.js file.
Choose "Node.js: Attach".
Name your configuration
Attach debugger
Go to "Run and Debug" and click on the green triangle next to your configuration name.
We use --inspect-brk in order to stop the execution right away, otherwise the execution will likely be done by the time you attach your debugging client. If you already added a debugger instruction in your code, then you can run --inspect and it will stop at the first debugger instruction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With