@@ -25,35 +25,31 @@ program
2525 . version ( pkg . version )
2626 . argument (
2727 '[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' ,
3329 )
30+ . argument ( '[files...]' , 'a glob of files to to test the EcmaScript version against' )
3431 . 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' )
3933 . option ( '--not <files>' , 'folder or file names to skip' )
4034 . option ( '--no-color' , 'disable use of colors in output' )
4135 . option ( '-v, --verbose' , 'verbose mode: will also output debug messages' )
4236 . option ( '--quiet' , 'quiet mode: only displays warn and error messages' )
4337 . option (
4438 '--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' ,
4640 )
4741 . action ( ( ecmaVersionArg , filesArg , options ) => {
4842 const logger = winston . createLogger ( )
49- logger . add ( new winston . transports . Console ( {
50- silent : options . silent ,
51- level : options . verbose ? 'silly' : options . quiet ? 'warn' : 'info' ,
52- format : winston . format . combine (
53- ...supportsColor . stdout ? [ winston . format . colorize ( ) ] : [ ] ,
54- winston . format . simple ( )
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+ )
5753
5854 const configFilePath = path . resolve ( process . cwd ( ) , '.escheckrc' )
5955
@@ -63,34 +59,22 @@ program
6359 * - If one exists, default to those options
6460 * - If no command line arguments are passed in
6561 */
66- const config = fs . existsSync ( configFilePath )
67- ? JSON . parse ( fs . readFileSync ( configFilePath ) )
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 )
7465 const esmodule = options . module ? options . module : config . module
75- const allowHashBang = options . allowHashBang
76- ? options . allowHashBang
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 || [ ] )
8268
8369 if ( ! expectedEcmaVersion ) {
8470 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' ,
8672 )
8773 process . exit ( 1 )
8874 }
8975
9076 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!' )
9478 process . exit ( 1 )
9579 }
9680
@@ -151,9 +135,7 @@ program
151135 ecmaVersion = '2021'
152136 break
153137 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' )
157139 process . exit ( 1 )
158140 }
159141
@@ -172,10 +154,7 @@ program
172154 const filterForIgnore = ( globbedFiles ) => {
173155 if ( expandedPathsToIgnore && expandedPathsToIgnore . length > 0 ) {
174156 const filtered = globbedFiles . filter (
175- ( filePath ) =>
176- ! expandedPathsToIgnore . some ( ( ignoreValue ) =>
177- filePath . includes ( ignoreValue )
178- )
157+ ( filePath ) => ! expandedPathsToIgnore . some ( ( ignoreValue ) => filePath . includes ( ignoreValue ) ) ,
179158 )
180159 return filtered
181160 }
@@ -198,38 +177,31 @@ program
198177 const globbedFiles = glob . sync ( pattern , globOpts )
199178
200179 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 } .` )
204181 process . exit ( 1 )
205182 }
206183
207184 const filteredFiles = filterForIgnore ( globbedFiles )
208185
209186 filteredFiles . forEach ( ( file ) => {
210187 const code = fs . readFileSync ( file , 'utf8' )
211-
212188 logger . debug ( `ES-Check: checking ${ file } ` )
213189 try {
214190 acorn . parse ( code , acornOpts )
215191 } 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 } ` )
219193 const errorObj = {
220194 err,
221195 stack : err . stack ,
222- file
196+ file,
223197 }
224198 errArray . push ( errorObj )
225199 }
226200 } )
227201 } )
228202
229203 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.` )
233205 errArray . forEach ( ( o ) => {
234206 logger . info ( `
235207 ES-Check Error:
0 commit comments