ES Check ✔️
Example of CLI boolean flag in previous versions (Versions 0-4.*)
// the "true" argument was requiredes-check --module true es6 ./tests/modules/*.js'
Now, with Version 5
// the "true" argument must be removed
npm i es-check --save-dev # locallynpm i es-check -g # or globally
Check if an array or glob of files matches a specified ES version.
- Note: adds quotation around globs. Globs are patterns like so,
es-check es5 './vendor/js/*.js' './dist/**/*.js'
- The ES Check script (above) checks
/dist/*.jsfiles to see if they're ES5. It throws an error and logs files are that do not pass the check.
Why ES Check?
The images below demonstrate command line scripts and their corresponding logged results.
ES Check is run above with node commands. It can also be run within npm scripts, ci tools, or testing suites.
# USAGEindex.js es-check <ecmaVersion> [files...]
--module use ES modules, default false
Allow Hash Bang
--allow-hash-bang supports files that start with hash bang, default false
--not=folderName1,folderName2 An array of file/folder names that you would like to ignore. Defaults to ``.
-h, --help Display help-V, --version Display version--no-color Disable colors--quiet Quiet mode - only displays warn and error messages-v, --verbose Verbose mode - will also output debug messages
Here are some example of es check scripts that could be run:
# globses-check ./js/*.js# array of argumentses-check ./js/*.js ./dist/*.js
If you're using a consistent configuration, you can create a
.escheckrc file in JSON format with the
files arguments so you can conveniently run
es-check standalone from the command line.
Here's an example of what an
.escheckrc file will look like:
⚠️ NOTE: Using command line arguments while there is an
.escheckrc file in the project directory will override the configuration values in
As of ES-Check version 2.0.2, a better debugging interface is provided. When a file errors, An error object will be logged with:
- the erroring file
- the error
- the error stack