Open FreeMasen opened 2 years ago
It might need to be more fine-grained than that, since users may want most validation but perhaps to relax one or two rules. Maybe one option might be to have a trait defining each validation rule in a default implementation. If users want to relax one or more rules or perhaps even make existing rules stricter then they could implement the trait and change the default implementation for one or more rules. Maybe then the parser constructor will optionally take an implementation as a parameter to customise the implementation if required.
I had initially added this to try and reach a fulling passing test262 based test, however validation is something that should be left up to the consumer of the AST. Ideally we could allow this to be provided by the constructor, similar to the how the comment handling works.
In the ideal case, users could completely opt out of the validation if they have already validate the javascript using some external tool, for example they are interacting with js that has already been passed through
webpack
or similar.