I am currently trying to figure out why JSDT posts errors like 'JavaScript error on valid regex'.
While I was testing I realized that it works fine for simple files like this:
var a = {
urlParseRE: /^\s*(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,
test: b.replace(/^\/|(\/[^\/]*|[^\/]+)$/g, "")
};
and reports errors on complex files like jQuery.mobile-1.3.1.min.js.
I used online tool to format mimified jQuery script and then deleted almost all content out of it to make a simple example which would help to replicate the problem. When size of file was reduced from around 3000 to 300 lines some new validation errors were posted before original one above. I ended up my experiment with completely different problem. Validation error was posted on ',' in example below:
!function(){
window.alert("passed 1");
}(),
function(){
window.alert("passed 2");
}();
window.alert("passed 3");
I understand that JSDT project was dormant for a while and supports only ECMAScript v3 so before I create new issue I'd like to be sure this last simple js example is correct for ECMAScript Language Specification 3rd edition. Is there any online or offline tool to verify that?
The ECMAScript specification is a standardized specification of a scripting language developed by Brendan Eich of Netscape; initially named Mocha, then LiveScript, and finally JavaScript. In December 1995, Sun Microsystems and Netscape announced JavaScript in a press release.
JavaScript is a general-purpose scripting language that conforms to the ECMAScript specification. The ECMAScript specification is a blueprint for creating a scripting language. JavaScript is an implementation of that blueprint. On the whole, JavaScript implements the ECMAScript specification as described in ECMA-262.
A little dated, but https://jshint.com/ points out ES3 and ES5 issues
You can use Esprima for this.
"ECMAScript parsing infrastructure for multipurpose analysis"
If you feed your last chunk to Esprima's validator, it says that "Code is syntatically valid."
Esprima follows ES5, so technically it could pass ES5-related syntax which ES3-only-compliant parser will not understand.
But in this case I don't see anything related to ES5, so it must be a bug in JSDT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With