-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
Check minified code for syntax errors (e.g. by trying to construct an AST) #3075
Comments
Validate AST? Sounds awfully like a linter to me. I think @gibson042 meant to just check if we can build an AST. |
@markelog updated the title & description. |
And it also sounds like, that this could be (if proven viable) implemented on uglify side, like self check of sorts which could be run if correct option is passed (since it would reflect on the performance). @mishoo what do you think? |
@markelog Not sure I understand what's your question, but I do agree that @mgol reported a valid issue on UglifyJS. We already have a PR that fixes it; I didn't have time to look into it yet, though — please test if possible. |
We have an idea, which we currently considering to implement in jquery build process - after uglify minifies the source, run it through parser once again and try to build an AST, if AST is builded, then we could be sure that there is no obvious syntax errors. Yes, we do run minified version through test suite on various set of browsers with browserstack, but because mentioned error was noticed only at that point, we almost reached our cap on that service, which is not preferred, proposed approach might caught such errors on early stage if automated. And yes, most errors will not be revealed at that stage, but it seems some of them will, like mishoo/UglifyJS#1052? I'm wondering if second parser run could be introduced on uglify side as a self check and overall, if you think this idea worth something. Other option is to run linter on minified version, with limited amount of enabled rules, but running linter on minified version sounds kinda... or is it? |
A second uglify parse would not have caught this issue:
as uglify parses it without error:
A full-fledged linter from a different parsing code base or testing with PhantomJS is your best bet. |
This issue doesn't seem actionable now, it seems it requires further research. Should we move it to the roadmap? |
Done |
While we have absolutely no style-related expectations to our minified file, we do care that it's valid ES 5.1. This is now verified. Fixes jquerygh-3075
Re-opening since it's now possible to do such a verification via a plain ESLint run. |
PR: #4594 |
Code in jquerygh-4594 configured ESLint properly but didn't change the Gruntfile.js config to actually lint the minified file. This has now been fixed. Fixes jquerygh-3075 Ref jquerygh-4594
While we have absolutely no style-related expectations to our minified file, we do care that it's valid ES 5.1. This is now verified. Fixes jquerygh-3075 Closes jquerygh-4594
While we have absolutely no style-related expectations to our minified file, we do care that it's valid ES 5.1. This is now verified. Also, update grunt-eslint as a newer ESLint version is required to be able to use "extends" inside of the "overrides" section. Fixes gh-3075 Closes gh-4594 Ref gh-4598
While we have absolutely no style-related expectations to our minified file, we do care that it's valid ES 5.1. This is now verified. Fixes jquerygh-3075 Closes jquerygh-4594
* Description*
Enabling strict mode uncovered an UglifyJS issue (mishoo/UglifyJS#1052) where it was creating code with SyntaxErrors. Perhaps we should try to generate the AST of the generated minified code to check if it doesn't contain syntax errors.
The text was updated successfully, but these errors were encountered: