es-check icon indicating copy to clipboard operation
es-check copied to clipboard

Missing information when using --checkFeatures

Open p3k opened this issue 11 months ago • 5 comments

Requested Update

If running es-check es2017 --checkFeatures detects an unsupported feature it does not output the erroring file and line number:

es-check es2017 *.min.js --checkFeatures
/path/to/node_modules/es-check/detectFeatures.js:71
    throw new Error(
    ^

Error: Unsupported features detected: ErgonomicBrandChecks, ArrayPrototypeAt. These require a higher ES version than 8.
    at detectFeatures (/path/to/node_modules/es-check/detectFeatures.js:71:11)
    at /path/to/node_modules/es-check/index.js:222:54
    at Array.forEach (<anonymous>)
    at Command.<anonymous> (/path/to/node_modules/es-check/index.js:203:19)
    at Command.listener [as _actionHandler] (/path/to/node_modules/commander/lib/command.js:542:17)
    at /path/to/node_modules/commander/lib/command.js:1502:14
    at Command._chainOrCall (/path/to/node_modules/commander/lib/command.js:1386:12)
    at Command._parseCommand (/path/to/node_modules/commander/lib/command.js:1501:27)
    at Command.parse (/path/to/node_modules/commander/lib/command.js:1064:10)
    at Object.<anonymous> (/path/to/node_modules/es-check/index.js:256:9)

Node.js v20.9.0

Why Is This Update Needed?

When running es-check on a list of files defined by a glob (as done in the example above), it does not become clear where the unsupported feature is located.

Compared to the output of a “ES version matching error”:

❯ yarn es-check es2017 *.min.js 
error: ES-Check: there were 1 ES version matching errors.
info:                                                                                                                                                                                                                                          
          ES-Check Error:                                                                                                                                                                                                                      
          ----                                                                                                                                                                                                                                 
          · erroring file: path/to/file.min.js
          · error: SyntaxError: Unexpected token (3:12)                                                               
          · see the printed err.stack below for context                                                               
          ----                                                                                                        
                                                                                                                      
          SyntaxError: Unexpected token (3:12)                                                                        
    at pp$4.raise (/path/to/node_modules/acorn/dist/acorn.js:3646:15)                            
    at pp$9.unexpected (/path/to/node_modules/acorn/dist/acorn.js:772:10)                        
    at pp$5.parseIdentNode (/path/to/node_modules/acorn/dist/acorn.js:3582:12)                   
    at pp$5.parseIdent (/path/to/node_modules/acorn/dist/acorn.js:3554:21)                       
    at pp$5.parsePropertyName (/path/to/node_modules/acorn/dist/acorn.js:3373:111)               
    at pp$5.parseProperty (/path/to/node_modules/acorn/dist/acorn.js:3296:10)                    
    at pp$5.parseObj (/path/to/node_modules/acorn/dist/acorn.js:3259:23)                         
    at pp$5.parseExprAtom (/path/to/node_modules/acorn/dist/acorn.js:2961:19)                    
    at pp$5.parseExprSubscripts (/path/to/node_modules/acorn/dist/acorn.js:2769:21)              
    at pp$5.parseMaybeUnary (/path/to/node_modules/acorn/dist/acorn.js:2727:19)                  

Are There Examples Of This Requested Update Elsewhere?

:shrug:

Read about references issues here. Provide paragraph text responses to each header.

p3k avatar Jan 13 '25 13:01 p3k

Hello @p3k! Thanks for the issue!

Why can't the people make updates on based on the error using find & replace? es-check was built (almost a decade ago) to fail fast—after linting & babel transpilation. I still initially feel like linting and transpilation tools are better suited for line-by-line fixes...?

yowainwright avatar Jan 13 '25 19:01 yowainwright

@yowainwright Apart from the inconvenience to find out which feature caused the error in which file, it looks like an inconsistency to get information about filename and line number in one case but only a stack trace in another.

p3k avatar Jan 14 '25 08:01 p3k

Thanks! I agree that the error logs for the new --checkFeatures should be improved to include the file, and needs to be improved. 🙏

yowainwright avatar Jan 14 '25 10:01 yowainwright

Would it be possible to provide the list of unsupported features in a machine-readable format? This way one could use es-check to automatically bundle the needed polyfills:

$ es-check es2017 /path/to/bundle.min.js --check-features --format json
["ErgonomicBrandChecks", "ArrayPrototypeAt"]

p3k avatar Jan 14 '25 14:01 p3k

I noticed this too and my first thought was that es-check had an error in itself before I understood what was going on.

tonebender avatar Mar 05 '25 11:03 tonebender

I updated the output in the recent build thanks to this feedback. Please (at) me and re-open if more similar updates are desired.

yowainwright avatar Mar 26 '25 07:03 yowainwright

add information when using --checkFeatures, when it update? i need this ability. Thanks!

caomeibuaichibaicai avatar Aug 05 '25 12:08 caomeibuaichibaicai

@caomeibuaichibaicai are you getting better insights with latest or no? ~Thanks!

yowainwright avatar Aug 06 '25 02:08 yowainwright