es-check 7.0.0 → 7.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 +12 -0
- package/index.js +33 -55
- package/package.json +34 -29
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@ Thanks to Anders for this deeper fix, to [Pavel Starosek](https://github.com/Stu
|
|
|
39
39
|
<a href="#debugging">Debugging</a>
|
|
40
40
|
<a href="#contributing">Contributing</a>
|
|
41
41
|
<a href="/issues">Issues</a>
|
|
42
|
+
<a href="#roadmap">Roadmap</a>
|
|
42
43
|
</p>
|
|
43
44
|
|
|
44
45
|
---
|
|
@@ -213,3 +214,14 @@ ES Check has 3 main dependencies: [acorn](https://github.com/ternjs/acorn/), [gl
|
|
|
213
214
|
- [Ben Junya](https://github.com/MrBenJ)
|
|
214
215
|
- [Jeff Barczewski](https://github.com/jeffbski)
|
|
215
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
|
@@ -25,35 +25,31 @@ program
|
|
|
25
25
|
.version(pkg.version)
|
|
26
26
|
.argument(
|
|
27
27
|
'[ecmaVersion]',
|
|
28
|
-
'ecmaVersion to check files against. Can be: es3, es4, es5, es6/es2015, es7/es2016, es8/es2017, es9/es2018, es10/es2019'
|
|
29
|
-
)
|
|
30
|
-
.argument(
|
|
31
|
-
'[files...]',
|
|
32
|
-
'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',
|
|
33
29
|
)
|
|
30
|
+
.argument('[files...]', 'a glob of files to to test the EcmaScript version against')
|
|
34
31
|
.option('--module', 'use ES modules')
|
|
35
|
-
.option(
|
|
36
|
-
'--allow-hash-bang',
|
|
37
|
-
'if the code starts with #! treat it as a comment'
|
|
38
|
-
)
|
|
32
|
+
.option('--allow-hash-bang', 'if the code starts with #! treat it as a comment')
|
|
39
33
|
.option('--not <files>', 'folder or file names to skip')
|
|
40
34
|
.option('--no-color', 'disable use of colors in output')
|
|
41
35
|
.option('-v, --verbose', 'verbose mode: will also output debug messages')
|
|
42
36
|
.option('--quiet', 'quiet mode: only displays warn and error messages')
|
|
43
37
|
.option(
|
|
44
38
|
'--silent',
|
|
45
|
-
'silent mode: does not output anything, giving no indication of success or failure other than the exit code'
|
|
39
|
+
'silent mode: does not output anything, giving no indication of success or failure other than the exit code',
|
|
46
40
|
)
|
|
47
41
|
.action((ecmaVersionArg, filesArg, options) => {
|
|
48
42
|
const logger = winston.createLogger()
|
|
49
|
-
logger.add(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
)
|
|
57
53
|
|
|
58
54
|
const configFilePath = path.resolve(process.cwd(), '.escheckrc')
|
|
59
55
|
|
|
@@ -63,34 +59,22 @@ program
|
|
|
63
59
|
* - If one exists, default to those options
|
|
64
60
|
* - If no command line arguments are passed in
|
|
65
61
|
*/
|
|
66
|
-
const config = fs.existsSync(configFilePath)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const expectedEcmaVersion = ecmaVersionArg
|
|
70
|
-
? ecmaVersionArg
|
|
71
|
-
: config.ecmaVersion
|
|
72
|
-
const files =
|
|
73
|
-
filesArg && filesArg.length ? filesArg : [].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)
|
|
74
65
|
const esmodule = options.module ? options.module : config.module
|
|
75
|
-
const allowHashBang = options.allowHashBang
|
|
76
|
-
|
|
77
|
-
: config.allowHashBang
|
|
78
|
-
const pathsToIgnore =
|
|
79
|
-
options.not
|
|
80
|
-
? options.not.split(',')
|
|
81
|
-
: [].concat(config.not || [])
|
|
66
|
+
const allowHashBang = options.allowHashBang ? options.allowHashBang : config.allowHashBang
|
|
67
|
+
const pathsToIgnore = options.not ? options.not.split(',') : [].concat(config.not || [])
|
|
82
68
|
|
|
83
69
|
if (!expectedEcmaVersion) {
|
|
84
70
|
logger.error(
|
|
85
|
-
'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',
|
|
86
72
|
)
|
|
87
73
|
process.exit(1)
|
|
88
74
|
}
|
|
89
75
|
|
|
90
76
|
if (!files || !files.length) {
|
|
91
|
-
logger.error(
|
|
92
|
-
'No files were passed in please pass in a list of files to es-check!'
|
|
93
|
-
)
|
|
77
|
+
logger.error('No files were passed in please pass in a list of files to es-check!')
|
|
94
78
|
process.exit(1)
|
|
95
79
|
}
|
|
96
80
|
|
|
@@ -150,10 +134,14 @@ program
|
|
|
150
134
|
case 'es2021':
|
|
151
135
|
ecmaVersion = '2021'
|
|
152
136
|
break
|
|
137
|
+
case 'es2022':
|
|
138
|
+
ecmaVersion = '2022'
|
|
139
|
+
break
|
|
140
|
+
case 'es2023':
|
|
141
|
+
ecmaVersion = '2023'
|
|
142
|
+
break
|
|
153
143
|
default:
|
|
154
|
-
logger.error(
|
|
155
|
-
'Invalid ecmaScript version, please pass a valid version, use --help for help'
|
|
156
|
-
)
|
|
144
|
+
logger.error('Invalid ecmaScript version, please pass a valid version, use --help for help')
|
|
157
145
|
process.exit(1)
|
|
158
146
|
}
|
|
159
147
|
|
|
@@ -172,10 +160,7 @@ program
|
|
|
172
160
|
const filterForIgnore = (globbedFiles) => {
|
|
173
161
|
if (expandedPathsToIgnore && expandedPathsToIgnore.length > 0) {
|
|
174
162
|
const filtered = globbedFiles.filter(
|
|
175
|
-
(filePath) =>
|
|
176
|
-
!expandedPathsToIgnore.some((ignoreValue) =>
|
|
177
|
-
filePath.includes(ignoreValue)
|
|
178
|
-
)
|
|
163
|
+
(filePath) => !expandedPathsToIgnore.some((ignoreValue) => filePath.includes(ignoreValue)),
|
|
179
164
|
)
|
|
180
165
|
return filtered
|
|
181
166
|
}
|
|
@@ -198,9 +183,7 @@ program
|
|
|
198
183
|
const globbedFiles = glob.sync(pattern, globOpts)
|
|
199
184
|
|
|
200
185
|
if (globbedFiles.length === 0) {
|
|
201
|
-
logger.error(
|
|
202
|
-
`ES-Check: Did not find any files to check for ${pattern}.`
|
|
203
|
-
)
|
|
186
|
+
logger.error(`ES-Check: Did not find any files to check for ${pattern}.`)
|
|
204
187
|
process.exit(1)
|
|
205
188
|
}
|
|
206
189
|
|
|
@@ -208,18 +191,15 @@ program
|
|
|
208
191
|
|
|
209
192
|
filteredFiles.forEach((file) => {
|
|
210
193
|
const code = fs.readFileSync(file, 'utf8')
|
|
211
|
-
|
|
212
194
|
logger.debug(`ES-Check: checking ${file}`)
|
|
213
195
|
try {
|
|
214
196
|
acorn.parse(code, acornOpts)
|
|
215
197
|
} catch (err) {
|
|
216
|
-
logger.debug(
|
|
217
|
-
`ES-Check: failed to parse file: ${file} \n - error: ${err}`
|
|
218
|
-
)
|
|
198
|
+
logger.debug(`ES-Check: failed to parse file: ${file} \n - error: ${err}`)
|
|
219
199
|
const errorObj = {
|
|
220
200
|
err,
|
|
221
201
|
stack: err.stack,
|
|
222
|
-
file
|
|
202
|
+
file,
|
|
223
203
|
}
|
|
224
204
|
errArray.push(errorObj)
|
|
225
205
|
}
|
|
@@ -227,9 +207,7 @@ program
|
|
|
227
207
|
})
|
|
228
208
|
|
|
229
209
|
if (errArray.length > 0) {
|
|
230
|
-
logger.error(
|
|
231
|
-
`ES-Check: there were ${errArray.length} ES version matching errors.`
|
|
232
|
-
)
|
|
210
|
+
logger.error(`ES-Check: there were ${errArray.length} ES version matching errors.`)
|
|
233
211
|
errArray.forEach((o) => {
|
|
234
212
|
logger.info(`
|
|
235
213
|
ES-Check Error:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-check",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.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",
|
|
@@ -11,17 +11,22 @@
|
|
|
11
11
|
"es-check": "index.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
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'",
|
|
19
20
|
"lint": "eslint index.js --fix",
|
|
20
21
|
"lint:ci": "eslint index.js",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"pre-commit": "pnpm lint && pnpm test",
|
|
23
|
+
"prepare": "is-ci || pnpm husky-setup",
|
|
24
|
+
"prepublishOnly": "pnpm test",
|
|
25
|
+
"release": "release-it",
|
|
23
26
|
"report:coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",
|
|
24
|
-
"
|
|
27
|
+
"setup": "pnpm install --reporter=silent",
|
|
28
|
+
"test": "nyc mocha test.js --timeout 10s --coverage",
|
|
29
|
+
"update": "codependence --update"
|
|
25
30
|
},
|
|
26
31
|
"repository": {
|
|
27
32
|
"type": "git",
|
|
@@ -33,26 +38,30 @@
|
|
|
33
38
|
},
|
|
34
39
|
"homepage": "https://github.com/yowainwright/es-check#readme",
|
|
35
40
|
"devDependencies": {
|
|
36
|
-
"@commitlint/cli": "
|
|
37
|
-
"@commitlint/config-conventional": "
|
|
38
|
-
"@commitlint/prompt": "
|
|
41
|
+
"@commitlint/cli": "17.4.2",
|
|
42
|
+
"@commitlint/config-conventional": "17.4.2",
|
|
43
|
+
"@commitlint/prompt": "17.4.2",
|
|
39
44
|
"assert": "^2.0.0",
|
|
40
45
|
"codecov": "^3.8.3",
|
|
41
|
-
"
|
|
46
|
+
"codependence": "^0.2.6",
|
|
47
|
+
"commitizen": "4.3.0",
|
|
42
48
|
"conventional-changelog-cli": "^2.2.2",
|
|
43
|
-
"eslint": "
|
|
44
|
-
"eslint-config-prettier": "
|
|
45
|
-
"husky": "
|
|
46
|
-
"
|
|
49
|
+
"eslint": "8.32.0",
|
|
50
|
+
"eslint-config-prettier": "8.6.0",
|
|
51
|
+
"husky": "8.0.3",
|
|
52
|
+
"is-ci": "^3.0.1",
|
|
53
|
+
"mocha": "^10.2.0",
|
|
47
54
|
"nyc": "^15.1.0",
|
|
48
|
-
"
|
|
55
|
+
"path-exists-cli": "^2.0.0",
|
|
56
|
+
"prettier": "2.8.3",
|
|
57
|
+
"release-it": "15.6.0"
|
|
49
58
|
},
|
|
50
59
|
"dependencies": {
|
|
51
|
-
"acorn": "
|
|
52
|
-
"commander": "
|
|
53
|
-
"fast-glob": "^3.2.
|
|
60
|
+
"acorn": "8.8.2",
|
|
61
|
+
"commander": "10.0.0",
|
|
62
|
+
"fast-glob": "^3.2.12",
|
|
54
63
|
"supports-color": "^8.1.1",
|
|
55
|
-
"winston": "^3.2
|
|
64
|
+
"winston": "^3.8.2"
|
|
56
65
|
},
|
|
57
66
|
"engines": {
|
|
58
67
|
"node": ">= 4"
|
|
@@ -87,13 +96,9 @@
|
|
|
87
96
|
]
|
|
88
97
|
}
|
|
89
98
|
},
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"post-checkout": "if [[ $HUSKY_GIT_PARAMS =~ 1$ ]]; then pnpm i -r; fi",
|
|
94
|
-
"post-merge": "pnpm i -r",
|
|
95
|
-
"post-rewrite": "pnpm i -r",
|
|
96
|
-
"pre-commit": "pnpm test && pnpm lint"
|
|
99
|
+
"release-it": {
|
|
100
|
+
"github": {
|
|
101
|
+
"release": true
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
}
|