Skip to content

JS-1181 Support local alias escapes in S6767#7128

Open
francois-mora-sonarsource wants to merge 14 commits into
masterfrom
fix/JS-1181-single-write-variables
Open

JS-1181 Support local alias escapes in S6767#7128
francois-mora-sonarsource wants to merge 14 commits into
masterfrom
fix/JS-1181-single-write-variables

Conversation

@francois-mora-sonarsource
Copy link
Copy Markdown
Contributor

Summary

  • support local whole-props aliases and named prop aliases in the S6767 false-positive escapes
  • handle local aliases used through forwardRef callbacks and typed decorator callbacks with focused JS and TS coverage
  • keep whole-props matching binding-aware so nested shadowed props aliases do not suppress real unused-prop reports

Root Cause

S6767 only recognized direct props and this.props usage shapes, so local aliases used in whole-props forwarding, forwardRef closures, and typed decorator callbacks still raised false positives. The whole-props path also matched the literal identifier name props, which could over-suppress nested helper-local aliases instead of the component's real props binding.

Test Plan

  • npx tsx --tsconfig packages/tsconfig.test.json --test packages/analysis/src/jsts/rules/S6767/unit.test.ts packages/analysis/src/jsts/rules/S6767/unit.typescript.test.ts

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 29, 2026

JS-1181

Comment thread packages/analysis/src/jsts/rules/S6767/decorator-indirect-prop-usage.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Ruling Report

No changes to ruling expected issues in this PR

@francois-mora-sonarsource francois-mora-sonarsource marked this pull request as ready for review May 29, 2026 12:28
🤖 Generated with GitHub Actions
@sonarqube-next
Copy link
Copy Markdown

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented May 29, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Support for local whole-props and named aliases in S6767 fixes false positives in forwardRef and decorator callbacks. The duplicate collectReferences helper was consolidated into a shared implementation.

✅ 1 resolved
Quality: Duplicate collectReferences helper across two files

📄 packages/analysis/src/jsts/rules/S6767/decorator-indirect-prop-usage.ts:162-167 📄 packages/analysis/src/jsts/rules/S6767/forward-ref-indirect-prop-usage.ts:73-78
The collectReferences(scope) function is defined identically in both decorator-indirect-prop-usage.ts (line 162) and forward-ref-indirect-prop-usage.ts (line 73). Since both files already import from shared helpers and from the new prop-alias-resolution.ts module, this utility could be extracted into a shared location (e.g., prop-alias-resolution.ts or a scope helper) to avoid drift.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant