Condor
06-12-2009, 05:02 AM
I thought it would be a good idea to run jslint on the Ext codebase to check for dubious code.
I added the following lines to ext-all-debug.js (latest SVN build):
/*jslint adsafe: false, bitwise: false, browser: true, cap: false, css: false, debug: false, eqeqeq: false, evil: true, forin: true, fragment: false, immed: false, laxbreak: true, newcap: false, nomen: false, on: false, onevar: false, passfail: false, plusplus: false, regexp: false, rhino: false, safe: false, sidebar: false, strict: false, sub: true, undef: false, white: false, widget: false */
/*global Ext: true */
and executed jslint.js using Rhino:
java -jar js.jar jslint.js ext-all-debug.js >warnings.txt
(I modified jslint.js to remove the 50 warnings limit)
Unfortunately Ext contains a few code segments that can't be parsed by the jslint parser (these are not errors, just unsupported syntax):
id : function(el, prefix){
return ((el = Ext.getDom(el) || {}).id = el.id) || (prefix || "ext-gen") + (++idSeed);
},
elasticBoth: function (t, b, c, d, a, p) {
...
p = p || (d * (0.3 * 1.5));
...
createListener: function(fn, scope, o){
o = o || {}; scope = scope || this.obj;
...
fire : function(){
...
return (ret = me.firing = FALSE);
...
"first-child" : function(c){
...
for(var i = 0, ci; ci = (n = c[i]); i++){
...
},
"last-child" : function(c){
...
for(var i = 0, ci; ci = (n = c[i]); i++){
...
},
replaceWith: function(el){
...
return (Element.cache[me.id] = me);
},
request : function(o){
...
return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
...
},
checkModifiers: function(config, e){
...
key = keys[i]; val = config[key];
...
},
onLayout : function(ct, target){
Ext.layout.VBoxLayout.superclass.onLayout.call(this, ct, target);
...
var totalFlex = (totalHeight = 0);
...
onLayout : function(ct, target){
Ext.layout.HBoxLayout.superclass.onLayout.call(this, ct, target);
...
var totalFlex = (totalWidth = 0);
...
setRawValue : function(v){
return (this.el.dom.value = (Ext.isEmpty(v) ? '' : v));
},
validateValue : function(value){
...
return (blank = false);
...
},
Can these jslint errors be fixed? And after these are fixed, can somebody look at the output of jslint and correct some of the warnings?
I added the following lines to ext-all-debug.js (latest SVN build):
/*jslint adsafe: false, bitwise: false, browser: true, cap: false, css: false, debug: false, eqeqeq: false, evil: true, forin: true, fragment: false, immed: false, laxbreak: true, newcap: false, nomen: false, on: false, onevar: false, passfail: false, plusplus: false, regexp: false, rhino: false, safe: false, sidebar: false, strict: false, sub: true, undef: false, white: false, widget: false */
/*global Ext: true */
and executed jslint.js using Rhino:
java -jar js.jar jslint.js ext-all-debug.js >warnings.txt
(I modified jslint.js to remove the 50 warnings limit)
Unfortunately Ext contains a few code segments that can't be parsed by the jslint parser (these are not errors, just unsupported syntax):
id : function(el, prefix){
return ((el = Ext.getDom(el) || {}).id = el.id) || (prefix || "ext-gen") + (++idSeed);
},
elasticBoth: function (t, b, c, d, a, p) {
...
p = p || (d * (0.3 * 1.5));
...
createListener: function(fn, scope, o){
o = o || {}; scope = scope || this.obj;
...
fire : function(){
...
return (ret = me.firing = FALSE);
...
"first-child" : function(c){
...
for(var i = 0, ci; ci = (n = c[i]); i++){
...
},
"last-child" : function(c){
...
for(var i = 0, ci; ci = (n = c[i]); i++){
...
},
replaceWith: function(el){
...
return (Element.cache[me.id] = me);
},
request : function(o){
...
return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
...
},
checkModifiers: function(config, e){
...
key = keys[i]; val = config[key];
...
},
onLayout : function(ct, target){
Ext.layout.VBoxLayout.superclass.onLayout.call(this, ct, target);
...
var totalFlex = (totalHeight = 0);
...
onLayout : function(ct, target){
Ext.layout.HBoxLayout.superclass.onLayout.call(this, ct, target);
...
var totalFlex = (totalWidth = 0);
...
setRawValue : function(v){
return (this.el.dom.value = (Ext.isEmpty(v) ? '' : v));
},
validateValue : function(value){
...
return (blank = false);
...
},
Can these jslint errors be fixed? And after these are fixed, can somebody look at the output of jslint and correct some of the warnings?