Skip to content

JS: Enhance isDomProperty #19579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

Napalys
Copy link
Contributor

@Napalys Napalys commented May 26, 2025

This pull request improves the detection of DOM properties, aiming to reduce the number of false positives reported by the js/useless-expression query.

@github-actions github-actions bot added the JS label May 26, 2025
@Napalys Napalys marked this pull request as ready for review May 26, 2025 11:00
@Copilot Copilot AI review requested due to automatic review settings May 26, 2025 11:00
@Napalys Napalys requested a review from a team as a code owner May 26, 2025 11:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Enhance the isDomProperty predicate to detect property reads on DOM nodes (e.g., offsetHeight, clientWidth) and reduce false positives in the js/useless-expression query.

  • Extend isDomProperty to also match property names accessed via data-flow property reads.
  • Add a test case validating layout-affecting reads on DOM elements.
  • Record the change in the project’s change notes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
javascript/ql/lib/Expressions/DOMProperties.qll Extend isDomProperty predicate with a DataFlow::SourceNode branch.
javascript/ql/test/query-tests/Expressions/ExprHasNoEffect/dom.js New test verifying that reads like offsetHeight and clientWidth are side-effectful.
javascript/ql/lib/change-notes/2025-05-26-dom-property-access.md Add change note documenting the enhancement to isDomProperty.
Comments suppressed due to low confidence (1)

javascript/ql/lib/Expressions/DOMProperties.qll:14

  • [nitpick] The variable name domNode implies a DOM AST node but actually refers to a data-flow source; consider renaming it to sourceNode or propSourceNode for clearer intent.
exists(DataFlow::SourceNode domNode | isDomNode(domNode) |

@Napalys Napalys marked this pull request as draft May 27, 2025 08:53
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.

1 participant