es-check 9.1.3-1 → 9.1.4
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.
- package/README.md +16 -1
- package/constants.js +9 -1
- package/index.js +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,6 +248,18 @@ es-check --checkBrowser --browserslistQuery="last 2 versions" ./dist/**/*.js
|
|
|
248
248
|
es-check --checkBrowser --browserslistQuery=">0.5%, not dead" --checkFeatures ./dist/**/*.js
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
+
**Using browserlist just like an es version**
|
|
252
|
+
|
|
253
|
+
```sh
|
|
254
|
+
es-check checkBrowser ./dist/**/*.js --browserslistQuery=">0.5%, not dead"
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Using browserlist with a pre-defined browserlist**
|
|
258
|
+
|
|
259
|
+
```sh
|
|
260
|
+
es-check checkBrowser ./dist/**/*.js
|
|
261
|
+
```
|
|
262
|
+
|
|
251
263
|
---
|
|
252
264
|
|
|
253
265
|
## Usage
|
|
@@ -442,6 +454,9 @@ es-check --checkBrowser --browserslistQuery="last 2 versions" ./dist/**/*.js
|
|
|
442
454
|
|
|
443
455
|
# Using 'checkBrowser' as the ES version argument
|
|
444
456
|
es-check checkBrowser --browserslistQuery="last 2 versions" ./dist/**/*.js
|
|
457
|
+
|
|
458
|
+
# Using a pre-defined browserslist configuration
|
|
459
|
+
es-check checkBrowser ./dist/**/*.js
|
|
445
460
|
```
|
|
446
461
|
|
|
447
462
|
This will read your browserslist configuration (from `.browserslistrc`, `package.json`, etc.) and determine the appropriate ES version based on your targeted browsers.
|
|
@@ -466,7 +481,7 @@ es-check --checkBrowser --browserslistEnv="production" ./dist/**/*.js
|
|
|
466
481
|
es-check --checkBrowser --checkFeatures ./dist/**/*.js
|
|
467
482
|
```
|
|
468
483
|
|
|
469
|
-
⚠️ **NOTE:** When using `--checkBrowser`, you must also provide a `--browserslistQuery` or have a valid browserslist configuration in your project.
|
|
484
|
+
⚠️ **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
|
|
470
485
|
|
|
471
486
|
---
|
|
472
487
|
|
package/constants.js
CHANGED
|
@@ -574,6 +574,13 @@ const BROWSER_TO_ES_VERSION = {
|
|
|
574
574
|
}
|
|
575
575
|
};
|
|
576
576
|
|
|
577
|
+
const JS_VERSIONS = [
|
|
578
|
+
'es3', 'es4', 'es5', 'es6', 'es2015',
|
|
579
|
+
'es7', 'es2016', 'es8', 'es2017', 'es9', 'es2018',
|
|
580
|
+
'es10', 'es2019', 'es11', 'es2020', 'es12', 'es2021',
|
|
581
|
+
'es13', 'es2022', 'es14', 'es2023', 'checkBrowser'
|
|
582
|
+
];
|
|
583
|
+
|
|
577
584
|
/**
|
|
578
585
|
* Maps feature names from ES_FEATURES to their polyfill patterns
|
|
579
586
|
* This helps us identify which features are being polyfilled
|
|
@@ -640,5 +647,6 @@ module.exports = {
|
|
|
640
647
|
ES_FEATURES,
|
|
641
648
|
NODE_TYPES,
|
|
642
649
|
BROWSER_TO_ES_VERSION,
|
|
643
|
-
FEATURE_TO_POLYFILL_MAP
|
|
650
|
+
FEATURE_TO_POLYFILL_MAP,
|
|
651
|
+
JS_VERSIONS,
|
|
644
652
|
};
|
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const detectFeatures = require('./detectFeatures')
|
|
|
10
10
|
let polyfillDetector = null;
|
|
11
11
|
const pkg = require('./package.json')
|
|
12
12
|
const { lilconfig } = require('lilconfig');
|
|
13
|
+
const { JS_VERSIONS } = require('./constants');
|
|
13
14
|
const { parseIgnoreList, createLogger, generateBashCompletion, generateZshCompletion } = require('./utils');
|
|
14
15
|
|
|
15
16
|
program.configureOutput({
|
|
@@ -92,7 +93,7 @@ program
|
|
|
92
93
|
.addOption(new Option('--ignore-file <path>', 'path to JSON file containing features to ignore').hideHelp())
|
|
93
94
|
.option('--ignoreFile <path>', 'path to JSON file containing features to ignore')
|
|
94
95
|
.option('--allowList <features>', 'comma-separated list of features to allow even in lower ES versions, e.g., "const,let"')
|
|
95
|
-
.addOption(new Option('--checkBrowser', 'use browserslist configuration to determine ES version, use checkBrowser argument instead of ecmaVersion').hideHelp())
|
|
96
|
+
.addOption(new Option('--checkBrowser', 'use browserslist configuration to determine ES version, use checkBrowser argument instead of ecmaVersion', false).hideHelp())
|
|
96
97
|
.option('--browserslistQuery <query>', 'browserslist query')
|
|
97
98
|
.option('--browserslistPath <path>', 'path to custom browserslist configuration')
|
|
98
99
|
.option('--browserslistEnv <env>', 'browserslist environment to use')
|
|
@@ -145,6 +146,13 @@ program
|
|
|
145
146
|
process.exit(1)
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
const validEcmaVersionValues = new Set(JS_VERSIONS);
|
|
150
|
+
|
|
151
|
+
if (options.checkBrowser && ecmaVersionArg && !validEcmaVersionValues.has(ecmaVersionArg)) {
|
|
152
|
+
filesArg.unshift(ecmaVersionArg);
|
|
153
|
+
ecmaVersionArg = 'checkBrowser';
|
|
154
|
+
}
|
|
155
|
+
|
|
148
156
|
const configs = await loadConfig(options.config);
|
|
149
157
|
const baseConfig = configs[0] || {};
|
|
150
158
|
|
|
@@ -257,7 +265,7 @@ async function runChecks(configs, logger) {
|
|
|
257
265
|
|
|
258
266
|
let ecmaVersion
|
|
259
267
|
|
|
260
|
-
const isBrowserslistCheck = Boolean(expectedEcmaVersion === 'checkBrowser' || checkBrowser);
|
|
268
|
+
const isBrowserslistCheck = Boolean(expectedEcmaVersion === 'checkBrowser' || checkBrowser !== undefined);
|
|
261
269
|
if (isBrowserslistCheck) {
|
|
262
270
|
const browserslistQuery = config.browserslistQuery;
|
|
263
271
|
try {
|