Skip to content

feat: add codemod for DEP0159 ERR_INVALID_CALLBACK replacement#417

Open
syhstanley wants to merge 2 commits intonodejs:mainfrom
syhstanley:feat/err-invalid-callback-codemod
Open

feat: add codemod for DEP0159 ERR_INVALID_CALLBACK replacement#417
syhstanley wants to merge 2 commits intonodejs:mainfrom
syhstanley:feat/err-invalid-callback-codemod

Conversation

@syhstanley
Copy link
Copy Markdown

Summary

Adds a codemod for DEP0159 — replaces the deprecated ERR_INVALID_CALLBACK error code with ERR_INVALID_ARG_TYPE.

  • Replaces all string literal occurrences of ERR_INVALID_CALLBACK with ERR_INVALID_ARG_TYPE
  • Handles error code comparisons (err.code === "ERR_INVALID_CALLBACK")
  • Handles switch case labels, assert.throws expectations, .includes() checks
  • Deduplicates redundant || conditions after replacement (e.g., a === "X" || a === "X"a === "X")
  • No-change behavior when file has no references to the deprecated code

Test plan

  • 6 test cases covering all examples from ERR_INVALID_CALLBACK error code #411
  • Error code comparison in catch block
  • Test assertion with error code
  • Switch statement with error codes
  • String includes check
  • Duplicate condition deduplication
  • No-change test (no ERR_INVALID_CALLBACK references)

Closes #411

🤖 Generated with Claude Code

stanleyshen2003 and others added 2 commits March 30, 2026 03:46
…ement

Replace deprecated ERR_INVALID_CALLBACK with ERR_INVALID_ARG_TYPE
in string literals. Handles error code comparisons, switch cases,
test assertions, and string includes checks. Also deduplicates
redundant || conditions that arise after replacement.

Closes nodejs#411

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add missing README.md (required per CONTRIBUTING.md)
- Add yaml-language-server schema comment to workflow.yaml
- Sort include file patterns alphabetically
- Rename Js type alias to JS (codebase convention)
- Reorder imports alphabetically (Edit, SgRoot)
- Tighten deduplication regex: use [\w.[\]"']+ instead of \S+
- Add single-quote test case (file-7.js)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERR_INVALID_CALLBACK error code

3 participants