es-check 7.0.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 +12 -0
- package/index.js +27 -55
- package/package.json +18 -16
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
|
|
|
@@ -151,9 +135,7 @@ program
|
|
|
151
135
|
ecmaVersion = '2021'
|
|
152
136
|
break
|
|
153
137
|
default:
|
|
154
|
-
logger.error(
|
|
155
|
-
'Invalid ecmaScript version, please pass a valid version, use --help for help'
|
|
156
|
-
)
|
|
138
|
+
logger.error('Invalid ecmaScript version, please pass a valid version, use --help for help')
|
|
157
139
|
process.exit(1)
|
|
158
140
|
}
|
|
159
141
|
|
|
@@ -172,10 +154,7 @@ program
|
|
|
172
154
|
const filterForIgnore = (globbedFiles) => {
|
|
173
155
|
if (expandedPathsToIgnore && expandedPathsToIgnore.length > 0) {
|
|
174
156
|
const filtered = globbedFiles.filter(
|
|
175
|
-
(filePath) =>
|
|
176
|
-
!expandedPathsToIgnore.some((ignoreValue) =>
|
|
177
|
-
filePath.includes(ignoreValue)
|
|
178
|
-
)
|
|
157
|
+
(filePath) => !expandedPathsToIgnore.some((ignoreValue) => filePath.includes(ignoreValue)),
|
|
179
158
|
)
|
|
180
159
|
return filtered
|
|
181
160
|
}
|
|
@@ -198,9 +177,7 @@ program
|
|
|
198
177
|
const globbedFiles = glob.sync(pattern, globOpts)
|
|
199
178
|
|
|
200
179
|
if (globbedFiles.length === 0) {
|
|
201
|
-
logger.error(
|
|
202
|
-
`ES-Check: Did not find any files to check for ${pattern}.`
|
|
203
|
-
)
|
|
180
|
+
logger.error(`ES-Check: Did not find any files to check for ${pattern}.`)
|
|
204
181
|
process.exit(1)
|
|
205
182
|
}
|
|
206
183
|
|
|
@@ -208,18 +185,15 @@ program
|
|
|
208
185
|
|
|
209
186
|
filteredFiles.forEach((file) => {
|
|
210
187
|
const code = fs.readFileSync(file, 'utf8')
|
|
211
|
-
|
|
212
188
|
logger.debug(`ES-Check: checking ${file}`)
|
|
213
189
|
try {
|
|
214
190
|
acorn.parse(code, acornOpts)
|
|
215
191
|
} catch (err) {
|
|
216
|
-
logger.debug(
|
|
217
|
-
`ES-Check: failed to parse file: ${file} \n - error: ${err}`
|
|
218
|
-
)
|
|
192
|
+
logger.debug(`ES-Check: failed to parse file: ${file} \n - error: ${err}`)
|
|
219
193
|
const errorObj = {
|
|
220
194
|
err,
|
|
221
195
|
stack: err.stack,
|
|
222
|
-
file
|
|
196
|
+
file,
|
|
223
197
|
}
|
|
224
198
|
errArray.push(errorObj)
|
|
225
199
|
}
|
|
@@ -227,9 +201,7 @@ program
|
|
|
227
201
|
})
|
|
228
202
|
|
|
229
203
|
if (errArray.length > 0) {
|
|
230
|
-
logger.error(
|
|
231
|
-
`ES-Check: there were ${errArray.length} ES version matching errors.`
|
|
232
|
-
)
|
|
204
|
+
logger.error(`ES-Check: there were ${errArray.length} ES version matching errors.`)
|
|
233
205
|
errArray.forEach((o) => {
|
|
234
206
|
logger.info(`
|
|
235
207
|
ES-Check Error:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-check",
|
|
3
|
-
"version": "7.0.
|
|
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",
|
|
@@ -11,16 +11,20 @@
|
|
|
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",
|
|
27
|
+
"setup": "pnpm install --reporter=silent",
|
|
24
28
|
"test": "nyc mocha test.js --timeout 10s --coverage"
|
|
25
29
|
},
|
|
26
30
|
"repository": {
|
|
@@ -45,7 +49,9 @@
|
|
|
45
49
|
"husky": "^8.0.1",
|
|
46
50
|
"mocha": "^10.0.0",
|
|
47
51
|
"nyc": "^15.1.0",
|
|
48
|
-
"
|
|
52
|
+
"path-exists-cli": "^2.0.0",
|
|
53
|
+
"prettier": "^2.5.1",
|
|
54
|
+
"release-it": "^15.1.3"
|
|
49
55
|
},
|
|
50
56
|
"dependencies": {
|
|
51
57
|
"acorn": "^8.7.0",
|
|
@@ -87,13 +93,9 @@
|
|
|
87
93
|
]
|
|
88
94
|
}
|
|
89
95
|
},
|
|
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"
|
|
96
|
+
"release-it": {
|
|
97
|
+
"github": {
|
|
98
|
+
"release": true
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
}
|