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

es-check es5 does not catch Promise, Map, Set etc. #72

Open
dotnetCarpenter opened this issue Sep 19, 2018 · 3 comments
Open

es-check es5 does not catch Promise, Map, Set etc. #72

dotnetCarpenter opened this issue Sep 19, 2018 · 3 comments

Comments

@dotnetCarpenter
Copy link

@dotnetCarpenter dotnetCarpenter commented Sep 19, 2018

Requested Update

I was asked today if there was a tool to check if the transpiled code was ES5 and I referred to this project but I just checked and es-check es5 ... does not catch Promise from ES2015.

Why Is This Update Needed?

The reason I was asked is that they have continuous issues with bug reports because they forget to add polyfills to their projects. They need an automated way to check which polyfills they are missing from their transpiled code.

Are There Examples Of This Requested Update Elsewhere?

@dotnetCarpenter
Copy link
Author

@dotnetCarpenter dotnetCarpenter commented Sep 19, 2018

Hmm I just found another project that tries to accomplish this - I haven't tried it though.
https://www.npmjs.com/package/es-feature-detection

@yowainwright
Copy link
Contributor

@yowainwright yowainwright commented Sep 21, 2018

How did you write the script you tested with @dotnetCarpenter?
What version of ES Check were you using?

^ Questions asked to ensure it's not a potential feature that needs to be added.

ES-check is built on acorn.js. I trust it. There are new features that are popping up though. So perhaps feature detection will become a thing that es-check supports.

Es-feature-detection provides some interesting things that could potentially be provided by ES-Check. Thanks for sharing.

@Artoria2e5
Copy link

@Artoria2e5 Artoria2e5 commented Nov 5, 2019

The ones for globals like Map and Set will require some keeping track of the variables. For a single file, this can probably be done by walking the syntax tree with acorn-walker or something similar and looking for uses while making sure that they are not shadowed by something else in the scope. Stuff in ESTree like Function, BlockStatement, WithStatement, VariableDeclaration, AssignmentExpression, Expression will need to be checked.

The story about new methods like Array.prototype.flatmap is a bit more frightening, since they are going to require type deduction and checking. An example of doing so is in the no-for-in-array rule of typescript-eslint. (Some more complex ones like await-thenable requries the tsutils package.) Acorn will not do: this linter uses a ESTree parser generated by consuming typescript AST to achieve that. On the other hand typescript compiler may be good for keeping track of global variables for you too, but it sure is a lot slower.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.