es-check 5.2.2 → 6.1.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.
- package/README.md +5 -1
- package/index.js +56 -25
- package/package.json +21 -16
- 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
|
+
**Version 6:** released with [dropped support for es4](https://github.com/yowainwright/es-check/pull/98/files#r680564074) and a **major version bump of the [acorn](https://github.com/acornjs/acorn) parser**. Thanks so much for your insightful PR, [Noah](https://github.com/noahnu)! For any issues with the newer acorn version or for es4 support, use [version 5.2.4](https://www.npmjs.com/package/es-check/v/5.2.4) (`npm i es-check@5.2.4`). 🎉
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
23
27
|
<p align="center">
|
|
24
28
|
<a href="#get-started">Get Started</a>
|
|
25
29
|
<a href="#why-es-check">Why ES Check?</a>
|
|
@@ -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/
|
|
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
|
|
5
|
+
const { program } = require('@caporal/core')
|
|
6
6
|
const acorn = require('acorn')
|
|
7
7
|
const glob = require('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,17 +20,25 @@ const argsArray = process.argv
|
|
|
20
20
|
* to to test the EcmaScript version of each file
|
|
21
21
|
* - error failures
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
program
|
|
24
24
|
.version(pkg.version)
|
|
25
25
|
.argument(
|
|
26
26
|
'[ecmaVersion]',
|
|
27
|
-
'ecmaVersion to check files against. Can be: es3, es4, es5, es6/es2015, es7/es2016, es8/es2017, es9/es2018, es10/es2019'
|
|
27
|
+
'ecmaVersion to check files against. Can be: es3, es4, es5, es6/es2015, es7/es2016, es8/es2017, es9/es2018, es10/es2019'
|
|
28
|
+
)
|
|
29
|
+
.argument(
|
|
30
|
+
'[files...]',
|
|
31
|
+
'a glob of files to to test the EcmaScript version against'
|
|
28
32
|
)
|
|
29
|
-
.argument('[files...]', 'a glob of files to to test the EcmaScript version against')
|
|
30
33
|
.option('--module', 'use ES modules')
|
|
31
|
-
.option(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
.option(
|
|
35
|
+
'--allow-hash-bang',
|
|
36
|
+
'if the code starts with #! treat it as a comment'
|
|
37
|
+
)
|
|
38
|
+
.option('--not', 'folder or file names to skip', {
|
|
39
|
+
validator: program.ARRAY
|
|
40
|
+
})
|
|
41
|
+
.action(({ logger, args, options }) => {
|
|
34
42
|
const configFilePath = path.resolve(process.cwd(), '.escheckrc')
|
|
35
43
|
|
|
36
44
|
/**
|
|
@@ -39,22 +47,34 @@ prog
|
|
|
39
47
|
* - If one exists, default to those options
|
|
40
48
|
* - If no command line arguments are passed in
|
|
41
49
|
*/
|
|
42
|
-
const config = fs.existsSync(configFilePath)
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const config = fs.existsSync(configFilePath)
|
|
51
|
+
? JSON.parse(fs.readFileSync(configFilePath))
|
|
52
|
+
: {}
|
|
53
|
+
const expectedEcmaVersion = args.ecmaVersion
|
|
54
|
+
? args.ecmaVersion
|
|
55
|
+
: config.ecmaVersion
|
|
56
|
+
const files =
|
|
57
|
+
args.files && args.files.length ? args.files : [].concat(config.files)
|
|
45
58
|
const esmodule = options.module ? options.module : config.module
|
|
46
|
-
const allowHashBang = options.allowHashBang
|
|
47
|
-
|
|
59
|
+
const allowHashBang = options.allowHashBang
|
|
60
|
+
? options.allowHashBang
|
|
61
|
+
: config.allowHashBang
|
|
62
|
+
const pathsToIgnore =
|
|
63
|
+
options.not && options.not.length
|
|
64
|
+
? options.not
|
|
65
|
+
: [].concat(config.not || [])
|
|
48
66
|
|
|
49
67
|
if (!expectedEcmaVersion) {
|
|
50
68
|
logger.error(
|
|
51
|
-
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc'
|
|
69
|
+
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc'
|
|
52
70
|
)
|
|
53
71
|
process.exit(1)
|
|
54
72
|
}
|
|
55
73
|
|
|
56
74
|
if (!files || !files.length) {
|
|
57
|
-
logger.error(
|
|
75
|
+
logger.error(
|
|
76
|
+
'No files were passed in please pass in a list of files to es-check!'
|
|
77
|
+
)
|
|
58
78
|
process.exit(1)
|
|
59
79
|
}
|
|
60
80
|
|
|
@@ -67,8 +87,8 @@ prog
|
|
|
67
87
|
ecmaVersion = '3'
|
|
68
88
|
break
|
|
69
89
|
case 'es4':
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
logger.error('ES4 is not supported.')
|
|
91
|
+
process.exit(1)
|
|
72
92
|
case 'es5':
|
|
73
93
|
ecmaVersion = '5'
|
|
74
94
|
break
|
|
@@ -115,13 +135,15 @@ prog
|
|
|
115
135
|
ecmaVersion = '2021'
|
|
116
136
|
break
|
|
117
137
|
default:
|
|
118
|
-
logger.error(
|
|
138
|
+
logger.error(
|
|
139
|
+
'Invalid ecmaScript version, please pass a valid version, use --help for help'
|
|
140
|
+
)
|
|
119
141
|
process.exit(1)
|
|
120
142
|
}
|
|
121
143
|
|
|
122
144
|
const errArray = []
|
|
123
145
|
const globOpts = { nodir: true }
|
|
124
|
-
const acornOpts = { ecmaVersion, silent: true }
|
|
146
|
+
const acornOpts = { ecmaVersion: parseInt(ecmaVersion, 10), silent: true }
|
|
125
147
|
|
|
126
148
|
const expandedPathsToIgnore = pathsToIgnore.reduce((result, path) => {
|
|
127
149
|
if (path.includes('*')) {
|
|
@@ -134,7 +156,10 @@ prog
|
|
|
134
156
|
const filterForIgnore = (globbedFiles) => {
|
|
135
157
|
if (expandedPathsToIgnore && expandedPathsToIgnore.length > 0) {
|
|
136
158
|
const filtered = globbedFiles.filter(
|
|
137
|
-
(filePath) =>
|
|
159
|
+
(filePath) =>
|
|
160
|
+
!expandedPathsToIgnore.some((ignoreValue) =>
|
|
161
|
+
filePath.includes(ignoreValue)
|
|
162
|
+
)
|
|
138
163
|
)
|
|
139
164
|
return filtered
|
|
140
165
|
}
|
|
@@ -157,7 +182,9 @@ prog
|
|
|
157
182
|
const globbedFiles = glob.sync(pattern, globOpts)
|
|
158
183
|
|
|
159
184
|
if (globbedFiles.length === 0) {
|
|
160
|
-
logger.error(
|
|
185
|
+
logger.error(
|
|
186
|
+
`ES-Check: Did not find any files to check for ${pattern}.`
|
|
187
|
+
)
|
|
161
188
|
process.exit(1)
|
|
162
189
|
}
|
|
163
190
|
|
|
@@ -170,11 +197,13 @@ prog
|
|
|
170
197
|
try {
|
|
171
198
|
acorn.parse(code, acornOpts)
|
|
172
199
|
} catch (err) {
|
|
173
|
-
logger.debug(
|
|
200
|
+
logger.debug(
|
|
201
|
+
`ES-Check: failed to parse file: ${file} \n - error: ${err}`
|
|
202
|
+
)
|
|
174
203
|
const errorObj = {
|
|
175
204
|
err,
|
|
176
205
|
stack: err.stack,
|
|
177
|
-
file
|
|
206
|
+
file
|
|
178
207
|
}
|
|
179
208
|
errArray.push(errorObj)
|
|
180
209
|
}
|
|
@@ -182,7 +211,9 @@ prog
|
|
|
182
211
|
})
|
|
183
212
|
|
|
184
213
|
if (errArray.length > 0) {
|
|
185
|
-
logger.error(
|
|
214
|
+
logger.error(
|
|
215
|
+
`ES-Check: there were ${errArray.length} ES version matching errors.`
|
|
216
|
+
)
|
|
186
217
|
errArray.forEach((o) => {
|
|
187
218
|
logger.info(`
|
|
188
219
|
ES-Check Error:
|
|
@@ -199,4 +230,4 @@ prog
|
|
|
199
230
|
logger.info(`ES-Check: there were no ES version matching errors! 🎉`)
|
|
200
231
|
})
|
|
201
232
|
|
|
202
|
-
|
|
233
|
+
program.run(argsArray)
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-check",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Checks the
|
|
3
|
+
"version": "6.1.0",
|
|
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
|
+
"license": "MIT",
|
|
6
7
|
"files": [
|
|
7
8
|
"index.js"
|
|
8
9
|
],
|
|
@@ -27,31 +28,36 @@
|
|
|
27
28
|
"url": "git+https://github.com/yowainwright/es-check.git"
|
|
28
29
|
},
|
|
29
30
|
"author": "Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in), Brian Gonzalez <me@briangonzalez.org>",
|
|
30
|
-
"license": "MIT",
|
|
31
31
|
"bugs": {
|
|
32
32
|
"url": "https://github.com/yowainwright/es-check/issues"
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/yowainwright/es-check#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@commitlint/cli": "^
|
|
37
|
-
"@commitlint/config-conventional": "^
|
|
38
|
-
"@commitlint/prompt": "^
|
|
39
|
-
"@heartly/eslint-config": "^0.0.2",
|
|
40
|
-
"@heartly/prettier-config": "^0.0.1",
|
|
36
|
+
"@commitlint/cli": "^14.1.0",
|
|
37
|
+
"@commitlint/config-conventional": "^13.1.0",
|
|
38
|
+
"@commitlint/prompt": "^13.1.0",
|
|
41
39
|
"assert": "^2.0.0",
|
|
42
40
|
"codecov": "^3.0.0",
|
|
43
41
|
"commitizen": "^4.2.2",
|
|
44
42
|
"conventional-changelog-cli": "^2.0.11",
|
|
45
|
-
"eslint": "^
|
|
46
|
-
"
|
|
47
|
-
"
|
|
43
|
+
"eslint": "^7.29.0",
|
|
44
|
+
"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": "^4.0.0",
|
|
50
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
51
|
+
"husky": "^7.0.1",
|
|
52
|
+
"mocha": "^9.0.1",
|
|
48
53
|
"nyc": "^15.1.0",
|
|
49
|
-
"prettier": "^2.2
|
|
54
|
+
"prettier": "^2.3.2",
|
|
55
|
+
"prettier-config-standard": "^4.0.0"
|
|
50
56
|
},
|
|
51
57
|
"dependencies": {
|
|
52
|
-
"acorn": "^
|
|
53
|
-
"caporal": "
|
|
54
|
-
"glob": "^7.1.
|
|
58
|
+
"acorn": "^8.4.1",
|
|
59
|
+
"@caporal/core": "^2.0.2",
|
|
60
|
+
"glob": "^7.1.7"
|
|
55
61
|
},
|
|
56
62
|
"engines": {
|
|
57
63
|
"node": ">= 4"
|
|
@@ -74,7 +80,6 @@
|
|
|
74
80
|
"test js version",
|
|
75
81
|
"test ecmascript version"
|
|
76
82
|
],
|
|
77
|
-
"prettier": "@heartly/eslint-config/dist/prettier",
|
|
78
83
|
"commitlint": {
|
|
79
84
|
"extends": [
|
|
80
85
|
"@commitlint/config-conventional"
|
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
|
-
|