tplink-smarthome-api icon indicating copy to clipboard operation
tplink-smarthome-api copied to clipboard

Add instrumentation for smooth debugging under VSCode

Open iva2k opened this issue 3 years ago • 3 comments

  1. eslint and prettier '--fix' applied to lib/ files (so when debugging js in VSCode, lint errors don't obstruct code editor)
  2. disable eslint rules for lib/*.js/.ts files that tsc produces and can't change
  3. package.json scripts to facilitate debugging: build-debug, debug-js, debug-ts, and supporting: format, format-lib, lint-lib, prettier-lib
  4. vscode launch configurations (direct command and 'npm run debug-js/ts')
  5. vscode relevant extensions recommendations
  6. README details for VSCode use
  7. Add VSCode setting debug.javascript.autoAttachFilter=smart for debugger Auto-Attach

iva2k avatar Mar 31 '21 19:03 iva2k

Codecov Report

Merging #123 (366c5df) into master (b73d680) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #123   +/-   ##
=======================================
  Coverage   75.83%   75.83%           
=======================================
  Files          25       25           
  Lines        1349     1349           
  Branches      306      306           
=======================================
  Hits         1023     1023           
  Misses        250      250           
  Partials       76       76           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b73d680...366c5df. Read the comment docs.

codecov[bot] avatar Mar 31 '21 19:03 codecov[bot]

Thanks for the contribution, I have some feedback:

  1. I don't see the benefit of linting and formatting /lib/
  2. Does the debug-ts script you have work? I would think that would need ts-node and not node to run. Also all the scripts added have an IP address hardcoded. I did just add a cli run-script in 947ef38 for at least that part

plasticrake avatar Apr 05 '21 18:04 plasticrake

@plasticrake - thanks for quick response,

  1. I don't see the benefit of linting and formatting /lib/

It helps when needed to look into generated JS code. WIthout this fix, VSCode paints red all over the the JS files (hundreds of errors), hard to see the code. The way this PR has it, it stays away from the build, only when build-debug script is called, then it will prettier and lint-fix /lib/, then VSCode has it clean.

  1. Does the debug-ts script you have work? I would think that would need ts-node and not node to run. ...

Yes, it does, and it is very quick run, instead of waiting for build to finish. I prefer to debug ts, much faster. I have ts-node globally installed. It does make sense to add it to dev dependencies. Shall I amend the PR?

  1. ... Also all the scripts added have an IP address hardcoded. I did just add a cli run-script in 947ef38 for at least that part

Yes, I inserted one of the mock devices into debug scripts as an example. Perhaps it's better to make it an environment variable, but I did not explore how well it works across platforms. As I can imagine anyone debugging the code would want to use their real device, but obviously it is different IP addr for everyone. I'm thinking having a "check-ip-set" script that will bark if env variable is not set, and then use it as pre-condition in each debug script. If interested, I can amend the PR.

iva2k avatar Apr 05 '21 22:04 iva2k