es-check 6.2.0 → 7.0.1
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 +19 -1
- package/index.js +39 -51
- package/package.json +27 -27
package/README.md
CHANGED
|
@@ -20,7 +20,13 @@ Ensuring that JavaScript files can pass ES Check is important in a [modular and
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Version 7 🎉
|
|
24
|
+
|
|
25
|
+
Thanks to the efforts of [Anders Kaseorg](https://github.com/andersk), ES Check has switched to [Commander](https://www.npmjs.com/package/commander)! There appears to be no breaking issues but this update is being published as a major release for your ease-of-use. Please reach out with observations or pull requests features/fixes!
|
|
26
|
+
|
|
27
|
+
This update was made for security purposes—dependencies not being maintained.
|
|
28
|
+
|
|
29
|
+
Thanks to Anders for this deeper fix, to [Pavel Starosek](https://github.com/StudioMaX) for the initial issue and support, and to [Alexander Pepper](https://github.com/apepper) for digging into this issue more!
|
|
24
30
|
|
|
25
31
|
---
|
|
26
32
|
|
|
@@ -33,6 +39,7 @@ Ensuring that JavaScript files can pass ES Check is important in a [modular and
|
|
|
33
39
|
<a href="#debugging">Debugging</a>
|
|
34
40
|
<a href="#contributing">Contributing</a>
|
|
35
41
|
<a href="/issues">Issues</a>
|
|
42
|
+
<a href="#roadmap">Roadmap</a>
|
|
36
43
|
</p>
|
|
37
44
|
|
|
38
45
|
---
|
|
@@ -207,3 +214,14 @@ ES Check has 3 main dependencies: [acorn](https://github.com/ternjs/acorn/), [gl
|
|
|
207
214
|
- [Ben Junya](https://github.com/MrBenJ)
|
|
208
215
|
- [Jeff Barczewski](https://github.com/jeffbski)
|
|
209
216
|
- [Brandon Casey](https://github.com/BrandonOCasey)
|
|
217
|
+
|
|
218
|
+
### Roadmap
|
|
219
|
+
|
|
220
|
+
- Provide compilation step to support esm
|
|
221
|
+
- non-user-facing
|
|
222
|
+
- required to keep package dependencies up-to-date as more dependencies are ESM-only
|
|
223
|
+
- Provide checks for _theoretical_ keywork words
|
|
224
|
+
- Things like `Map` and `Object.assign` are not keywords that fail ECMAScript
|
|
225
|
+
compilation depending on specific versions of ECMAScript. However, they hint at additions to ECMAScript that previous version did not support.
|
|
226
|
+
- This feature will enhance an already built-in confiration feature to provide more out-of-the-box support for ECMAScript checking.
|
|
227
|
+
- If enabled, this feature will warn (or fail) based on _theoretical_ ECMAScript keywords.
|
package/index.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict'
|
|
4
4
|
|
|
5
|
-
const { program } = require('
|
|
5
|
+
const { program } = require('commander')
|
|
6
6
|
const acorn = require('acorn')
|
|
7
7
|
const glob = require('fast-glob')
|
|
8
8
|
const fs = require('fs')
|
|
9
9
|
const path = require('path')
|
|
10
|
+
const supportsColor = require('supports-color')
|
|
11
|
+
const winston = require('winston')
|
|
10
12
|
|
|
11
13
|
const pkg = require('./package.json')
|
|
12
|
-
const argsArray = process.argv.slice(2)
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* es-check 🏆
|
|
@@ -24,21 +25,32 @@ program
|
|
|
24
25
|
.version(pkg.version)
|
|
25
26
|
.argument(
|
|
26
27
|
'[ecmaVersion]',
|
|
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
|
+
'ecmaVersion to check files against. Can be: es3, es4, es5, es6/es2015, es7/es2016, es8/es2017, es9/es2018, es10/es2019',
|
|
32
29
|
)
|
|
30
|
+
.argument('[files...]', 'a glob of files to to test the EcmaScript version against')
|
|
33
31
|
.option('--module', 'use ES modules')
|
|
32
|
+
.option('--allow-hash-bang', 'if the code starts with #! treat it as a comment')
|
|
33
|
+
.option('--not <files>', 'folder or file names to skip')
|
|
34
|
+
.option('--no-color', 'disable use of colors in output')
|
|
35
|
+
.option('-v, --verbose', 'verbose mode: will also output debug messages')
|
|
36
|
+
.option('--quiet', 'quiet mode: only displays warn and error messages')
|
|
34
37
|
.option(
|
|
35
|
-
'--
|
|
36
|
-
'
|
|
38
|
+
'--silent',
|
|
39
|
+
'silent mode: does not output anything, giving no indication of success or failure other than the exit code',
|
|
37
40
|
)
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
.action((ecmaVersionArg, filesArg, options) => {
|
|
42
|
+
const logger = winston.createLogger()
|
|
43
|
+
logger.add(
|
|
44
|
+
new winston.transports.Console({
|
|
45
|
+
silent: options.silent,
|
|
46
|
+
level: options.verbose ? 'silly' : options.quiet ? 'warn' : 'info',
|
|
47
|
+
format: winston.format.combine(
|
|
48
|
+
...(supportsColor.stdout ? [winston.format.colorize()] : []),
|
|
49
|
+
winston.format.simple(),
|
|
50
|
+
),
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
53
|
+
|
|
42
54
|
const configFilePath = path.resolve(process.cwd(), '.escheckrc')
|
|
43
55
|
|
|
44
56
|
/**
|
|
@@ -47,34 +59,22 @@ program
|
|
|
47
59
|
* - If one exists, default to those options
|
|
48
60
|
* - If no command line arguments are passed in
|
|
49
61
|
*/
|
|
50
|
-
const config = fs.existsSync(configFilePath)
|
|
51
|
-
|
|
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)
|
|
62
|
+
const config = fs.existsSync(configFilePath) ? JSON.parse(fs.readFileSync(configFilePath)) : {}
|
|
63
|
+
const expectedEcmaVersion = ecmaVersionArg ? ecmaVersionArg : config.ecmaVersion
|
|
64
|
+
const files = filesArg && filesArg.length ? filesArg : [].concat(config.files)
|
|
58
65
|
const esmodule = options.module ? options.module : config.module
|
|
59
|
-
const allowHashBang = options.allowHashBang
|
|
60
|
-
|
|
61
|
-
: config.allowHashBang
|
|
62
|
-
const pathsToIgnore =
|
|
63
|
-
options.not && options.not.length
|
|
64
|
-
? options.not
|
|
65
|
-
: [].concat(config.not || [])
|
|
66
|
+
const allowHashBang = options.allowHashBang ? options.allowHashBang : config.allowHashBang
|
|
67
|
+
const pathsToIgnore = options.not ? options.not.split(',') : [].concat(config.not || [])
|
|
66
68
|
|
|
67
69
|
if (!expectedEcmaVersion) {
|
|
68
70
|
logger.error(
|
|
69
|
-
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc'
|
|
71
|
+
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc',
|
|
70
72
|
)
|
|
71
73
|
process.exit(1)
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
if (!files || !files.length) {
|
|
75
|
-
logger.error(
|
|
76
|
-
'No files were passed in please pass in a list of files to es-check!'
|
|
77
|
-
)
|
|
77
|
+
logger.error('No files were passed in please pass in a list of files to es-check!')
|
|
78
78
|
process.exit(1)
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -135,9 +135,7 @@ program
|
|
|
135
135
|
ecmaVersion = '2021'
|
|
136
136
|
break
|
|
137
137
|
default:
|
|
138
|
-
logger.error(
|
|
139
|
-
'Invalid ecmaScript version, please pass a valid version, use --help for help'
|
|
140
|
-
)
|
|
138
|
+
logger.error('Invalid ecmaScript version, please pass a valid version, use --help for help')
|
|
141
139
|
process.exit(1)
|
|
142
140
|
}
|
|
143
141
|
|
|
@@ -156,10 +154,7 @@ program
|
|
|
156
154
|
const filterForIgnore = (globbedFiles) => {
|
|
157
155
|
if (expandedPathsToIgnore && expandedPathsToIgnore.length > 0) {
|
|
158
156
|
const filtered = globbedFiles.filter(
|
|
159
|
-
(filePath) =>
|
|
160
|
-
!expandedPathsToIgnore.some((ignoreValue) =>
|
|
161
|
-
filePath.includes(ignoreValue)
|
|
162
|
-
)
|
|
157
|
+
(filePath) => !expandedPathsToIgnore.some((ignoreValue) => filePath.includes(ignoreValue)),
|
|
163
158
|
)
|
|
164
159
|
return filtered
|
|
165
160
|
}
|
|
@@ -182,9 +177,7 @@ program
|
|
|
182
177
|
const globbedFiles = glob.sync(pattern, globOpts)
|
|
183
178
|
|
|
184
179
|
if (globbedFiles.length === 0) {
|
|
185
|
-
logger.error(
|
|
186
|
-
`ES-Check: Did not find any files to check for ${pattern}.`
|
|
187
|
-
)
|
|
180
|
+
logger.error(`ES-Check: Did not find any files to check for ${pattern}.`)
|
|
188
181
|
process.exit(1)
|
|
189
182
|
}
|
|
190
183
|
|
|
@@ -192,18 +185,15 @@ program
|
|
|
192
185
|
|
|
193
186
|
filteredFiles.forEach((file) => {
|
|
194
187
|
const code = fs.readFileSync(file, 'utf8')
|
|
195
|
-
|
|
196
188
|
logger.debug(`ES-Check: checking ${file}`)
|
|
197
189
|
try {
|
|
198
190
|
acorn.parse(code, acornOpts)
|
|
199
191
|
} catch (err) {
|
|
200
|
-
logger.debug(
|
|
201
|
-
`ES-Check: failed to parse file: ${file} \n - error: ${err}`
|
|
202
|
-
)
|
|
192
|
+
logger.debug(`ES-Check: failed to parse file: ${file} \n - error: ${err}`)
|
|
203
193
|
const errorObj = {
|
|
204
194
|
err,
|
|
205
195
|
stack: err.stack,
|
|
206
|
-
file
|
|
196
|
+
file,
|
|
207
197
|
}
|
|
208
198
|
errArray.push(errorObj)
|
|
209
199
|
}
|
|
@@ -211,9 +201,7 @@ program
|
|
|
211
201
|
})
|
|
212
202
|
|
|
213
203
|
if (errArray.length > 0) {
|
|
214
|
-
logger.error(
|
|
215
|
-
`ES-Check: there were ${errArray.length} ES version matching errors.`
|
|
216
|
-
)
|
|
204
|
+
logger.error(`ES-Check: there were ${errArray.length} ES version matching errors.`)
|
|
217
205
|
errArray.forEach((o) => {
|
|
218
206
|
logger.info(`
|
|
219
207
|
ES-Check Error:
|
|
@@ -230,4 +218,4 @@ program
|
|
|
230
218
|
logger.info(`ES-Check: there were no ES version matching errors! 🎉`)
|
|
231
219
|
})
|
|
232
220
|
|
|
233
|
-
program.
|
|
221
|
+
program.parse()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-check",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
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,21 +10,21 @@
|
|
|
10
10
|
"bin": {
|
|
11
11
|
"es-check": "index.js"
|
|
12
12
|
},
|
|
13
|
-
"resolutions": {
|
|
14
|
-
"ansi-regex": "5.0.1"
|
|
15
|
-
},
|
|
16
13
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
14
|
+
"commit": "git-cz",
|
|
15
|
+
"commit-msg": "commitlint --edit $1",
|
|
16
|
+
"husky-setup": "path-exists .husky/commit-msg || (husky install && pnpm husky-setup:commit-msg && pnpm husky-setup:post-merge && pnpm husky-setup:pre-commit)",
|
|
17
|
+
"husky-setup:commit-msg": "npx husky add .husky/commit-msg 'pnpm run commit-msg'",
|
|
18
|
+
"husky-setup:post-merge": "npx husky add .husky/post-merge 'pnpm run setup'",
|
|
19
|
+
"husky-setup:pre-commit": "npx husky add .husky/pre-commit 'pnpm run pre-commit'",
|
|
22
20
|
"lint": "eslint index.js --fix",
|
|
23
21
|
"lint:ci": "eslint index.js",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
22
|
+
"pre-commit": "pnpm lint && pnpm test",
|
|
23
|
+
"prepare": "is-ci || pnpm husky-setup",
|
|
24
|
+
"prepublishOnly": "pnpm test",
|
|
25
|
+
"release": "release-it",
|
|
27
26
|
"report:coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",
|
|
27
|
+
"setup": "pnpm install --reporter=silent",
|
|
28
28
|
"test": "nyc mocha test.js --timeout 10s --coverage"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
@@ -37,24 +37,28 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/yowainwright/es-check#readme",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@commitlint/cli": "^
|
|
41
|
-
"@commitlint/config-conventional": "^
|
|
42
|
-
"@commitlint/prompt": "^
|
|
40
|
+
"@commitlint/cli": "^17.0.3",
|
|
41
|
+
"@commitlint/config-conventional": "^17.0.3",
|
|
42
|
+
"@commitlint/prompt": "^17.0.3",
|
|
43
43
|
"assert": "^2.0.0",
|
|
44
44
|
"codecov": "^3.8.3",
|
|
45
45
|
"commitizen": "^4.2.4",
|
|
46
46
|
"conventional-changelog-cli": "^2.2.2",
|
|
47
47
|
"eslint": "^8.7.0",
|
|
48
48
|
"eslint-config-prettier": "^8.3.0",
|
|
49
|
-
"husky": "^
|
|
50
|
-
"mocha": "^
|
|
49
|
+
"husky": "^8.0.1",
|
|
50
|
+
"mocha": "^10.0.0",
|
|
51
51
|
"nyc": "^15.1.0",
|
|
52
|
-
"
|
|
52
|
+
"path-exists-cli": "^2.0.0",
|
|
53
|
+
"prettier": "^2.5.1",
|
|
54
|
+
"release-it": "^15.1.3"
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {
|
|
55
|
-
"@caporal/core": "^2.0.2",
|
|
56
57
|
"acorn": "^8.7.0",
|
|
57
|
-
"
|
|
58
|
+
"commander": "^9.4.0",
|
|
59
|
+
"fast-glob": "^3.2.11",
|
|
60
|
+
"supports-color": "^8.1.1",
|
|
61
|
+
"winston": "^3.2.1"
|
|
58
62
|
},
|
|
59
63
|
"engines": {
|
|
60
64
|
"node": ">= 4"
|
|
@@ -89,13 +93,9 @@
|
|
|
89
93
|
]
|
|
90
94
|
}
|
|
91
95
|
},
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
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"
|
|
96
|
+
"release-it": {
|
|
97
|
+
"github": {
|
|
98
|
+
"release": true
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|