es-check 9.4.4 → 9.4.5-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +205 -130
  2. package/{browserslist.js → lib/browserslist.js} +31 -22
  3. package/{cache.js → lib/cache.js} +13 -13
  4. package/lib/check-runner/index.js +193 -0
  5. package/lib/check-runner/utils.js +521 -0
  6. package/lib/cli/constants.js +172 -0
  7. package/lib/cli/handler.js +183 -0
  8. package/lib/cli/index.js +33 -0
  9. package/lib/cli/parser.js +122 -0
  10. package/lib/cli/utils.js +228 -0
  11. package/lib/config.js +47 -0
  12. package/lib/constants/index.js +3 -0
  13. package/lib/constants/versions.js +181 -0
  14. package/{esm-wrapper.mjs → lib/esm-wrapper.mjs} +3 -3
  15. package/lib/helpers/ast.js +43 -0
  16. package/lib/helpers/detectFeatures/constants/es-features/10.js +37 -0
  17. package/lib/helpers/detectFeatures/constants/es-features/11.js +57 -0
  18. package/lib/helpers/detectFeatures/constants/es-features/12.js +51 -0
  19. package/lib/helpers/detectFeatures/constants/es-features/13.js +62 -0
  20. package/lib/helpers/detectFeatures/constants/es-features/14.js +59 -0
  21. package/lib/helpers/detectFeatures/constants/es-features/15.js +28 -0
  22. package/lib/helpers/detectFeatures/constants/es-features/16.js +39 -0
  23. package/lib/helpers/detectFeatures/constants/es-features/6.js +165 -0
  24. package/lib/helpers/detectFeatures/constants/es-features/7.js +20 -0
  25. package/lib/helpers/detectFeatures/constants/es-features/8.js +45 -0
  26. package/lib/helpers/detectFeatures/constants/es-features/9.js +27 -0
  27. package/lib/helpers/detectFeatures/constants/es-features/index.js +27 -0
  28. package/lib/helpers/detectFeatures/constants/index.js +13 -0
  29. package/lib/helpers/detectFeatures/constants/polyfills.js +267 -0
  30. package/lib/helpers/detectFeatures/index.js +200 -0
  31. package/lib/helpers/files.js +81 -0
  32. package/lib/helpers/index.js +25 -0
  33. package/lib/helpers/logger.js +103 -0
  34. package/lib/helpers/parsers.js +75 -0
  35. package/lib/helpers/sourcemap.js +284 -0
  36. package/lib/index.js +9 -0
  37. package/package.json +44 -55
  38. package/constants.js +0 -807
  39. package/detectFeatures.js +0 -146
  40. package/index.js +0 -603
  41. package/polyfillDetector.js +0 -51
  42. package/utils.js +0 -633
package/README.md CHANGED
@@ -10,20 +10,17 @@
10
10
 
11
11
  # ES Check ✔️
12
12
 
13
- [![npm version](https://badge.fury.io/js/es-check.svg)](https://www.npmjs.com/package/es-check)
13
+ [![npm version](https://badge.fury.io/js/es-check.svg)](https://www.npmjs.com/package/es-check) [![codecov](https://codecov.io/gh/yowainwright/es-check/branch/main/graph/badge.svg)](https://codecov.io/gh/yowainwright/es-check)
14
14
 
15
15
  ---
16
16
 
17
- **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.
18
-
19
- Ensuring that JavaScript files can pass ES Check is important in a [modular and bundled](https://www.sitepoint.com/javascript-modules-bundling-transpiling/) world. Read more about [why](#why).
17
+ **ES Check** validates JavaScript files against specified ECMAScript versions. Files failing version checks throw errors with detailed logging.
20
18
 
21
19
  ---
22
20
 
23
21
  ## Version 9 🎉
24
22
 
25
- **ES Check** version 9 is a major release update that can enforce more ES version specific features checks, implements initial browserslist integration, basic (naive) polyfill detection, and supports an allowlist. To enable ecmaVersion specific checks, pass the `--checkFeatures` flag. To enable browserslist integration, pass the `--checkBrowser` flag. To enable polyfill detection, pass the `--checkForPolyfills` flag. There is also more config file support. Besides this, there are other feature updates based on user feedback. This version should not break any existing scripts but, as significant changes/features have been added and it's know that es-check supports protecting against breaking errors going to production, a major version bump feels appropriate. Please report any issues!
26
-
23
+ Version 9 adds ES version feature checks (`--checkFeatures`), browserslist integration (`--checkBrowser`), polyfill detection (`--checkForPolyfills`), and enhanced config support. Backward compatible.
27
24
 
28
25
  ### `--checkFeatures`
29
26
 
@@ -42,12 +39,12 @@ es-check checkBrowser ./dist/**/*.js --browserslistQuery="last 2 versions"
42
39
  <p align="center">
43
40
  <a href="#get-started">Get Started</a>&nbsp;&nbsp;
44
41
  <a href="#why-es-check">Why ES Check?</a>&nbsp;&nbsp;
45
- <a href="#usage">Usage</a>&nbsp;&nbsp;
46
- <a href="#walk-through">Walk Through</a>&nbsp;&nbsp;
47
42
  <a href="#api">API</a>&nbsp;&nbsp;
48
- <a href="#debugging">Debugging</a>&nbsp;&nbsp;
43
+ <a href="#usage">Usage</a>&nbsp;&nbsp;
44
+ <a href="#configuration">Configuration</a>&nbsp;&nbsp;
45
+ <a href="#how-es-check-works">How ES Check Works</a>&nbsp;&nbsp;
49
46
  <a href="#contributing">Contributing</a>&nbsp;&nbsp;
50
- <a href="/issues">Issues</a>
47
+ <a href="https://github.com/yowainwright/es-check/issues">Issues</a>
51
48
  </p>
52
49
 
53
50
  ---
@@ -79,11 +76,11 @@ es-check es5 './vendor/js/*.js' './dist/**/*.js'
79
76
 
80
77
  ## Why ES Check?
81
78
 
82
- 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.
79
+ Modern JavaScript builds assume proper transpilation via tools like Babel. ES Check verifies transpilation succeeded, catching untranspiled files before production.
83
80
 
84
81
  ## What features does ES Check check for?
85
82
 
86
- ES Check checks syntax out of the box—to protect against breaking errors going to production. Additionally, by adding the `--checkFeatures` flag, ES Check will check for actual ES version specific features. This ensures that your code is syntactically correct and only using features that are available in the specified ES version. Look here to view/add [features](./constants.js) that ES Check checks for with the `--checkFeatures` flag!
83
+ ES Check validates syntax by default. Add `--checkFeatures` for ES version-specific feature checking. View supported [features](./lib/helpers/detectFeatures/constants/es-features/).
87
84
 
88
85
  ---
89
86
 
@@ -99,7 +96,7 @@ The images below demonstrate command line scripts and their corresponding logged
99
96
 
100
97
  ![fail](https://user-images.githubusercontent.com/1074042/31471486-d65c3a80-ae9d-11e7-94fd-68b7acdb2d89.jpg)
101
98
 
102
- **ES Check** is run above with node commands. It can also be run within npm scripts, ci tools, or testing suites. It also provide minimal support for use in node apps.
99
+ Run ES Check via CLI, npm scripts, CI tools, or programmatically in Node apps.
103
100
 
104
101
  ---
105
102
 
@@ -130,71 +127,33 @@ Arguments:
130
127
 
131
128
  Here's a comprehensive list of all available options:
132
129
 
133
- | Option | Description |
134
- |--------|-------------|
135
- | `-V, --version` | Output the version number |
136
- | `--module` | Use ES modules (default: false) |
137
- | `--light` | Lightweight mode: 2-3x faster checking using pattern matching only (default: false) |
138
- | `--allowHashBang` | If the code starts with #! treat it as a comment (default: false) |
139
- | `--files <files>` | A glob of files to test the ECMAScript version against (alias for [files...]) |
140
- | `--not <files>` | Folder or file names to skip |
141
- | `--noColor` | Disable use of colors in output (default: false) |
142
- | `-v, --verbose` | Verbose mode: will also output debug messages (default: false) |
143
- | `--quiet` | Quiet mode: only displays warn and error messages (default: false) |
144
- | `--looseGlobMatching` | Doesn't fail if no files are found in some globs/files (default: false) |
145
- | `--silent` | Silent mode: does not output anything, giving no indication of success or failure other than the exit code (default: false) |
146
- | `--checkFeatures` | Check for actual ES version specific features (default: false) |
147
- | `--checkForPolyfills` | Consider polyfills when checking features (only works with --checkFeatures) (default: false) |
148
- | `--ignore <features>` | Comma-separated list of features to ignore, e.g., "ErrorCause,TopLevelAwait" |
149
- | `--ignoreFile <path>` | Path to JSON file containing features to ignore |
150
- | `--allowList <features>` | Comma-separated list of features to allow even in lower ES versions, e.g., "const,let" |
151
- | `--checkBrowser` | Use browserslist configuration to determine ES version (default: false) |
152
- | `--browserslistQuery <query>` | Custom browserslist query (e.g., "last 2 versions") |
153
- | `--browserslistPath <path>` | Path to custom browserslist configuration (default: uses standard browserslist config resolution) |
154
- | `--browserslistEnv <env>` | Browserslist environment to use (default: production) |
155
- | `--config <path>` | Path to custom .escheckrc config file |
156
- | `--batchSize <number>` | Number of files to process concurrently (0 for unlimited, default: 0) |
157
- | `--noCache` | Disable file caching (cache is enabled by default) |
158
- | `-h, --help` | Display help for command |
159
-
160
- ### Shell Completion
161
-
162
- ES Check supports shell tab completion for commands and options. You can generate completion scripts for bash and zsh shells:
163
-
164
- ```sh
165
- # Generate completion script for bash (default)
166
- es-check completion
167
-
168
- # Generate completion script for zsh
169
- es-check completion zsh
170
- ```
171
-
172
- To enable completions in your shell:
173
-
174
- **Bash:**
175
-
176
- ```sh
177
- # Add to ~/.bashrc or ~/.bash_profile
178
- es-check completion > ~/.es-check-completion.bash
179
- echo 'source ~/.es-check-completion.bash' >> ~/.bashrc
180
- ```
181
-
182
- **Zsh:**
183
-
184
- ```sh
185
- # Add to ~/.zshrc
186
- es-check completion zsh > ~/.es-check-completion.zsh
187
- echo 'source ~/.es-check-completion.zsh' >> ~/.zshrc
188
- ```
189
-
190
- Once enabled, you can use tab completion for:
191
-
192
- - ES versions (es5, es6, etc.)
193
- - Commands (completion)
194
- - Options (--module, --checkFeatures, etc.)
195
- - File paths
196
-
197
- #### Examples
130
+ | Option | Description |
131
+ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
132
+ | `-V, --version` | Output the version number |
133
+ | `--module` | Use ES modules (default: false) |
134
+ | `--allowHashBang` | If the code starts with #! treat it as a comment (default: false) |
135
+ | `--files <files>` | A glob of files to test the ECMAScript version against (alias for [files...]) |
136
+ | `--not <files>` | Folder or file names to skip |
137
+ | `--noColor` | Disable use of colors in output (default: false) |
138
+ | `-v, --verbose` | Verbose mode: will also output debug messages (default: false) |
139
+ | `--quiet` | Quiet mode: only displays warn and error messages (default: false) |
140
+ | `--looseGlobMatching` | Doesn't fail if no files are found in some globs/files (default: false) |
141
+ | `--silent` | Silent mode: does not output anything, giving no indication of success or failure other than the exit code (default: false) |
142
+ | `--checkFeatures` | Check for actual ES version specific features (default: false) |
143
+ | `--checkForPolyfills` | Consider polyfills when checking features (only works with --checkFeatures) (default: false) |
144
+ | `--ignore <features>` | Comma-separated list of features to ignore, e.g., "ErrorCause,TopLevelAwait" |
145
+ | `--ignoreFile <path>` | Path to JSON file containing features to ignore |
146
+ | `--allowList <features>` | Comma-separated list of features to allow even in lower ES versions, e.g., "const,let" |
147
+ | `--checkBrowser` | Use browserslist configuration to determine ES version (default: false) |
148
+ | `--browserslistQuery <query>` | Custom browserslist query (e.g., "last 2 versions") |
149
+ | `--browserslistPath <path>` | Path to custom browserslist configuration (default: uses standard browserslist config resolution) |
150
+ | `--browserslistEnv <env>` | Browserslist environment to use (default: production) |
151
+ | `--config <path>` | Path to custom .escheckrc config file |
152
+ | `--batchSize <number>` | Number of files to process concurrently (0 for unlimited, default: 0) |
153
+ | `--noCache` | Disable file caching (cache is enabled by default) |
154
+ | `-h, --help` | Display help for command |
155
+
156
+ ### Examples
198
157
 
199
158
  **Using ES modules:**
200
159
 
@@ -202,12 +161,6 @@ Once enabled, you can use tab completion for:
202
161
  es-check es6 './dist/**/*.js' --module
203
162
  ```
204
163
 
205
- **Fast checking with light mode (2-3x faster):**
206
-
207
- ```sh
208
- es-check es5 './dist/**/*.js' --light
209
- ```
210
-
211
164
  **Checking files with hash bang:**
212
165
 
213
166
  ```sh
@@ -297,24 +250,26 @@ es-check es6 ./js/*.js ./dist/*.js
297
250
  In addition to its CLI utility, ES Check can be used programmatically in Node.js applications:
298
251
 
299
252
  ```javascript
300
- const { runChecks, loadConfig } = require('es-check');
253
+ const { runChecks, loadConfig } = require("es-check");
301
254
 
302
255
  async function checkMyFiles() {
303
- const configs = [{
304
- ecmaVersion: 'es5',
305
- files: ['dist/**/*.js'],
306
- module: false,
307
- checkFeatures: true
308
- }];
309
-
256
+ const configs = [
257
+ {
258
+ ecmaVersion: "es5",
259
+ files: ["dist/**/*.js"],
260
+ module: false,
261
+ checkFeatures: true,
262
+ },
263
+ ];
264
+
310
265
  const result = await runChecks(configs);
311
-
266
+
312
267
  if (result.success) {
313
- console.log('All files passed ES5 check!');
268
+ console.log("All files passed ES5 check!");
314
269
  // Output: All files passed ES5 check!
315
270
  } else {
316
271
  console.error(`ES Check failed with ${result.errors.length} errors`);
317
- result.errors.forEach(error => {
272
+ result.errors.forEach((error) => {
318
273
  console.error(`- ${error.file}: ${error.err.message}`);
319
274
  });
320
275
  // Example output:
@@ -322,7 +277,7 @@ async function checkMyFiles() {
322
277
  // - dist/app.js: Unsupported features used: const, arrow-functions but your target is ES5.
323
278
  // - dist/utils.js: Unsupported features used: template-literals but your target is ES5.
324
279
  }
325
-
280
+
326
281
  return result;
327
282
  }
328
283
  ```
@@ -356,22 +311,22 @@ Here's an example of what an `.escheckrc` file will look like:
356
311
 
357
312
  ### Configuration Options
358
313
 
359
- | Option | Type | Description |
360
- |--------|------|-------------|
361
- | `ecmaVersion` | String | ECMAScript version to check against (e.g., "es5", "es6", "es2020") |
362
- | `files` | String or Array | Files or glob patterns to check |
363
- | `module` | Boolean | Whether to parse files as ES modules |
364
- | `not` | Array | Files or glob patterns to exclude |
365
- | `allowHashBang` | Boolean | Whether to allow hash bang in files |
366
- | `looseGlobMatching` | Boolean | Whether to ignore missing files in globs |
367
- | `checkFeatures` | Boolean | Whether to check for ES version specific features |
368
- | `checkForPolyfills` | Boolean | Whether to consider polyfills when checking features |
369
- | `ignore` | Array | Features to ignore when checking |
370
- | `allowList` | Array | Features to allow even in lower ES versions |
371
- | `checkBrowser` | Boolean | Whether to use browserslist configuration to determine ES version |
372
- | `browserslistQuery` | String | Custom browserslist query to use |
373
- | `browserslistPath` | String | Path to custom browserslist configuration |
374
- | `browserslistEnv` | String | Browserslist environment to use |
314
+ | Option | Type | Description |
315
+ | ------------------- | --------------- | ------------------------------------------------------------------ |
316
+ | `ecmaVersion` | String | ECMAScript version to check against (e.g., "es5", "es6", "es2020") |
317
+ | `files` | String or Array | Files or glob patterns to check |
318
+ | `module` | Boolean | Whether to parse files as ES modules |
319
+ | `not` | Array | Files or glob patterns to exclude |
320
+ | `allowHashBang` | Boolean | Whether to allow hash bang in files |
321
+ | `looseGlobMatching` | Boolean | Whether to ignore missing files in globs |
322
+ | `checkFeatures` | Boolean | Whether to check for ES version specific features |
323
+ | `checkForPolyfills` | Boolean | Whether to consider polyfills when checking features |
324
+ | `ignore` | Array | Features to ignore when checking |
325
+ | `allowList` | Array | Features to allow even in lower ES versions |
326
+ | `checkBrowser` | Boolean | Whether to use browserslist configuration to determine ES version |
327
+ | `browserslistQuery` | String | Custom browserslist query to use |
328
+ | `browserslistPath` | String | Path to custom browserslist configuration |
329
+ | `browserslistEnv` | String | Browserslist environment to use |
375
330
 
376
331
  ### Multiple Configurations
377
332
 
@@ -442,10 +397,7 @@ Example `.escheckignore` file:
442
397
 
443
398
  ```json
444
399
  {
445
- "features": [
446
- "ErrorCause",
447
- "TopLevelAwait"
448
- ]
400
+ "features": ["ErrorCause", "TopLevelAwait"]
449
401
  }
450
402
  ```
451
403
 
@@ -471,11 +423,13 @@ This option tells ES Check to look for common polyfill patterns in your code and
471
423
  ES Check provides three ways to handle polyfilled features:
472
424
 
473
425
  1. **--checkForPolyfills**: Automatically detects polyfills in your code
426
+
474
427
  ```sh
475
428
  es-check es2022 './dist/**/*.js' --checkFeatures --checkForPolyfills
476
429
  ```
477
430
 
478
431
  2. **--allowList**: Explicitly specify features to allow regardless of ES version
432
+
479
433
  ```sh
480
434
  es-check es2022 './dist/**/*.js' --checkFeatures --allowList="ArrayToSorted,ObjectHasOwn"
481
435
  ```
@@ -532,7 +486,7 @@ es-check --checkBrowser --browserslistEnv="production" ./dist/**/*.js
532
486
  es-check --checkBrowser --checkFeatures ./dist/**/*.js
533
487
  ```
534
488
 
535
- ⚠️ **NOTE:** When using `--checkBrowser`, you must also provide a `--browserslistQuery` or have a valid browserslist configuration in your project. You cannot have a files directly after your `--checkBrowser` option; it will read as
489
+ ⚠️ **NOTE:** When using `--checkBrowser`, you must also provide a `--browserslistQuery` or have a valid browserslist configuration in your project. You cannot have a files directly after your `--checkBrowser` option; it will read as
536
490
 
537
491
  ---
538
492
 
@@ -541,6 +495,7 @@ es-check --checkBrowser --checkFeatures ./dist/**/*.js
541
495
  ES Check includes several performance optimizations:
542
496
 
543
497
  ### File Caching
498
+
544
499
  File caching is **enabled by default** for faster re-checking:
545
500
 
546
501
  ```sh
@@ -552,11 +507,13 @@ es-check es5 './dist/**/*.js' --noCache
552
507
  ```
553
508
 
554
509
  We observed ~28% performance improvement in our [benchmark tests](./benchmarks/README.md). Your results may vary based on file sizes and system configuration. Try the benchmarks yourself:
510
+
555
511
  ```sh
556
512
  node benchmarks/compare-tools.js 3 ./benchmarks/test-files
557
513
  ```
558
514
 
559
515
  ### Batch Processing
516
+
560
517
  The `--batchSize` option optimizes memory usage:
561
518
 
562
519
  ```sh
@@ -572,17 +529,18 @@ es-check es5 './dist/**/*.js' --batchSize 50
572
529
 
573
530
  ### Performance Guidelines
574
531
 
575
- | Scenario | Recommended `--batchSize` | Reason |
576
- |----------|---------------------------|---------|
577
- | Small codebases (< 100 files) | `0` (unlimited) | Maximum parallelism for fastest results |
578
- | Medium codebases (100-500 files) | `0` or `50` | Balance between speed and memory |
579
- | Large codebases (> 500 files) | `50-100` | Prevent memory spikes |
580
- | CI/CD with limited memory | `10-20` | Conservative memory usage |
581
- | Local development | `0` (default) | Utilize available hardware |
532
+ | Scenario | Recommended `--batchSize` | Reason |
533
+ | -------------------------------- | ------------------------- | --------------------------------------- |
534
+ | Small codebases (< 100 files) | `0` (unlimited) | Maximum parallelism for fastest results |
535
+ | Medium codebases (100-500 files) | `0` or `50` | Balance between speed and memory |
536
+ | Large codebases (> 500 files) | `50-100` | Prevent memory spikes |
537
+ | CI/CD with limited memory | `10-20` | Conservative memory usage |
538
+ | Local development | `0` (default) | Utilize available hardware |
582
539
 
583
540
  ### Recent Performance Improvements
584
541
 
585
542
  As of August 2025, ES Check has been optimized with:
543
+
586
544
  - **Single-parse optimization**: Files are parsed once and the AST is reused
587
545
  - **Async file processing**: Non-blocking I/O for better performance
588
546
  - **Configurable batch processing**: Fine-tune based on your needs
@@ -605,21 +563,132 @@ A simple example script is available in `examples/check-node-modules.js`.
605
563
 
606
564
  ---
607
565
 
608
- ## Acknowledgements
566
+ ## How ES Check Works
567
+
568
+ ```mermaid
569
+ flowchart LR
570
+ A[Input: ES Version<br/>+ File Globs] --> B[Full AST Parsing<br/>Acorn]
571
+ B --> C{Syntax<br/>Valid?}
572
+ C -->|Pass| E{--checkFeatures?}
573
+ C -->|Fail| D[Report Error]
574
+ E -->|Yes| G[Check ES Features<br/>AST Walk]
575
+ E -->|No| F[Success]
576
+ G --> G1{Features<br/>Valid?}
577
+ G1 -->|Pass| H{--checkForPolyfills?}
578
+ G1 -->|Fail| D
579
+ H -->|Yes| I{Polyfills<br/>Detected?}
580
+ H -->|No| F
581
+ I -->|Yes| F
582
+ I -->|No| D
583
+ D --> J[Exit 1]
584
+ F --> K[Exit 0]
585
+
586
+ classDef inputStyle fill:#e1f5ff,stroke:#0288d1,stroke-width:2px
587
+ classDef processStyle fill:#fff3e0,stroke:#f57c00,stroke-width:2px
588
+ classDef decisionStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
589
+ classDef successStyle fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
590
+ classDef errorStyle fill:#ffebee,stroke:#d32f2f,stroke-width:2px
591
+
592
+ class A inputStyle
593
+ class B,G processStyle
594
+ class C,E,G1,H,I decisionStyle
595
+ class F,K successStyle
596
+ class D,J errorStyle
597
+ ```
598
+
599
+ ---
600
+
601
+ ## Source Maps
609
602
 
610
- ES Check is a small utility using powerful tools that [Isaac Z. Schlueter](https://github.com/isaacs), [Marijn Haverbeke](https://github.com/marijnh), and [Matthias Etienne](https://github.com/mattallty) built. [ES Checker](https://github.com/ruanyf/es-checker) by [Ruan YiFeng](https://github.com/ruanyf) checks the JavaScript version supported within a [browser](http://ruanyf.github.io/es-checker/) 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 [Philip Walton](https://github.com/philipwalton)'s post about [deploying es2015 code to production today](https://philipwalton.com/articles/deploying-es2015-code-in-production-today/).
603
+ ES Check supports source maps for better error reporting. When a `.map` file exists alongside your JavaScript file, ES Check will automatically map error positions from transpiled code back to the original source:
604
+
605
+ ```sh
606
+ es-check es5 './dist/bundle.js'
607
+ ```
608
+
609
+ If `bundle.js.map` exists, errors will reference the original source file and line numbers instead of the minified positions. This helps quickly identify issues in your source code.
610
+
611
+ ---
612
+
613
+ ## Shell Completion
614
+
615
+ ES Check supports shell tab completion for commands and options. You can generate completion scripts for bash and zsh shells:
616
+
617
+ ```sh
618
+ # Generate completion script for bash (default)
619
+ es-check completion
620
+
621
+ # Generate completion script for zsh
622
+ es-check completion zsh
623
+ ```
624
+
625
+ To enable completions in your shell:
626
+
627
+ **Bash:**
628
+
629
+ ```sh
630
+ # Add to ~/.bashrc or ~/.bash_profile
631
+ es-check completion > ~/.es-check-completion.bash
632
+ echo 'source ~/.es-check-completion.bash' >> ~/.bashrc
633
+ ```
634
+
635
+ **Zsh:**
636
+
637
+ ```sh
638
+ # Add to ~/.zshrc
639
+ es-check completion zsh > ~/.es-check-completion.zsh
640
+ echo 'source ~/.es-check-completion.zsh' >> ~/.zshrc
641
+ ```
642
+
643
+ Once enabled, you can use tab completion for:
644
+
645
+ - ES versions (es5, es6, etc.)
646
+ - Commands (completion)
647
+ - Options (--module, --checkFeatures, etc.)
648
+ - File paths
649
+
650
+ ---
651
+
652
+ ## Performance
653
+
654
+ ES Check is benchmarked against similar tools using real-world production libraries. Results from 11/02/2025:
655
+
656
+ | Tool | Average (ms) | Relative Performance |
657
+ | --------------------- | ------------ | -------------------- |
658
+ | **es-check-batch-50** | **7.20** | **1x (fastest)** |
659
+ | es-check-batch-10 | 7.67 | 1.06x slower |
660
+ | es-check-bundled | 8.04 | 1.12x slower |
661
+ | es-check | 9.17 | 1.27x slower |
662
+ | are-you-es5 | 15.05 | 2.09x slower |
663
+ | acorn (direct) | 47.11 | 6.54x slower |
664
+ | eslint | 55.21 | 7.67x slower |
665
+ | swc/core | 55.69 | 7.73x slower |
666
+ | babel-parser | 65.00 | 9.03x slower |
667
+
668
+ Tested on lodash, axios, react, moment, express, and chalk. See [benchmarks](./tests/benchmarks/README.md) for details.
611
669
 
612
670
  ---
613
671
 
614
672
  ## Contributing
615
673
 
616
- ES Check has 7 dependencies: [acorn and acorn-walk](https://github.com/ternjs/acorn/), [fast-glob](https://github.com/mrmlnc/fast-glob), [supports-color](https://github.com/chalk/supports-color), [winston](https://github.com/winstonjs/winston), [browserslist](https://github.com/browserslist/browserslist), and [commander](https://github.com/tj/commander). To contribute, file an [issue](https://github.com/yowainwright/es-check/issues) or submit a pull request.
674
+ ES Check has only 4 core dependencies: [acorn](https://github.com/ternjs/acorn/) for JavaScript parsing, [fast-brake](https://github.com/stackblitz/fast-brake) for lightweight feature detection, [fast-glob](https://github.com/mrmlnc/fast-glob) for file globbing, and [browserslist](https://github.com/browserslist/browserslist) for browser targeting.
675
+
676
+ The CLI, logging, and source map support are implemented with custom lightweight solutions using Node.js built-ins to minimize dependencies. To contribute, file an [issue](https://github.com/yowainwright/es-check/issues) or submit a pull request.
617
677
 
618
- To update es versions, check out these lines of code [here](https://github.com/yowainwright/es-check/blob/main/index.js#L92-L153) and [here (in acorn.js)](https://github.com/acornjs/acorn/blob/3221fa54f9dea30338228b97210c4f1fd332652d/acorn/src/acorn.d.ts#L586).
678
+ ### Contributing to ES Features
619
679
 
620
- To update es feature detection, update these files [here](./utils.js) and [here](./constants.js) as enabled feature testing using [acorn walk](https://github.com/acornjs/acorn/blob/master/acorn-walk/README.md).
680
+ To update ES version support:
621
681
 
622
- [tests](./test.js) to go with new version and/or feature detection updates are great to have!
682
+ - Update [ES version mappings](./lib/constants/versions.js)
683
+ - Reference [Acorn ES version support](https://github.com/acornjs/acorn/blob/3221fa54f9dea30338228b97210c4f1fd332652d/acorn/src/acorn.d.ts#L586)
684
+
685
+ To update ES feature detection:
686
+
687
+ - Add features to [version-specific files](./lib/helpers/detectFeatures/constants/es-features/) (e.g., `6.js` for ES6 features)
688
+ - Update [polyfill patterns](./lib/helpers/detectFeatures/constants/polyfills.js) if needed
689
+ - Feature detection uses [acorn walk](https://github.com/acornjs/acorn/blob/master/acorn-walk/README.md)
690
+
691
+ Tests are located in `tests/unit/` and mirror the `lib/` structure. Please add tests for new features!
623
692
 
624
693
  ### Contributors
625
694
 
@@ -630,3 +699,9 @@ To update es feature detection, update these files [here](./utils.js) and [here]
630
699
  - [Ben Junya](https://github.com/MrBenJ)
631
700
  - [Jeff Barczewski](https://github.com/jeffbski)
632
701
  - [Brandon Casey](https://github.com/BrandonOCasey)
702
+
703
+ ---
704
+
705
+ ## License
706
+
707
+ [MIT](./LICENSE) © [Jeff Wainwright](https://github.com/yowainwright)
@@ -1,5 +1,5 @@
1
- const browserslist = require('browserslist');
2
- const { BROWSER_TO_ES_VERSION } = require('./constants');
1
+ const browserslist = require("browserslist");
2
+ const { BROWSER_TO_ES_VERSION } = require("./constants/versions");
3
3
 
4
4
  /**
5
5
  * Determines the ES version supported by a specific browser and version
@@ -15,7 +15,7 @@ function getESVersionForBrowser(browser, version) {
15
15
  }
16
16
 
17
17
  const browserVersions = Object.keys(BROWSER_TO_ES_VERSION[browser])
18
- .map(v => parseFloat(v))
18
+ .map((v) => parseFloat(v))
19
19
  .sort((a, b) => a - b);
20
20
 
21
21
  const targetVersion = parseFloat(version);
@@ -29,7 +29,10 @@ function getESVersionForBrowser(browser, version) {
29
29
  }
30
30
  }
31
31
 
32
- if (matchedVersion === null && (browser === 'chrome' || browser === 'firefox')) {
32
+ if (
33
+ matchedVersion === null &&
34
+ (browser === "chrome" || browser === "firefox")
35
+ ) {
33
36
  return 6;
34
37
  }
35
38
 
@@ -54,51 +57,57 @@ function getESVersionFromBrowserslist(options = {}) {
54
57
  try {
55
58
  const browsers = browserslist(browserslistQuery ?? null, {
56
59
  path: browserslistPath,
57
- env: browserslistEnv
60
+ env: browserslistEnv,
58
61
  });
59
62
 
60
63
  if (!browsers || browsers.length === 0) {
61
64
  return 5;
62
65
  }
63
66
 
64
- const hasIE = browsers.some(browser => browser.includes('ie '));
65
- const hasOldEdge = browsers.some(browser => {
66
- const [name, version] = browser.split(' ');
67
- return name === 'edge' && parseInt(version, 10) < 79;
67
+ const hasIE = browsers.some((browser) => browser.includes("ie "));
68
+ const hasOldEdge = browsers.some((browser) => {
69
+ const [name, version] = browser.split(" ");
70
+ return name === "edge" && parseInt(version, 10) < 79;
68
71
  });
69
72
 
70
73
  if (hasIE || hasOldEdge) {
71
74
  return 5;
72
75
  }
73
76
 
74
- if ((browserslistPath && browserslistPath.includes('legacy')) ||
75
- (browserslistEnv && browserslistEnv.includes('legacy'))) {
77
+ if (
78
+ (browserslistPath && browserslistPath.includes("legacy")) ||
79
+ (browserslistEnv && browserslistEnv.includes("legacy"))
80
+ ) {
76
81
  return 5;
77
82
  }
78
83
 
79
- if (browsers.length === 0 || (browserslistPath && browserslistPath.includes('non-existent'))) {
84
+ if (
85
+ browsers.length === 0 ||
86
+ (browserslistPath && browserslistPath.includes("non-existent"))
87
+ ) {
80
88
  return 5;
81
89
  }
82
90
 
83
- if (browserslistPath && browserslistPath.includes('mixed')) {
91
+ if (browserslistPath && browserslistPath.includes("mixed")) {
84
92
  return 5;
85
93
  }
86
94
 
87
- const hasModernBrowsers = browsers.some(browser =>
88
- browser.includes('chrome') || browser.includes('firefox')
89
- );
95
+ const esVersions = browsers.map((browser) => {
96
+ const [browserName, version] = browser.split(" ");
97
+ return getESVersionForBrowser(browserName, version);
98
+ });
90
99
 
91
- if (hasModernBrowsers) {
92
- return 6;
93
- }
100
+ const maxESVersion = esVersions.reduce((max, version) => {
101
+ return version > max ? version : max;
102
+ }, 5);
94
103
 
95
- return 5;
96
- } catch (error) {
104
+ return maxESVersion;
105
+ } catch {
97
106
  return 5;
98
107
  }
99
108
  }
100
109
 
101
110
  module.exports = {
102
111
  getESVersionFromBrowserslist,
103
- getESVersionForBrowser
112
+ getESVersionForBrowser,
104
113
  };