refactor(eslint-plugin-query): remove unused ast-utils helpers#11115
Open
electrohyun wants to merge 2 commits into
Open
refactor(eslint-plugin-query): remove unused ast-utils helpers#11115electrohyun wants to merge 2 commits into
electrohyun wants to merge 2 commits into
Conversation
Remove five unused helpers from the ASTUtils object in ast-utils.ts: getNestedIdentifiers, getNestedReturnStatements, getClosestVariableDeclarator, mapKeyNodeToText and mapKeyNodeToBaseText. None are referenced by any rule or other module, and ASTUtils is not part of the package's public API (it is not exported from index.ts). knip does not flag them because ASTUtils is exported as a single object, so member-level dead code slips past it. All 1709 tests pass and ast-utils.ts line coverage rises from 41% to 95%.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughFive unused internal ChangesAST utilities cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
TL;DR: the
ASTUtilsobject has five unused helpers. Removing them drops 194 lines, and all 1,709 tests still pass.Hello, I came across this while running test coverage on
@tanstack/eslint-plugin-query: the filesrc/utils/ast-utils.tssits far below the rest of the package (41% line coverage vs. a ~83% package average):To see why, I traced every
ASTUtils.<member>reference acrosssrc/, matching each against the member's own definition range so that self-recursive calls don't count as usage. Five members turned out to be dead code (see the References column below).ASTUtilsis not exported fromsrc/index.ts, and theexportsfield inpackage.jsononly exposes"."and"./package.json", so these members aren't reachable as public API.ASTUtilsis exported as a single object, and per knip's docs knip does not yet detect unused members of objects (only of enums and classes), which is why this was never surfaced.Removed helpers
getNestedIdentifiersIdentifiernode nested within a nodegetNestedReturnStatementsReturnStatementnode within a nodegetClosestVariableDeclaratorVariableDeclaratormapKeyNodeToBaseText?.) and non-null (!) operators frommapKeyNodeToText's resultmapKeyNodeToTextmapKeyNodeToBaseText, so unused once that is removedThis removes 194 lines. All 1,709 tests still pass, which confirms nothing was using this code. Line coverage of
ast-utils.tsthen rises from 41% -> 95% (package: 83% -> 93%) as a side effect of dropping code that was never covered.If any of these helpers were intentionally kept for use in upcoming rules, please let me know. In that case I'm happy to switch this PR from removing them to adding test coverage for them instead.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
I added a
patchchangeset because previous internal-code removals (#10082, #10574) included one. If you consider this purely internal and prefer no release, let me know and I'll drop it.Summary by CodeRabbit