Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

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

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

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 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 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants