Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing information when using --checkFeatures #231

Open
p3k opened this issue Jan 13, 2025 · 5 comments
Open

Missing information when using --checkFeatures #231

p3k opened this issue Jan 13, 2025 · 5 comments

Comments

@p3k
Copy link

p3k commented Jan 13, 2025

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?

🤷

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

@yowainwright
Copy link
Owner

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...?

@p3k
Copy link
Author

p3k commented Jan 14, 2025

@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.

@yowainwright
Copy link
Owner

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

@p3k
Copy link
Author

p3k commented Jan 14, 2025

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"]

@tonebender
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants