dollarshaveclub / es-check Goto Github PK
View Code? Open in Web Editor NEWChecks the version of ES in JavaScript files with simple shell commands 🏆
Home Page: https://github.com/yowainwright/es-check
License: MIT License
Checks the version of ES in JavaScript files with simple shell commands 🏆
Home Page: https://github.com/yowainwright/es-check
License: MIT License
https://github.com/dollarshaveclub/es-check/blob/master/index.js#L74-L84 << Set https://github.com/dollarshaveclub/es-check/blob/master/package.json#L40 to >=8
and you can async/await
the file reads
Allow validating code written in ES5 EXCEPT module imports/exports.
We're transpiling our code to ES5 but still use ES modules to allow for tree-shaking.
We wanted to make sure our generated code is ES5 with the exception of the module syntax which will be handled by webpack in consuming projects (talking about an internal lib).
We need to somehow ignore import/export syntax while still ES5-check our code, if possible/makes sense to you guys.
Thanks a bunch!
Object.assign was a feature introduced in es6 for copying object's own properties. But, as of es-check version 5.1.0 , I see this check passes for es5 check. Reference
update acorn version to latest 6 or 7
Vulnerabilities: Regular Expression Denial of Service
Reproduce:
npm audit
.Nothing
It would be really cool to be able to test your entire code and then see a small status at the bottom: "Your code will run on 95% of all browsers". If you change one feature it will run on 98%.
The data could be compared to caniuse-lite database to see exactly what features are used by browsers.
Just testing against es6 is not enough, some browsers only have partial support. It would be really useful to have exact statistics of where our code will run and what can we do to make it run on even more browsers without using babel, maybe we are just using one weird feature which we can manually replace ourselves.
I don't think so.
Read about references issues here. Provide paragraph text responses to each header.
'includes' is es6 grammar , but actually, it pass check.
2.0.5
to 2.0.7
.This version is covered by your current version range and after updating it in your project the build failed.
conventional-changelog-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I have a problem: es-check tries to validate js files inside my node_modules folder. How to ignore that folder?
I have a monorepo, so, I have multiple node_moudles across my repo.
What exactly ecmaVersion values are valid?
I assume that these are es5
es6
and es2015
.
Is that correct?
Any other versions?
UPD: Ok, I see) https://github.com/dollarshaveclub/es-check/blob/master/index.js#L34
I performed the following on my JS directory and got the following response:
What does the error actually mean?
· error: SyntaxError: Invalid number (22:51)
If that is line #, then character in that line, then in my code its point to the last letter of an object key definition...not an a number. Is it a line/char after it has been minified or the line/char from the raw source file?
:\Users\RPO\dev\myap\www\js>es-check --module es6 *.js
S-Check: there were 1 ES version matching errors.
ES-Check Error:
----
· erroring file: servicesTride.js
· error: SyntaxError: Invalid number (22:51)
· see the printed err.stack below for context
----
SyntaxError: Invalid number (22:51)
at Parser.pp$4.raise (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2769:13)
at Parser.pp$8.readNumber (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:4997:36)
at Parser.pp$8.getTokenFromCode (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:4875:17)
at Parser.pp$8.readToken (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:4633:15)
at Parser.pp$8.nextToken (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:4624:15)
at Parser.pp$8.next (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:4581:8)
at Parser.pp.eat (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:610:10)
at Parser.pp$3.parsePropertyValue (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2475:12)
at Parser.pp$3.parseProperty (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2467:8)
at Parser.pp$3.parseObj (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2413:23)
at Parser.pp$3.parseExprAtom (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2212:17)
at Parser.pp$3.parseExprSubscripts (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2074:19)
at Parser.pp$3.parseMaybeUnary (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:2051:17)
at Parser.pp$3.parseExprOps (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:1993:19)
at Parser.pp$3.parseMaybeConditional (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:1976:19)
at Parser.pp$3.parseMaybeAssign (C:\Users\RPO\AppData\Roaming\npm\node_modules\es-check\node_modules\acorn\dist\acorn.js:1951:19)
Passing --quiet
flag doesn't do anything. I'm still getting ES-Check: there were no ES version matching errors! 🎉
(I'm getting it on a file that doesn't work in IE11, but that's another issue...)
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.nvmrc
with the new onepackage.json
files, so that was left aloneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
would be nice instead of having to comb through a 1mb minified file
Currently, using es-check foo dist/*.js
returns ES-Check: there were no ES version matching errors! 🎉
However you could assume that if the dev mistyped foo
instead of es4
, he could also mistype se7
instead of es7
.
I think es-check
should throw an error when it does not recognize a valid ecmaVersion
argument (see the default
behavior in
Line 74 in b7a40f2
Devs that check their ES version do not need to be handled; lets tell them the harsh truth; they made a typo!
Nope, but issue #40 could have been avoided perhaps?
Specially if when such an error is detected, you could display a usage
info with all the possible ecmaVersion
.
bugfix
crashes with this source code in file (a.js)
CLI launch: npx es-check es6 a.js
module.exports = async (foo) => alert('foo');
stacktrace
ES-Check: there were 1 ES version matching errors.
ES-Check Error:
----
· erroring file: a.js
· error: SyntaxError: Unexpected token (1:29)
· see the printed err.stack below for context
----
SyntaxError: Unexpected token (1:29)
at Parser.pp$4.raise (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:2769:13)
at Parser.pp.unexpected (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:680:8)
at Parser.pp.semicolon (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:657:64)
at Parser.pp$1.parseExpressionStatement (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:1127:8)
at Parser.pp$1.parseStatement (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:851:24)
at Parser.pp$1.parseTopLevel (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:739:23)
at Parser.parse (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:550:15)
at Function.parse (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:572:35)
at Object.parse (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:5288:17)
at globbedFiles.forEach (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/index.js:160:17)
at Array.forEach (<anonymous>)
at files.forEach (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/index.js:155:20)
at Array.forEach (<anonymous>)
at Command.prog.version.argument.argument.option.option.action [as _action] (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/index.js:144:11)
at Command._run (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/caporal/lib/command.js:413:40)
at Program._run (/Users/colch/.npm/_npx/93411/lib/node_modules/es-check/node_modules/caporal/lib/program.js:170:16)
program crashes
no
Read about references issues here. Provide paragraph text responses to each header.
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.
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.
It would be handy if es-check
could also check all required/imported files as well. I tried to run es-check es5 ./dist/index.js
and it said it was no matching errors, but when I included my module in a react-app in complained that one of my dependencies was not in ES5.
To make sure the entire module and not a single file is in ES5.
Read about references issues here. Provide paragraph text responses to each header.
Read about references issues here. Provide paragraph text responses to each header.
Find a different solution for the cycle package. The package itself is only one file with two (short) functions with a "public domain" license published to NPM in 2014.
It does not provide a valid LICENSE as part of the project causing CI tools to fail due to not parsing the package.json. It also appears to be abandoned by the maintainer based on this issue from 2018.
It looks like other packages depend on this facing the same issue as I have.
es-check fails if no files found. This is not okay in my case, because I have a variable number of bundled js files, including zero.
es-check ./src/**/*.mjs
:
ES-Check: there were 22 ES version matching errors.
ES-Check Error:
----
· erroring file: ./src/annotations/annotation.iframe.mjs
· error: SyntaxError: The keyword 'import' is reserved (1:0)
· see the printed err.stack below for context
----
SyntaxError: The keyword 'import' is reserved (1:0)
Proposed CLI: es-check --experimental-modules ./src/**/*.mjs
or es-check --experimental-modules ./src/index.mjs
. The latter points to the main file which import
the rest of the app.
I run es-check es5 project/**/*.js | grep 'erroring file'
multi times in my project
It said:
ES-Check: there were 79 ES version matching errors.
· erroring file: xxxA.js
· erroring file: xxxB.js
· erroring file: xxxC.js
There were always 79 error files in my project, that's ok,
but grep erroring file
count seems random, sometimes 63, sometimes 47,
I just can't tell what all those files are.
Also meet this problem while using it in Node (maybe make an incode requirable version as well?)
exec('es-check es5 myFolder', (err, stdout, stderr) => {
console.log(err)
});
I check your code
I think this issue may be caused by process.exit
...
forEach
is synchronous but log
is not?
So it return before log all the items
and don't use logger.error
for everything...
e.g.
logger.error(`ES-Check: there were no ES version matching errors! 🎉`)
// => better
logger.log(`ES-Check: there were no ES version matching errors! 🎉`)
Expose a JS API so the module can be required and used as a function.
Currently this module is only a CLI tool, but it would be great to use it programatically too.
n/a
If we pass --module
, --allow-hash-bang
, or --verbose
the true value should be implied rather than passed in like it is currently. IE --module true
should not be needed, it should just be --module
.
Flags are fairly standard for most cli applications, and at first glance it would be tough to understand es-check
because these options are flags but you have to pass a true value anyway.
I think this will have to be fixed upstream before we add it here, unless we want to switch the argument parsing library that we use.
mattallty/Caporal.js#107
es-check can have a function to tell us the minimum version of all ES versions that allows a file to parse normally.
This can be done by simply testing against all parsers, or by bisection (with es4 singled out of course) in a million years when testing all yearly ES versions becomes uneconomical.
One can use the new feature to determine the approximate compatibility of a piece of code. With #72 in place this would make a great tool for devs.
It can also be used for "dating" a piece of ancient code found in some ancient ruins.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.