JSPM

  • Created
  • Published
  • Downloads 82831
  • Score
    100M100P100Q145542F
  • License MIT

Checks the EcamScript version of .js glob against a specified version of EcamScript with a shell command

Package Exports

  • es-check

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (es-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ES Check ✔️


Check JavaScript files ES version against a specified ES version 🏆


Build Status npm version Greenkeeper Codecov Share on Twitter


ES Check ✔️

ES Check checks JavaScript files against a specified version of ECMAScript (ES) with a shell command. If a specified file's ES version doesn't match the ES version argument passed in the ES Check command, ES Check will throw an error and log the files that didn't match the check.

Ensuring that JavaScript files can pass ES Check is important in a modular and bundled world. Read more about why.


Get Started   Why ES Check?   Usage   Walk Through   API   Contributing   Issues


Get Started

Install

npm i es-check --save-dev

Check if an array or glob of files matches a specified ES version

node_modules/es-check/index.js check es5 ./vendor/js/*.js ./dist/**/*.js
  • The ES Check script (above) checks /dist/*.js files to see if they're ES5. It throws an error and logs files are that do not pass the check.

Why ES Check?

In modern JavaScript builds, files are bundled up so they can be served in an optimized manner in the browsers. It is assumed by developers that future JavaScript—like ES8 will be transpiled (changed from future JavaScript to current JavaScript) appropriately by a tool like Babel. Sometimes there is an issue where files are not transpiled. There was no efficient way to test for files that weren't transpiled—until now. That's what ES Check does.


Walk through

The images below demonstrate command line scripts and their corresponding logged results.

Pass pass

Fail fail

ES Check is run above with node commands. It can also be run within npm scripts, ci tools, or testing suites.


API

ES Check provides the necessities. It accepts its place as a JavaScript matcher/tester.

General Information

USAGE

index.js es-check <es-checkersion> [files...]

Arguments

<ecmaVersion> 'define the ECMAScript version to check for against a glob of JavaScript files' required
[files...] 'a glob of files to test the ECMAScript version against' required

Global Options

-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

Usage

ES Check is a shell command CLI. It is run in shell tool like Terminal, ITerm, or Hyper. It takes in two arguments: an ECMAScript version (<ECMAScript version>) and files ([files]) in globs.

Here are some example of es check scripts that could be run:

# globs
node_modules/es-check/index.js check es5 ./js/*.js

# array of arguments
node_modules/es-check/index.js check es5 ./js/*.js ./dist/*.js

Acknowledgements

ES Check is a small utility using powerful tools that Isaac Z. Schlueter, Marijn Haverbeke, and Matthias Etienne built. ES Checker by Ruan YiFeng checks the JavaScript version supported within a browser at run time. ES Check offers similar feedback to ES Checker but at build time and is specific to the product that is using it. ES Check was started after reading this post about [deploying es2015 code to production today] by Philip Walton.


Contributing

ES Check has 3 main dependencies: acorn, glob, and caporal. To contribute, file an issue or submit a pull request.

Contributors