Skip to content

JS-2020 Fix S3735 false positives on voided member calls#7489

Draft
erwan-leforestier-sonarsource wants to merge 2 commits into
masterfrom
fix/js-2020-allow-voided-promise-calls
Draft

JS-2020 Fix S3735 false positives on voided member calls#7489
erwan-leforestier-sonarsource wants to merge 2 commits into
masterfrom
fix/js-2020-allow-voided-promise-calls

Conversation

@erwan-leforestier-sonarsource

Copy link
Copy Markdown
Contributor

Summary

This fixes S3735 false positives on untyped member calls such as void this.load(), which currently conflict with @typescript-eslint/no-floating-promises when type information is unavailable.

Changes

  • broadened the no-type-info fallback so member calls and optionally chained calls are treated like other voided call expressions
  • kept typed member calls precise while failing open only when the resolved call type is indeterminate
  • added rule tests for untyped member calls, optional chaining, indeterminate typed calls, and preserved non-promise reports

Functional Validation

Artifact: JS-2020-fv.zip

Once the file is attached to the PR description, unzip and run:
./run.sh

Expected output:

******************* MASTER *******************
Analyzing "sample.jsx"...
Results:
    - Rule "S3735" -> L.10
    - Rule "S3735" -> L.11

****** Branch "fix/js-2020-allow-voided-promise-calls" ******
Analyzing "sample.jsx"...
Results:
    - Rule "S3735" -> L.11

⚠️⚠️ This is not ready for review ⚠️⚠️

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jul 7, 2026

Copy link
Copy Markdown

JS-2020

Comment thread packages/analysis/src/jsts/rules/S3735/rule.ts
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Ruling Report

Code no longer flagged (2 issues)

S3735

eigen/src/palette/organisms/screenStructure/Screen.tsx:74

    72 | 
    73 |   useEffect(
>   74 |     () => void setOptions({ handleTopSafeArea: header === "none" || header === "floating" }),
    75 |     [header]
    76 |   )

eigen/src/palette/organisms/screenStructure/Screen.tsx:234

   232 |       left={0}
   233 |       right={0}
>  234 |       onLayout={(evt) => void setOptions({ bottomViewHeight: evt.nativeEvent.layout.height })}
   235 |     >
   236 |       <LinearGradient

@datadog-sonarsource

This comment has been minimized.

@gitar-bot

gitar-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Broadens the S3735 no-type-info fallback to correctly handle untyped member calls and optional chaining. Ensure the JSDoc for hasIndeterminateType is updated to accurately reflect the check for unresolved error types.

✅ 1 resolved
Quality: JSDoc mentions error type not explicitly handled

📄 packages/analysis/src/jsts/rules/S3735/rule.ts:95-104
The JSDoc for hasIndeterminateType states it returns true for any, unknown, or "an unresolved error type", but the implementation only checks ts.TypeFlags.Any | ts.TypeFlags.Unknown. There is no explicit branch for an error type. In practice this still works because TypeScript's error type carries the Any flag, so it is caught by the Any check — but the documentation implies a dedicated check that does not exist. Consider either removing the "unresolved error type" phrasing from the doc comment or adding a short note that error types are covered implicitly via the Any flag, to avoid future confusion for maintainers.

Options

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

Comment with these commands to change the behavior for this request:

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

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

sonarqube-next Bot commented Jul 8, 2026

Copy link
Copy Markdown

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