Skip to content
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

[js-experimental] Add the ability to parse the '::' operator in Semgrep for javascript #4416

Closed
Jason-Lim00 opened this issue Dec 10, 2021 · 1 comment
Labels
lang:javascript lang-nonstandard-syntax a request to support syntax that's not an official feature of the language at this time. parsing Requires a fix in a parser, typically a tree-sitter or menhir grammar. priority:medium

Comments

@Jason-Lim00
Copy link

Is your feature request related to a problem? Please describe:

Semgrep currently does not support parsing for the '::' operation in javascript. An example can be found in the following error and code snippet below in the additional context.

Describe the solution you'd like:

It would be nice to add the ability to parse this to help with faster code writing as well as keeping up with shorthand ways of coding a certain operation.

Describe alternatives you've considered:

The only alternative is to revert back to using the bind() operation which is the longhand for that '::' operator.

Additional context:

Error:

| Semgrep exited with 629 errors:
|    Semgrep Core WARN - Syntax error: When running typescript.react.security.audit.react-html-element-spreading.react-html-element-spreading on js/component/Input/PowerDropdown.js: `::` was unexpected

Code snippet that it is faulty on:

handleEscapePress = ::this.handleEscapePress;
handleDocumentClick = ::this.handleDocumentClick;
@aryx aryx added parsing Requires a fix in a parser, typically a tree-sitter or menhir grammar. and removed feature:debug labels Dec 13, 2021
@mjambon
Copy link
Member

mjambon commented Jan 6, 2022

I can't find documentation for this. It looks like it was a proposal for ES7 (2016) but there's no trace of it in the ES7 spec or later. Here's confirmation that the bind operator :: wasn't adopted in javascript. It wasn't adopted in typescript either but a comment indicates that the ES proposal has been recently revived (Sep 2021).

We can support whatever is supported by typescript via the tree-sitter-typescript implementation but if it's not an official feature of typescript, it's going to be complicated.

@mjambon mjambon added the lang-nonstandard-syntax a request to support syntax that's not an official feature of the language at this time. label Jan 6, 2022
@nbrahms nbrahms changed the title [js] Add the ability to parse the '::' operator in Semgrep for javascript [js-experimental] Add the ability to parse the '::' operator in Semgrep for javascript Jan 6, 2022
@aryx aryx closed this as completed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:javascript lang-nonstandard-syntax a request to support syntax that's not an official feature of the language at this time. parsing Requires a fix in a parser, typically a tree-sitter or menhir grammar. priority:medium
Development

No branches or pull requests

3 participants