refactor: share API reference tracking across rules - #2193
Merged
Merged
Conversation
elecmonkey
approved these changes
Sep 17, 2026
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.
Motivation
Node API rules and
unicorn/no-document-cookieimplement overlapping alias, destructuring and property traversal. Keeping both implementations makes future rule ports repeat scope and JavaScript evaluation logic.The extraction also exposed a Node false negative:
({require} = globalThis); require('fs')bypassesnode/no-restricted-require, and({Buffer} = globalThis); new Buffer()bypassesnode/no-deprecated-api. A shorthand assignment's property symbol was incorrectly treated as a variable binding.Changes
internal/utils/referencetracker, reusingRuleContext.Refs, the cached reference index, tsgo binding helpers and the existing static evaluator. Migrate Node's adapter andunicorn/no-document-cookie; keep module loading, builtin aliases and strict/legacy ESM policies in Node.StaticStringEvaluator. Reference tracking retains upstream's no-scope key evaluation; existing literal-only helpers keep their contracts.Validation passed:
go test ./internal/utils -run '^TestStaticStringEvaluatorPropertyNames$'go test ./internal/utils/referencetracker ./internal/plugins/node/rules/no_deprecated_api ./internal/plugins/node/rules/no_restricted_require ./internal/plugins/node/rules/no_extraneous_require ./internal/plugins/node/rules/no_path_concat ./internal/plugins/unicorn/rules/no_document_cookiegolangci-lint run --new-from-merge-base=origin/main ./internal/utils ./internal/utils/referencetracker ./internal/plugins/node/nodeutil ./internal/plugins/node/rules/no_deprecated_api ./internal/plugins/node/rules/no_restricted_require ./internal/plugins/node/rules/no_extraneous_require ./internal/plugins/node/rules/no_path_concat ./internal/plugins/unicorn/rules/no_document_cookie: 0 issues.pnpm run check-spellwith all 15 changed paths explicitly supplied, including.agents/;pnpm run format:checkpassed.Validation is scoped to the affected Go consumers and native CLI behavior; whole-repository suites and JS integration suites were not run.