tplink-smarthome-api
tplink-smarthome-api copied to clipboard
Add instrumentation for smooth debugging under VSCode
- eslint and prettier '--fix' applied to lib/ files (so when debugging js in VSCode, lint errors don't obstruct code editor)
- disable eslint rules for lib/*.js/.ts files that tsc produces and can't change
- package.json scripts to facilitate debugging: build-debug, debug-js, debug-ts, and supporting: format, format-lib, lint-lib, prettier-lib
- vscode launch configurations (direct command and 'npm run debug-js/ts')
- vscode relevant extensions recommendations
- README details for VSCode use
- Add VSCode setting debug.javascript.autoAttachFilter=smart for debugger Auto-Attach
Codecov Report
Merging #123 (366c5df) into master (b73d680) will not change coverage. The diff coverage is
n/a
.
@@ 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.
Thanks for the contribution, I have some feedback:
- I don't see the benefit of linting and formatting
/lib/
- Does the
debug-ts
script you have work? I would think that would needts-node
and notnode
to run. Also all the scripts added have an IP address hardcoded. I did just add acli
run-script in 947ef38 for at least that part
@plasticrake - thanks for quick response,
- 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.
- 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?
- ... 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.