es-check 5.2.4 → 6.2.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 (4) hide show
  1. package/README.md +5 -1
  2. package/index.js +18 -14
  3. package/package.json +25 -28
  4. package/CHANGELOG.md +0 -67
package/README.md CHANGED
@@ -20,6 +20,10 @@ Ensuring that JavaScript files can pass ES Check is important in a [modular and
20
20
 
21
21
  ---
22
22
 
23
+ **Known issue:** cli argument vs. option order. There is a small issue with cli's option ordering. If an argument is passed **after** a boolean option, the boolean option will default to `falsy` as if the argument was not added. This will create weirdness in checks. A fix for this issue is in the works! 👌
24
+
25
+ ---
26
+
23
27
  <p align="center">
24
28
  <a href="#get-started">Get Started</a>&nbsp;&nbsp;
25
29
  <a href="#why-es-check">Why ES Check?</a>&nbsp;&nbsp;
@@ -192,7 +196,7 @@ ES Check is a small utility using powerful tools that [Isaac Z. Schlueter](https
192
196
 
193
197
  ## Contributing
194
198
 
195
- ES Check has 3 main dependencies: [acorn](https://github.com/ternjs/acorn/), [glob](https://www.npmjs.com/package/glob), and [caporal](https://github.com/mattallty/Caporal.js). To contribute, file an [issue](https://github.com/dollarshaveclub/es-check/issues) or submit a pull request.
199
+ ES Check has 3 main dependencies: [acorn](https://github.com/ternjs/acorn/), [glob](https://www.npmjs.com/package/glob), and [caporal](https://github.com/mattallty/Caporal.js). To contribute, file an [issue](https://github.com/yowainwright/es-check/issues) or submit a pull request.
196
200
 
197
201
  ### Contributors
198
202
 
package/index.js CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  'use strict'
4
4
 
5
- const prog = require('caporal')
5
+ const { program } = require('@caporal/core')
6
6
  const acorn = require('acorn')
7
- const glob = require('glob')
7
+ const glob = require('fast-glob')
8
8
  const fs = require('fs')
9
9
  const path = require('path')
10
10
 
11
11
  const pkg = require('./package.json')
12
- const argsArray = process.argv
12
+ const argsArray = process.argv.slice(2)
13
13
 
14
14
  /**
15
15
  * es-check 🏆
@@ -20,7 +20,7 @@ const argsArray = process.argv
20
20
  * to to test the EcmaScript version of each file
21
21
  * - error failures
22
22
  */
23
- prog
23
+ program
24
24
  .version(pkg.version)
25
25
  .argument(
26
26
  '[ecmaVersion]',
@@ -35,8 +35,10 @@ prog
35
35
  '--allow-hash-bang',
36
36
  'if the code starts with #! treat it as a comment'
37
37
  )
38
- .option('--not', 'folder or file names to skip', prog.LIST)
39
- .action((args, options, logger) => {
38
+ .option('--not', 'folder or file names to skip', {
39
+ validator: program.ARRAY
40
+ })
41
+ .action(({ logger, args, options }) => {
40
42
  const configFilePath = path.resolve(process.cwd(), '.escheckrc')
41
43
 
42
44
  /**
@@ -51,14 +53,16 @@ prog
51
53
  const expectedEcmaVersion = args.ecmaVersion
52
54
  ? args.ecmaVersion
53
55
  : config.ecmaVersion
54
- const files = args.files.length ? args.files : [].concat(config.files)
56
+ const files =
57
+ args.files && args.files.length ? args.files : [].concat(config.files)
55
58
  const esmodule = options.module ? options.module : config.module
56
59
  const allowHashBang = options.allowHashBang
57
60
  ? options.allowHashBang
58
61
  : config.allowHashBang
59
- const pathsToIgnore = options.not.length
60
- ? options.not
61
- : [].concat(config.not || [])
62
+ const pathsToIgnore =
63
+ options.not && options.not.length
64
+ ? options.not
65
+ : [].concat(config.not || [])
62
66
 
63
67
  if (!expectedEcmaVersion) {
64
68
  logger.error(
@@ -83,8 +87,8 @@ prog
83
87
  ecmaVersion = '3'
84
88
  break
85
89
  case 'es4':
86
- ecmaVersion = '4'
87
- break
90
+ logger.error('ES4 is not supported.')
91
+ process.exit(1)
88
92
  case 'es5':
89
93
  ecmaVersion = '5'
90
94
  break
@@ -139,7 +143,7 @@ prog
139
143
 
140
144
  const errArray = []
141
145
  const globOpts = { nodir: true }
142
- const acornOpts = { ecmaVersion, silent: true }
146
+ const acornOpts = { ecmaVersion: parseInt(ecmaVersion, 10), silent: true }
143
147
 
144
148
  const expandedPathsToIgnore = pathsToIgnore.reduce((result, path) => {
145
149
  if (path.includes('*')) {
@@ -226,4 +230,4 @@ prog
226
230
  logger.info(`ES-Check: there were no ES version matching errors! 🎉`)
227
231
  })
228
232
 
229
- prog.parse(argsArray)
233
+ program.run(argsArray)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-check",
3
- "version": "5.2.4",
3
+ "version": "6.2.0",
4
4
  "description": "Checks the ECMAScript version of .js glob against a specified version of ECMAScript with a shell command",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -10,16 +10,20 @@
10
10
  "bin": {
11
11
  "es-check": "index.js"
12
12
  },
13
+ "resolutions": {
14
+ "ansi-regex": "5.0.1"
15
+ },
13
16
  "scripts": {
14
17
  "chore:delete-branch": "if git show-ref --quiet refs/heads/chore-changelog; then git branch -D chore-changelog; fi",
15
18
  "chore:branch": "git checkout -b chore-changelog",
16
19
  "chore:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
17
20
  "chore:pr": "git add . && git commit -m '[chore] updates changelog' --no-verify && git push origin chore-changelog -f",
18
- "chore": "npm run chore:delete-branch && npm run chore:branch && npm run chore:changelog && npm run chore:pr",
21
+ "chore": "pnpm run chore:delete-branch && pnpm run chore:branch && pnpm run chore:changelog && pnpm run chore:pr",
19
22
  "lint": "eslint index.js --fix",
20
23
  "lint:ci": "eslint index.js",
21
- "prepush": "npm run lint && npm test",
22
- "postpublish": "git tag $npm_package_version && git push origin --tags && npm run chore",
24
+ "prepush": "pnpm run lint && pnpm test",
25
+ "postpublish": "git tag $npm_package_version && git push origin --tags && pnpm run chore",
26
+ "preinstall": "npx only-allow pnpm",
23
27
  "report:coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",
24
28
  "test": "nyc mocha test.js --timeout 10s --coverage"
25
29
  },
@@ -33,31 +37,24 @@
33
37
  },
34
38
  "homepage": "https://github.com/yowainwright/es-check#readme",
35
39
  "devDependencies": {
36
- "@commitlint/cli": "^12.0.1",
37
- "@commitlint/config-conventional": "^12.0.1",
38
- "@commitlint/prompt": "^12.0.1",
40
+ "@commitlint/cli": "^16.1.0",
41
+ "@commitlint/config-conventional": "^16.0.0",
42
+ "@commitlint/prompt": "^16.1.0",
39
43
  "assert": "^2.0.0",
40
- "codecov": "^3.0.0",
41
- "commitizen": "^4.2.2",
42
- "conventional-changelog-cli": "^2.0.11",
43
- "eslint": "^7.29.0",
44
+ "codecov": "^3.8.3",
45
+ "commitizen": "^4.2.4",
46
+ "conventional-changelog-cli": "^2.2.2",
47
+ "eslint": "^8.7.0",
44
48
  "eslint-config-prettier": "^8.3.0",
45
- "eslint-config-prettier-standard": "^4.0.1",
46
- "eslint-config-standard": "^16.0.3",
47
- "eslint-plugin-import": "^2.23.4",
48
- "eslint-plugin-node": "^11.1.0",
49
- "eslint-plugin-prettier": "^3.4.0",
50
- "eslint-plugin-promise": "^5.1.0",
51
- "husky": "^5.1.3",
52
- "mocha": "^9.0.1",
49
+ "husky": "^7.0.4",
50
+ "mocha": "^9.2.0",
53
51
  "nyc": "^15.1.0",
54
- "prettier": "^2.3.2",
55
- "prettier-config-standard": "^4.0.0"
52
+ "prettier": "^2.5.1"
56
53
  },
57
54
  "dependencies": {
58
- "acorn": "^6.4.1",
59
- "caporal": "1.4.0",
60
- "glob": "^7.1.2"
55
+ "@caporal/core": "^2.0.2",
56
+ "acorn": "^8.7.0",
57
+ "fast-glob": "^3.2.11"
61
58
  },
62
59
  "engines": {
63
60
  "node": ">= 4"
@@ -95,10 +92,10 @@
95
92
  "husky": {
96
93
  "hooks": {
97
94
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
98
- "post-checkout": "if [[ $HUSKY_GIT_PARAMS =~ 1$ ]]; then yarn; fi",
99
- "post-merge": "yarn",
100
- "post-rewrite": "yarn",
101
- "pre-commit": "yarn test && yarn lint"
95
+ "post-checkout": "if [[ $HUSKY_GIT_PARAMS =~ 1$ ]]; then pnpm i -r; fi",
96
+ "post-merge": "pnpm i -r",
97
+ "post-rewrite": "pnpm i -r",
98
+ "pre-commit": "pnpm test && pnpm lint"
102
99
  }
103
100
  }
104
101
  }
package/CHANGELOG.md DELETED
@@ -1,67 +0,0 @@
1
- # [5.1.0](https://github.com/yowainwright/es-check/compare/5.0.0...5.1.0) (2019-11-13)
2
-
3
-
4
- ### Features
5
-
6
- * **index:** Add not option to filter files ([#104](https://github.com/yowainwright/es-check/issues/104)) ([f709c3b](https://github.com/yowainwright/es-check/commit/f709c3b94749f065586843c482880e26ea66f5de))
7
-
8
-
9
-
10
- # [5.0.0](https://github.com/yowainwright/es-check/compare/4.0.0...5.0.0) (2018-11-20)
11
-
12
-
13
- ### Features
14
-
15
- * Update Caporal.js, exit without files, options as flags ([#75](https://github.com/yowainwright/es-check/issues/75)) ([6ea433c](https://github.com/yowainwright/es-check/commit/6ea433cf833fd012d6b46e257cc03d4defe9d677))
16
-
17
-
18
-
19
- # [4.0.0](https://github.com/yowainwright/es-check/compare/3.0.0...4.0.0) (2018-09-13)
20
-
21
-
22
- ### Bug Fixes
23
-
24
- * exit on an invalid es version ([#67](https://github.com/yowainwright/es-check/issues/67)) ([37bf919](https://github.com/yowainwright/es-check/commit/37bf9191c3a1d5eac72848df6a807228089c5df1))
25
-
26
-
27
-
28
- # [3.0.0](https://github.com/yowainwright/es-check/compare/2.3.0...3.0.0) (2018-09-10)
29
-
30
-
31
- ### Bug Fixes
32
-
33
- * should exit with an error if no files were checked ([#58](https://github.com/yowainwright/es-check/issues/58)) ([8e8d61f](https://github.com/yowainwright/es-check/commit/8e8d61f720c2633016ed74c0d2d55a221a2b8db6))
34
-
35
-
36
- ### Features
37
-
38
- * support files that start with hash bang ([#62](https://github.com/yowainwright/es-check/issues/62)) ([06b412c](https://github.com/yowainwright/es-check/commit/06b412c1aade76e8fbc04e47a6d31b5abff56f60))
39
-
40
-
41
-
42
- # [2.3.0](https://github.com/yowainwright/es-check/compare/2.2.0...2.3.0) (2018-09-09)
43
-
44
-
45
- ### Features
46
-
47
- * log version, module, and files ([#59](https://github.com/yowainwright/es-check/issues/59)) ([3de6d31](https://github.com/yowainwright/es-check/commit/3de6d31840efb8332d4b60b63b466f81dc81b213))
48
-
49
-
50
-
51
- # [2.2.0](https://github.com/yowainwright/es-check/compare/2.1.0...2.2.0) (2018-09-04)
52
-
53
-
54
-
55
- # [2.1.0](https://github.com/yowainwright/es-check/compare/270ed6ca82859495cf9f134cb2c8783f14e0b8cc...2.1.0) (2018-08-02)
56
-
57
-
58
- ### Bug Fixes
59
-
60
- * **package:** update acorn to version 5.6.0 ([#45](https://github.com/yowainwright/es-check/issues/45)) ([90d1ae7](https://github.com/yowainwright/es-check/commit/90d1ae7fc752de0f3a4e2eff281db7d730becf62))
61
- * **package:** update acorn to version 5.7.0 ([#47](https://github.com/yowainwright/es-check/issues/47)) ([3826159](https://github.com/yowainwright/es-check/commit/3826159a6059d33623feb7d88fc77c42ff7c2948))
62
- * **package:** update caporal to version 0.10.0 ([#37](https://github.com/yowainwright/es-check/issues/37)) ([f3e0f52](https://github.com/yowainwright/es-check/commit/f3e0f528a12ddb97c21a25a0fbb0e701695666ef))
63
- * **package:** update caporal to version 0.8.0 ([#17](https://github.com/yowainwright/es-check/issues/17)) ([270ed6c](https://github.com/yowainwright/es-check/commit/270ed6ca82859495cf9f134cb2c8783f14e0b8cc))
64
- * **package:** update caporal to version 0.9.0 ([#33](https://github.com/yowainwright/es-check/issues/33)) ([300c0d5](https://github.com/yowainwright/es-check/commit/300c0d5e7b92b7e8b48d5cd07200a7e0d99b0385))
65
-
66
-
67
-