es-check 5.2.1 → 6.0.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.
Files changed (4) hide show
  1. package/README.md +4 -0
  2. package/index.js +45 -18
  3. package/package.json +22 -17
  4. 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>&nbsp;&nbsp;
25
29
  <a href="#why-es-check">Why ES Check?</a>&nbsp;&nbsp;
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('--allow-hash-bang', 'if the code starts with #! treat it as a comment')
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) ? JSON.parse(fs.readFileSync(configFilePath)) : {}
43
- const expectedEcmaVersion = args.ecmaVersion ? args.ecmaVersion : config.ecmaVersion
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 ? options.allowHashBang : config.allowHashBang
47
- const pathsToIgnore = options.not.length ? options.not : [].concat(config.not)
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('No files were passed in please pass in a list of files to es-check!')
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
 
@@ -67,8 +83,8 @@ prog
67
83
  ecmaVersion = '3'
68
84
  break
69
85
  case 'es4':
70
- ecmaVersion = '4'
71
- break
86
+ logger.error('ES4 is not supported.')
87
+ process.exit(1)
72
88
  case 'es5':
73
89
  ecmaVersion = '5'
74
90
  break
@@ -115,13 +131,15 @@ prog
115
131
  ecmaVersion = '2021'
116
132
  break
117
133
  default:
118
- logger.error('Invalid ecmaScript version, please pass a valid version, use --help for help')
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
- const acornOpts = { ecmaVersion, silent: true }
142
+ const acornOpts = { ecmaVersion: parseInt(ecmaVersion, 10), silent: true }
125
143
 
126
144
  const expandedPathsToIgnore = pathsToIgnore.reduce((result, path) => {
127
145
  if (path.includes('*')) {
@@ -134,7 +152,10 @@ prog
134
152
  const filterForIgnore = (globbedFiles) => {
135
153
  if (expandedPathsToIgnore && expandedPathsToIgnore.length > 0) {
136
154
  const filtered = globbedFiles.filter(
137
- (filePath) => !expandedPathsToIgnore.some((ignoreValue) => filePath.includes(ignoreValue)),
155
+ (filePath) =>
156
+ !expandedPathsToIgnore.some((ignoreValue) =>
157
+ filePath.includes(ignoreValue)
158
+ )
138
159
  )
139
160
  return filtered
140
161
  }
@@ -157,7 +178,9 @@ prog
157
178
  const globbedFiles = glob.sync(pattern, globOpts)
158
179
 
159
180
  if (globbedFiles.length === 0) {
160
- logger.error(`ES-Check: Did not find any files to check for ${pattern}.`)
181
+ logger.error(
182
+ `ES-Check: Did not find any files to check for ${pattern}.`
183
+ )
161
184
  process.exit(1)
162
185
  }
163
186
 
@@ -170,11 +193,13 @@ prog
170
193
  try {
171
194
  acorn.parse(code, acornOpts)
172
195
  } catch (err) {
173
- logger.debug(`ES-Check: failed to parse file: ${file} \n - error: ${err}`)
196
+ logger.debug(
197
+ `ES-Check: failed to parse file: ${file} \n - error: ${err}`
198
+ )
174
199
  const errorObj = {
175
200
  err,
176
201
  stack: err.stack,
177
- file,
202
+ file
178
203
  }
179
204
  errArray.push(errorObj)
180
205
  }
@@ -182,7 +207,9 @@ prog
182
207
  })
183
208
 
184
209
  if (errArray.length > 0) {
185
- logger.error(`ES-Check: there were ${errArray.length} ES version matching errors.`)
210
+ logger.error(
211
+ `ES-Check: there were ${errArray.length} ES version matching errors.`
212
+ )
186
213
  errArray.forEach((o) => {
187
214
  logger.info(`
188
215
  ES-Check Error:
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "es-check",
3
- "version": "5.2.1",
4
- "description": "Checks the EcamScript version of .js glob against a specified version of EcamScript with a shell command",
3
+ "version": "6.0.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": "^11.0.0",
37
- "@commitlint/config-conventional": "^11.0.0",
38
- "@commitlint/prompt": "^11.0.0",
39
- "@heartly/eslint-config": "^0.0.2",
40
- "@heartly/prettier-config": "^0.0.1",
36
+ "@commitlint/cli": "^12.0.1",
37
+ "@commitlint/config-conventional": "^13.1.0",
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": "^6.6.0",
46
- "husky": "^4.3.7",
47
- "mocha": "^8.2.1",
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": "^7.0.1",
52
+ "mocha": "^9.0.1",
48
53
  "nyc": "^15.1.0",
49
- "prettier": "^2.2.1"
54
+ "prettier": "^2.3.2",
55
+ "prettier-config-standard": "^4.0.0"
50
56
  },
51
57
  "dependencies": {
52
- "acorn": "^6.4.1",
53
- "caporal": "1.4.0",
54
- "glob": "^7.1.2"
58
+ "acorn": "^8.4.1",
59
+ "caporal": "^1.4.0",
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"
@@ -87,7 +92,7 @@
87
92
  ]
88
93
  }
89
94
  },
90
- "husky": {
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",
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
-