es-check 5.2.0 → 5.2.4
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 +3 -2
- package/index.js +53 -17
- package/package.json +19 -14
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ index.js es-check <ecmaVersion> [files...]
|
|
|
122
122
|
**Not**
|
|
123
123
|
|
|
124
124
|
```sh
|
|
125
|
-
--not=folderName1,folderName2 An array of file/folder names that you would like to ignore. Defaults to `[]`.
|
|
125
|
+
--not=folderName1,folderName2 An array of file/folder names or globs that you would like to ignore. Defaults to `[]`.
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
### Global Options
|
|
@@ -165,7 +165,8 @@ Here's an example of what an `.escheckrc` file will look like:
|
|
|
165
165
|
{
|
|
166
166
|
"ecmaVersion": "es6",
|
|
167
167
|
"module": false,
|
|
168
|
-
"files": "./dist/**/*.js"
|
|
168
|
+
"files": "./dist/**/*.js",
|
|
169
|
+
"not": ["./dist/skip/*.js"]
|
|
169
170
|
}
|
|
170
171
|
```
|
|
171
172
|
|
package/index.js
CHANGED
|
@@ -24,11 +24,17 @@ prog
|
|
|
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(
|
|
34
|
+
.option(
|
|
35
|
+
'--allow-hash-bang',
|
|
36
|
+
'if the code starts with #! treat it as a comment'
|
|
37
|
+
)
|
|
32
38
|
.option('--not', 'folder or file names to skip', prog.LIST)
|
|
33
39
|
.action((args, options, logger) => {
|
|
34
40
|
const configFilePath = path.resolve(process.cwd(), '.escheckrc')
|
|
@@ -39,22 +45,32 @@ prog
|
|
|
39
45
|
* - If one exists, default to those options
|
|
40
46
|
* - If no command line arguments are passed in
|
|
41
47
|
*/
|
|
42
|
-
const config = fs.existsSync(configFilePath)
|
|
43
|
-
|
|
48
|
+
const config = fs.existsSync(configFilePath)
|
|
49
|
+
? JSON.parse(fs.readFileSync(configFilePath))
|
|
50
|
+
: {}
|
|
51
|
+
const expectedEcmaVersion = args.ecmaVersion
|
|
52
|
+
? args.ecmaVersion
|
|
53
|
+
: config.ecmaVersion
|
|
44
54
|
const files = args.files.length ? args.files : [].concat(config.files)
|
|
45
55
|
const esmodule = options.module ? options.module : config.module
|
|
46
|
-
const allowHashBang = options.allowHashBang
|
|
47
|
-
|
|
56
|
+
const allowHashBang = options.allowHashBang
|
|
57
|
+
? options.allowHashBang
|
|
58
|
+
: config.allowHashBang
|
|
59
|
+
const pathsToIgnore = options.not.length
|
|
60
|
+
? options.not
|
|
61
|
+
: [].concat(config.not || [])
|
|
48
62
|
|
|
49
63
|
if (!expectedEcmaVersion) {
|
|
50
64
|
logger.error(
|
|
51
|
-
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc'
|
|
65
|
+
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc'
|
|
52
66
|
)
|
|
53
67
|
process.exit(1)
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
if (!files || !files.length) {
|
|
57
|
-
logger.error(
|
|
71
|
+
logger.error(
|
|
72
|
+
'No files were passed in please pass in a list of files to es-check!'
|
|
73
|
+
)
|
|
58
74
|
process.exit(1)
|
|
59
75
|
}
|
|
60
76
|
|
|
@@ -115,17 +131,31 @@ prog
|
|
|
115
131
|
ecmaVersion = '2021'
|
|
116
132
|
break
|
|
117
133
|
default:
|
|
118
|
-
logger.error(
|
|
134
|
+
logger.error(
|
|
135
|
+
'Invalid ecmaScript version, please pass a valid version, use --help for help'
|
|
136
|
+
)
|
|
119
137
|
process.exit(1)
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
const errArray = []
|
|
123
141
|
const globOpts = { nodir: true }
|
|
124
142
|
const acornOpts = { ecmaVersion, silent: true }
|
|
143
|
+
|
|
144
|
+
const expandedPathsToIgnore = pathsToIgnore.reduce((result, path) => {
|
|
145
|
+
if (path.includes('*')) {
|
|
146
|
+
return result.concat(glob.sync(path, globOpts))
|
|
147
|
+
} else {
|
|
148
|
+
return result.concat(path)
|
|
149
|
+
}
|
|
150
|
+
}, [])
|
|
151
|
+
|
|
125
152
|
const filterForIgnore = (globbedFiles) => {
|
|
126
|
-
if (
|
|
153
|
+
if (expandedPathsToIgnore && expandedPathsToIgnore.length > 0) {
|
|
127
154
|
const filtered = globbedFiles.filter(
|
|
128
|
-
(filePath) =>
|
|
155
|
+
(filePath) =>
|
|
156
|
+
!expandedPathsToIgnore.some((ignoreValue) =>
|
|
157
|
+
filePath.includes(ignoreValue)
|
|
158
|
+
)
|
|
129
159
|
)
|
|
130
160
|
return filtered
|
|
131
161
|
}
|
|
@@ -148,7 +178,9 @@ prog
|
|
|
148
178
|
const globbedFiles = glob.sync(pattern, globOpts)
|
|
149
179
|
|
|
150
180
|
if (globbedFiles.length === 0) {
|
|
151
|
-
logger.error(
|
|
181
|
+
logger.error(
|
|
182
|
+
`ES-Check: Did not find any files to check for ${pattern}.`
|
|
183
|
+
)
|
|
152
184
|
process.exit(1)
|
|
153
185
|
}
|
|
154
186
|
|
|
@@ -161,11 +193,13 @@ prog
|
|
|
161
193
|
try {
|
|
162
194
|
acorn.parse(code, acornOpts)
|
|
163
195
|
} catch (err) {
|
|
164
|
-
logger.debug(
|
|
196
|
+
logger.debug(
|
|
197
|
+
`ES-Check: failed to parse file: ${file} \n - error: ${err}`
|
|
198
|
+
)
|
|
165
199
|
const errorObj = {
|
|
166
200
|
err,
|
|
167
201
|
stack: err.stack,
|
|
168
|
-
file
|
|
202
|
+
file
|
|
169
203
|
}
|
|
170
204
|
errArray.push(errorObj)
|
|
171
205
|
}
|
|
@@ -173,7 +207,9 @@ prog
|
|
|
173
207
|
})
|
|
174
208
|
|
|
175
209
|
if (errArray.length > 0) {
|
|
176
|
-
logger.error(
|
|
210
|
+
logger.error(
|
|
211
|
+
`ES-Check: there were ${errArray.length} ES version matching errors.`
|
|
212
|
+
)
|
|
177
213
|
errArray.forEach((o) => {
|
|
178
214
|
logger.info(`
|
|
179
215
|
ES-Check Error:
|
|
@@ -187,7 +223,7 @@ prog
|
|
|
187
223
|
})
|
|
188
224
|
process.exit(1)
|
|
189
225
|
}
|
|
190
|
-
logger.
|
|
226
|
+
logger.info(`ES-Check: there were no ES version matching errors! 🎉`)
|
|
191
227
|
})
|
|
192
228
|
|
|
193
229
|
prog.parse(argsArray)
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-check",
|
|
3
|
-
"version": "5.2.
|
|
4
|
-
"description": "Checks the
|
|
3
|
+
"version": "5.2.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
|
+
"license": "MIT",
|
|
6
7
|
"files": [
|
|
7
8
|
"index.js"
|
|
8
9
|
],
|
|
@@ -27,26 +28,31 @@
|
|
|
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": "^12.0.1",
|
|
37
|
+
"@commitlint/config-conventional": "^12.0.1",
|
|
38
|
+
"@commitlint/prompt": "^12.0.1",
|
|
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": "^3.4.0",
|
|
50
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
51
|
+
"husky": "^5.1.3",
|
|
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
58
|
"acorn": "^6.4.1",
|
|
@@ -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"
|
|
@@ -87,7 +92,7 @@
|
|
|
87
92
|
]
|
|
88
93
|
}
|
|
89
94
|
},
|
|
90
|
-
|
|
95
|
+
"husky": {
|
|
91
96
|
"hooks": {
|
|
92
97
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
93
98
|
"post-checkout": "if [[ $HUSKY_GIT_PARAMS =~ 1$ ]]; then yarn; fi",
|