[kupu-checkins] r35854 - in kupu/trunk/kupu: . common plone plone/kupu_plone_layer
duncan at codespeak.net
duncan at codespeak.net
Mon Dec 18 16:37:21 CET 2006
Author: duncan
Date: Mon Dec 18 16:37:15 2006
New Revision: 35854
Added:
kupu/trunk/kupu/jslint.opts (contents, props changed)
Modified:
kupu/trunk/kupu/common/kupu_kjax.js
kupu/trunk/kupu/common/kupubasetools.js
kupu/trunk/kupu/common/kupubeforeunload.js
kupu/trunk/kupu/common/kupucleanupexpressions.js
kupu/trunk/kupu/common/kupucnftable.js
kupu/trunk/kupu/common/kupucontextmenu.js
kupu/trunk/kupu/common/kupudrawers.js
kupu/trunk/kupu/common/kupueditor.js
kupu/trunk/kupu/common/kupuhelpers.js
kupu/trunk/kupu/common/kupuinit.js
kupu/trunk/kupu/common/kupuinit_experimental.js
kupu/trunk/kupu/common/kupuinit_form.js
kupu/trunk/kupu/common/kupuinit_genericelements.js
kupu/trunk/kupu/common/kupuinit_multi.js
kupu/trunk/kupu/common/kupuinspector.js
kupu/trunk/kupu/common/kupuloggers.js
kupu/trunk/kupu/common/kupumultieditor.js
kupu/trunk/kupu/common/kupusaveonpart.js
kupu/trunk/kupu/common/kupusourceedit.js
kupu/trunk/kupu/common/kupuspellchecker.js
kupu/trunk/kupu/common/kupustart.js
kupu/trunk/kupu/common/kupustart_form.js
kupu/trunk/kupu/common/kupustart_multi.js
kupu/trunk/kupu/common/kuputoolcollapser.js
kupu/trunk/kupu/common/sarissa.js
kupu/trunk/kupu/common/sarissa_ieemu_xpath.js
kupu/trunk/kupu/jslint.js
kupu/trunk/kupu/lint.py
kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js
kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js
kupu/trunk/kupu/plone/kupu_plone_layer/kupusaveonpart.js
kupu/trunk/kupu/plone/plonelibrarytool.py
Log:
jslint.js now accepts command line arguments. Moved most of the lint comment directives out into jslint.opts.
Modified: kupu/trunk/kupu/common/kupu_kjax.js
==============================================================================
--- kupu/trunk/kupu/common/kupu_kjax.js (original)
+++ kupu/trunk/kupu/common/kupu_kjax.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern Sarissa timer_instance newElement */
/* Javascript to aid migration page. */
function KJax() {};
Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js (original)
+++ kupu/trunk/kupu/common/kupubasetools.js Mon Dec 18 16:37:15 2006
@@ -7,10 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern addEventHandler _ getFromSelector newElement
- ContextMenuElement _SARISSA_IS_MOZ openPopup selectSelectItem
- NodeIterator _IE_VERSION Sarissa
- */
// $Id$
//----------------------------------------------------------------------------
Modified: kupu/trunk/kupu/common/kupubeforeunload.js
==============================================================================
--- kupu/trunk/kupu/common/kupubeforeunload.js (original)
+++ kupu/trunk/kupu/common/kupubeforeunload.js Mon Dec 18 16:37:15 2006
@@ -1,5 +1,4 @@
/* BeforeUnload form processing */
-/*extern _ */
if (!window.beforeunload) (function() {
var BeforeUnloadHandler = function() {
var self = this;
Modified: kupu/trunk/kupu/common/kupucleanupexpressions.js
==============================================================================
--- kupu/trunk/kupu/common/kupucleanupexpressions.js (original)
+++ kupu/trunk/kupu/common/kupucleanupexpressions.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern addEventHandler NodeIterator */
// $Id: kupueditor.js 7951 2004-12-21 15:06:38Z guido $
// WARNING: this file can contain non-ascii characters, *always* make sure your
Modified: kupu/trunk/kupu/common/kupucnftable.js
==============================================================================
--- kupu/trunk/kupu/common/kupucnftable.js (original)
+++ kupu/trunk/kupu/common/kupucnftable.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern _ getFromSelector addEventHandler selectSelectItem */
// $Id$
TableTool.prototype.setTableRowRepeat = function() {
Modified: kupu/trunk/kupu/common/kupucontextmenu.js
==============================================================================
--- kupu/trunk/kupu/common/kupucontextmenu.js (original)
+++ kupu/trunk/kupu/common/kupucontextmenu.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern addEventHandler */
// $Id$
Modified: kupu/trunk/kupu/common/kupudrawers.js
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers.js (original)
+++ kupu/trunk/kupu/common/kupudrawers.js Mon Dec 18 16:37:15 2006
@@ -7,10 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern getFromSelector timer_instance NodeIterator getBaseTagClass
- addEventHandler selectSelectItem newElement XSLTProcessor
- Sarissa
- */
// $Id$
function DrawerTool() {
Modified: kupu/trunk/kupu/common/kupueditor.js
==============================================================================
--- kupu/trunk/kupu/common/kupueditor.js (original)
+++ kupu/trunk/kupu/common/kupueditor.js Mon Dec 18 16:37:15 2006
@@ -7,11 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern _SARISSA_IS_IE IESelection MozillaSelection addEventHandler
- XMLSerializer XhtmlValidation _ UpdateStateCancelBubble
- ContextFixer _SARISSA_IS_MOZ timer_instance newDocumentElement
- Sarissa
- */
// $Id$
//----------------------------------------------------------------------------
Modified: kupu/trunk/kupu/common/kupuhelpers.js
==============================================================================
--- kupu/trunk/kupu/common/kupuhelpers.js (original)
+++ kupu/trunk/kupu/common/kupuhelpers.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern _SARISSA_IS_IE _ Node Range */
// $Id$
/*
Modified: kupu/trunk/kupu/common/kupuinit.js
==============================================================================
--- kupu/trunk/kupu/common/kupuinit.js (original)
+++ kupu/trunk/kupu/common/kupuinit.js Mon Dec 18 16:37:15 2006
@@ -7,15 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern KupuButton loadDictFromXML listtool ImageTool PlainLogger
- SourceEditTool LinkTool KupuSpellChecker DrawerTool
- ImageToolBox TableDrawer KupuDocument KupuStateButton
- KupuUI DefinitionListTool PropertyTool LinkDrawer LinkToolBox
- AnchorTool parentWithStyleChecker AnchorDrawer TableToolBox
- LinkLibraryDrawer ColorchooserTool KupuEditor CleanupExpressionsTool
- KupuZoomTool ImageLibraryDrawer KupuRemoveElementButton
- ContextMenu TableTool NonXHTMLTagFilter ShowPathTool _ ListTool
- */
// $Id$
Modified: kupu/trunk/kupu/common/kupuinit_experimental.js
==============================================================================
--- kupu/trunk/kupu/common/kupuinit_experimental.js (original)
+++ kupu/trunk/kupu/common/kupuinit_experimental.js Mon Dec 18 16:37:15 2006
@@ -7,16 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern KupuButton loadDictFromXML listtool ImageTool PlainLogger
- SourceEditTool LinkTool KupuSpellChecker DrawerTool
- ImageToolBox TableDrawer KupuDocument KupuStateButton
- KupuUI DefinitionListTool PropertyTool LinkDrawer LinkToolBox
- AnchorTool parentWithStyleChecker AnchorDrawer TableToolBox
- LinkLibraryDrawer ColorchooserTool KupuEditor CleanupExpressionsTool
- KupuZoomTool ImageLibraryDrawer KupuRemoveElementButton
- ContextMenu TableTool NonXHTMLTagFilter ShowPathTool _ ListTool
- KupuInspector ViewSourceTool
- */
// $Id$
Modified: kupu/trunk/kupu/common/kupuinit_form.js
==============================================================================
--- kupu/trunk/kupu/common/kupuinit_form.js (original)
+++ kupu/trunk/kupu/common/kupuinit_form.js Mon Dec 18 16:37:15 2006
@@ -19,16 +19,6 @@
// We only want to disable the save button, but unfortunately that currently
// still means this method should be overridden completely
//----------------------------------------------------------------------------
-/*extern KupuButton loadDictFromXML listtool ImageTool PlainLogger
- SourceEditTool LinkTool KupuSpellChecker DrawerTool
- ImageToolBox TableDrawer KupuDocument KupuStateButton
- KupuUI DefinitionListTool PropertyTool LinkDrawer LinkToolBox
- AnchorTool parentWithStyleChecker AnchorDrawer TableToolBox
- LinkLibraryDrawer ColorchooserTool KupuEditor CleanupExpressionsTool
- KupuZoomTool ImageLibraryDrawer KupuRemoveElementButton
- ContextMenu TableTool NonXHTMLTagFilter ShowPathTool _ ListTool
- KupuInspector ViewSourceTool addEventHandler getFromSelector
- */
function initKupu(iframe) {
/* Although this is meant to be a sample implementation, it can
Modified: kupu/trunk/kupu/common/kupuinit_genericelements.js
==============================================================================
--- kupu/trunk/kupu/common/kupuinit_genericelements.js (original)
+++ kupu/trunk/kupu/common/kupuinit_genericelements.js Mon Dec 18 16:37:15 2006
@@ -7,18 +7,7 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern KupuButton loadDictFromXML listtool ImageTool PlainLogger
- SourceEditTool LinkTool KupuSpellChecker DrawerTool
- ImageToolBox TableDrawer KupuDocument KupuStateButton
- KupuUI DefinitionListTool PropertyTool LinkDrawer LinkToolBox
- AnchorTool parentWithStyleChecker AnchorDrawer TableToolBox
- LinkLibraryDrawer ColorchooserTool KupuEditor CleanupExpressionsTool
- KupuZoomTool ImageLibraryDrawer KupuRemoveElementButton
- ContextMenu TableTool NonXHTMLTagFilter ShowPathTool _ ListTool
- KupuInspector ViewSourceTool addEventHandler getFromSelector
- */
/*extern CNFTableToolBox GenericElementsTool GenericElementsToolBox */
-
// $Id$
Modified: kupu/trunk/kupu/common/kupuinit_multi.js
==============================================================================
--- kupu/trunk/kupu/common/kupuinit_multi.js (original)
+++ kupu/trunk/kupu/common/kupuinit_multi.js Mon Dec 18 16:37:15 2006
@@ -7,16 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern KupuButton loadDictFromXML listtool ImageTool PlainLogger
- SourceEditTool LinkTool KupuSpellChecker DrawerTool
- ImageToolBox TableDrawer KupuDocument KupuStateButton
- KupuUI DefinitionListTool PropertyTool LinkDrawer LinkToolBox
- AnchorTool parentWithStyleChecker AnchorDrawer TableToolBox
- LinkLibraryDrawer ColorchooserTool KupuEditor CleanupExpressionsTool
- KupuZoomTool ImageLibraryDrawer KupuRemoveElementButton
- ContextMenu TableTool NonXHTMLTagFilter ShowPathTool _ ListTool
- KupuInspector ViewSourceTool addEventHandler getFromSelector
- */
/*extern KupuMultiEditor MultiSourceEditTool */
// $Id$
Modified: kupu/trunk/kupu/common/kupuinspector.js
==============================================================================
--- kupu/trunk/kupu/common/kupuinspector.js (original)
+++ kupu/trunk/kupu/common/kupuinspector.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern _SARISSA_IS_IE addEventHandler getFromSelector */
// $Id$
/* The Kupu Inspector tool
Modified: kupu/trunk/kupu/common/kupuloggers.js
==============================================================================
--- kupu/trunk/kupu/common/kupuloggers.js (original)
+++ kupu/trunk/kupu/common/kupuloggers.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern getFromSelector */
// $Id$
Modified: kupu/trunk/kupu/common/kupumultieditor.js
==============================================================================
--- kupu/trunk/kupu/common/kupumultieditor.js (original)
+++ kupu/trunk/kupu/common/kupumultieditor.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern _ timer_instance */
// $Id: kupumultieditor.js 3450 2004-03-28 11:07:30Z guido $
function KupuMultiEditor(documents, config, logger) {
Modified: kupu/trunk/kupu/common/kupusaveonpart.js
==============================================================================
--- kupu/trunk/kupu/common/kupusaveonpart.js (original)
+++ kupu/trunk/kupu/common/kupusaveonpart.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern kupu _ */
// $Id$
function saveOnPart() {
Modified: kupu/trunk/kupu/common/kupusourceedit.js
==============================================================================
--- kupu/trunk/kupu/common/kupusourceedit.js (original)
+++ kupu/trunk/kupu/common/kupusourceedit.js Mon Dec 18 16:37:15 2006
@@ -7,8 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern getFromSelector addEventHandler _ kupuButtonEnable
- kupuButtonDisable kupu */
// $Id$
Modified: kupu/trunk/kupu/common/kupuspellchecker.js
==============================================================================
--- kupu/trunk/kupu/common/kupuspellchecker.js (original)
+++ kupu/trunk/kupu/common/kupuspellchecker.js Mon Dec 18 16:37:15 2006
@@ -1,4 +1,3 @@
-/*extern addEventHandler ContextFixer _ NodeIterator timer_instance */
function KupuSpellChecker(buttonid, scripturl, spanstyle,
winwidth, winheight, skip_tags) {
this.button = document.getElementById(buttonid);
Modified: kupu/trunk/kupu/common/kupustart.js
==============================================================================
--- kupu/trunk/kupu/common/kupustart.js (original)
+++ kupu/trunk/kupu/common/kupustart.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern saveOnPart getFromSelector initKupu addEventHandler */
// $Id$
function startKupu() {
Modified: kupu/trunk/kupu/common/kupustart_form.js
==============================================================================
--- kupu/trunk/kupu/common/kupustart_form.js (original)
+++ kupu/trunk/kupu/common/kupustart_form.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern getFromSelector initKupu ContextFixer _ */
// $Id$
function startKupu() {
Modified: kupu/trunk/kupu/common/kupustart_multi.js
==============================================================================
--- kupu/trunk/kupu/common/kupustart_multi.js (original)
+++ kupu/trunk/kupu/common/kupustart_multi.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern initKupu ContextFixer _ */
// $Id$
function startKupu() {
Modified: kupu/trunk/kupu/common/kuputoolcollapser.js
==============================================================================
--- kupu/trunk/kupu/common/kuputoolcollapser.js (original)
+++ kupu/trunk/kupu/common/kuputoolcollapser.js Mon Dec 18 16:37:15 2006
@@ -1,4 +1,3 @@
-/*extern addEventHandler _ */
// turn this into a nice module-like namespace to avoid messing up the global
// (window) namespace
this.kuputoolcollapser = new function() {
@@ -15,7 +14,7 @@
var cookie = document.cookie;
var reg = /initial_state=([^;]+);?/;
var match = cookie.match(reg);
- if (match) { /*lint 558*/
+ if (match) { /*ignore 558 */
eval(unescape(match[0]));
};
};
Modified: kupu/trunk/kupu/common/sarissa.js
==============================================================================
--- kupu/trunk/kupu/common/sarissa.js (original)
+++ kupu/trunk/kupu/common/sarissa.js Mon Dec 18 16:37:15 2006
@@ -26,7 +26,6 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/*extern ActiveXObject */
/**
* <p>Sarissa is a utility class. Provides "static" methods for DOMDocument,
* DOM Node serialization to XML strings and other utility goodies.</p>
Modified: kupu/trunk/kupu/common/sarissa_ieemu_xpath.js
==============================================================================
--- kupu/trunk/kupu/common/sarissa_ieemu_xpath.js (original)
+++ kupu/trunk/kupu/common/sarissa_ieemu_xpath.js Mon Dec 18 16:37:15 2006
@@ -33,7 +33,6 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/*extern XPathResult */
if(_SARISSA_HAS_DOM_FEATURE && document.implementation.hasFeature("XPath", "3.0")){
/**
* <p>SarissaNodeList behaves as a NodeList but is only used as a result to <code>selectNodes</code>,
Modified: kupu/trunk/kupu/jslint.js
==============================================================================
--- kupu/trunk/kupu/jslint.js (original)
+++ kupu/trunk/kupu/jslint.js Mon Dec 18 16:37:15 2006
@@ -101,12 +101,44 @@
return (this >= '0' && this <= '9');
};
+function repr(o) {
+ if (o===undefined||o===null) {return o+'';}
+ if (o.__repr__) {
+ return o.__repr__();
+ }
+ if (typeof o =='string') {
+ var v = o.replace(/\\/g, '\\\\').replace(/\n/g, '\\n').
+ replace(/\r/g,'\\r');
+ if (/'/.test(o)) {
+ return '"'+v.replace(/"/g, '\\"')+'"';
+ } else {
+ return "'"+v+"'";
+ }
+}
+if (o instanceof Array) {
+ var els = [];
+ for (var i = 0; i < o.length; i++) {
+ els.push(repr(o[i]));
+ }
+ return "["+els.join(', ')+"]";
+}
+if (o instanceof Object) {
+ var attrs = [];
+ for (var name in o) {
+ if (o.hasOwnProperty(name)) {
+ attrs.push(repr(name)+': '+repr(o[name]));
+ }
+ }
+ return "{"+attrs.join(', ')+"}";
+}
+return o.toString? o.toString() : o;
+}
String.prototype.format = function() {
function repl() {
function spaces(n) {
n = Math.floor(n);
- if (n<=0) return '';
- if (n==1) return ' ';
+ if (n<=0) { return '';}
+ if (n==1) { return ' ';}
return spaces(n/2)+spaces(n-n/2);
}
var flag = arguments[1];
@@ -128,19 +160,15 @@
case 'r': case 's':
value = args[n++];
if (type=='r') {
- if (typeof(value)=='string') {
- value = "'"+value.replace("'","\\'")+"'";
- } else {
- value = value.toString();
- }
+ value = repr(value);
}
if (prec !== 0) {
value = value.substr(0,prec);
}
+ value=value+'';
break;
default:
throw("String.format: unrecognised format character '"+type+"'");
- break;
}
var padding = spaces(width-value.length);
if (flag=='-') { // Left align
@@ -156,7 +184,7 @@
throw("String.format given %d arguments, expecting %d".format(args.length, n));
}
return res;
-}
+};
// We build the application inside a function so that we produce only a single
// global variable. The function will be invoked, its return value is the JSLINT
@@ -216,7 +244,7 @@
window: true,
XMLHttpRequest: true
},
- funlab, funstack, functions, globals, directive,
+ funlab, funstack, functions, globals,
// konfab contains the global names which are provided to a Yahoo
// (fna Konfabulator) widget.
@@ -330,7 +358,7 @@
xtype,
// token
- tx = /^([(){}[.,:;'"~]|\](\]>)?|\?>?|==?=?|\/(\*(global|extern|lint)*|=|)|\*[\/=]?|\+[+=]?|-[-=]?|%[=>]?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=%\?]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+-]?[0-9]+)?)/,
+ tx = /^([(){}[.,:;'"~]|\](\]>)?|\?>?|==?=?|\/(\*(global|extern|ignore|warning|error)*|=|)|\*[\/=]?|\+[+=]?|-[-=]?|%[=>]?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=%\?]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+-]?[0-9]+)?)/,
// string ending in single quote
sx = /^((\\[^\x00-\x1f]|[^\x00-\x1f'\\])*)'/,
sxx = /^(([^\x00-\x1f'])*)'/,
@@ -360,11 +388,16 @@
// Produce an error warning.
- function warning(n, m, x, y) {
+ function warning(n, m, x, y, f) {
var l, c, t = typeof x === 'object' ? x : token;
if (typeof x === 'number') {
l = x;
- c = y || 0;
+ if (typeof y === 'number') {
+ c = y || 0;
+ } else {
+ f = y;
+ c = 0;
+ }
} else {
if (t.id === '(end)') {
t = prevtoken;
@@ -372,16 +405,17 @@
l = t.line || 0;
c = t.from || 0;
}
- if (directive[n]) { return; } // Ignore this warning.
+ if (JSLINT.errorlevels[n]=='ignore') { return; } // Ignore this warning.
JSLINT.errors.push({
id: '(error)',
reason: m,
evidence: lines[l] || '',
+ filename: f || JSLINT.filename,
line: l,
character: c,
errno: n
});
- if (option.passfail) {
+ if (option.passfail || JSLINT.errorlevels[n]=='error') {
JSLINT.errors.push(null);
throw null;
}
@@ -615,8 +649,10 @@
error(105,"Unclosed comment.");
}
}
- } else if (t== '/*lint') {
+ } else if (/\/\*(ignore|warning|error)/.test(t)) {
+ var level = /\/\*(ignore|warning|error)/.exec(t)[1];
for (;;) {
+
r = hx.exec(s);
if (r) {
l = r[0].length;
@@ -632,9 +668,9 @@
l = r[0].length;
s = s.substr(l);
character += l;
- directive[r[1]] = true;
+ JSLINT.errorlevels[r[1]] = level;
} else {
- error(104,"Bad lint directive: '" +
+ error(104,"Bad error level directive: '" +
s + "'.", line, character);
}
} else if (!nextLine()) {
@@ -701,7 +737,7 @@
function builtin(name) {
return standard[name] === true ||
- globals[name] === true ||
+ globals[name] === true || option.extern[name] === true ||
((xtype === 'widget' || option.widget) && konfab[name] === true) ||
((xtype === 'html' || option.browser) && browser[name] === true);
}
@@ -885,7 +921,7 @@
function beginfunction(i) {
- var f = {'(name)': i, '(line)': token.line + 1, '(context)': funlab};
+ var f = {'(name)': i, '(filename)': JSLINT.filename, '(line)': token.line + 1, '(context)': funlab};
funstack.push(funlab);
funlab = f;
functions.push(funlab);
@@ -2493,14 +2529,14 @@
// The actual JSLINT function itself.
- var itself = function (s, o) {
+ var itself = function (filename, s, o) {
option = o;
if (!o) {
option = {};
}
JSLINT.errors = [];
+ JSLINT.filename = filename;
globals = {};
- directive ={};
functions = [];
xmode = false;
xtype = '';
@@ -2510,11 +2546,6 @@
funstack = [];
lookahead = [];
lex.init(s);
- if (o.ignore) {
- for (var i=0; i < o.ignore.length; i++) {
- directive[o.ignore[i]] = true;
- }
- }
prevtoken = token = syntax['(begin)'];
try {
advance();
@@ -2792,7 +2823,7 @@
break;
case 'parameter!':
s.push(k + ' (closure)');
- warning(1002, 'Parameter %r used in nested function in %s'.format(k,f['(name)']), f['(line)']);
+ warning(1002, 'Parameter %r used in nested function in %s'.format(k,f['(name)']), f['(line)'], f['(filename)']);
break;
}
}
@@ -2804,18 +2835,18 @@
switch(f[k]) {
case 'var':
s.push(k + ' (unused)');
- warning(1003, 'Unused local variable %r in %s'.format(k,f['(name)']), f['(line)']);
+ warning(1003, 'Unused local variable %r in %s'.format(k,f['(name)']), f['(line)'], f['(filename)']);
break;
case 'var*':
s.push(k);
break;
case 'var!':
s.push(k + ' (closure)');
- warning(1004, 'Var %r used in nested function in %s'.format(k,f['(name)']), f['(line)']);
+ warning(1004, 'Var %r used in nested function in %s'.format(k,f['(name)']), f['(line)'], f['(filename)']);
break;
case 'var.':
s.push(k + ' (outer)');
- warning(1005, 'Var %r used from outer function in %s'.format(k,f['(name)']), f['(line)']);
+ warning(1005, 'Var %r used from outer function in %s'.format(k,f['(name)']), f['(line)'], f['(filename)']);
break;
}
}
@@ -2849,7 +2880,7 @@
}
return o.join('\n');
};
-
+ itself.errorlevels={};
return itself;
}();// rhino.js
@@ -2859,43 +2890,220 @@
*/
/*extern JSLINT, print, quit, readFile */
+function parserange(r, action) {
+ var RP = /(\d+)(?:-)?(\d+)?(?:,|$)?/g;
+ do {
+ var m = RP.exec(r);
+ if (m) {
+ var start = parseInt(m[1], 0);
+ var end = parseInt(m[2], 0);
+ if (!end) {
+ end = start;
+ }
+ for (var i=start; i <= end; i++) {
+ action(i);
+ }
+ }
+ } while(RP.lastIndex !== 0);
+}
-(function (a) {
- if (!a[0]) {
- print("Usage: jslint.js file.js");
- quit(1);
- }
- var input = readFile(a[0]);
- if (!input) {
- print("jslint: Couldn't open file '" + a[0] + "'.");
- quit(1);
- }
- ignore = [501, 510, 531, 535, 544, 546, 554, 557,1001,1002,1004,1005];
- if (!JSLINT(input, {passfail: false, redef:true, ignore:ignore, browser:true})) {
- for (var i = 0; i < JSLINT.errors.length; i += 1) {
- var e = JSLINT.errors[i];
- if (e) {
- var type = (e.errno >= 500)?"Warning":"Error";
- print("%s:%d,%d: %s %d:%s".format(a[0],e.line+1, e.character+1, type, e.errno,e.reason));
- print((e.evidence || '').
- replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
- print('');
+function usage(options, msg) {
+ if (msg) { print(msg); }
+ print("Usage:");
+ var optlist = [], name, opt;
+ for (name in options) {
+ optlist.push(name);
+ }
+ optlist.sort();
+ for (var i = 0; i < optlist.length; i++) {
+ name = optlist[i];
+ opt = options[name];
+ var keys = [];
+ if (opt.hasarg) {
+ keys.push("--%s #".format(name));
+ } else if (opt.action) {
+ keys.push("--%s".format(name));
+ } else {
+ keys.push("--%s%s".format(name, opt.def?'*':''));
+ keys.push("--no%s%s".format(name, opt.def?'':'*'));
+ }
+ print(keys.join(', '));
+ if (opt.help) {
+ print(" %s".format(opt.help.replace(/\n/g, '\n ')));
+ }
+ }
+}
+
+function processarguments(options, args, defaults) {
+ var shortopts = {};
+ var result = {};
+ var name, opt;
+ if(typeof args == 'string') {
+ args = [args];
+ }
+ for (name in options) {
+ opt = options[name];
+ var sname = opt.shortname;
+ if (sname) {
+ shortopts[sname] = opt;
+ }
+ if (!opt.dest) {
+ opt.dest = name;
+ }
+ if (opt.def!==undefined) {
+ result[name] = opt.def;
+ } else if (!opt.hasarg&&!opt.action) {
+ result[name] = false;
+ }
+ }
+ if (defaults) {
+ for (name in defaults) {
+ result[name] = defaults[name];
+ }
+ }
+ for (var i = 0; i < args.length; i++) {
+ var arg = args[i];
+ var value = true;
+ var pat = /(?:--(\w+))|(?:-(.))/;
+ var m = pat.exec(args[i]);
+ if (!m) {
+ opt = options[''];
+ value = arg;
+ } else if (m[1]) {
+ name = m[1];
+ opt = options[name];
+ if (!opt && (/^no/.test(name))) {
+ opt = options[name.substr(2)];
+ if (opt && (opt.hasarg || opt.action)) {
+ opt = undefined;
+ }
+ value = false;
}
+ } else {
+ opt = shortopts[m[2]];
}
- quit(1);
- } else {
- print("jslint: No problems found in " + a[0]);
+ if (!opt) {
+ usage(options, "Unrecognised argument: "+arg);
+ return;
+ }
+ if (opt.hasarg) {
+ value = args[++i];
+ }
+ if (opt.action) {
+ value = opt.action(arg, value, result);
+ }
+ if (value===undefined) {
+ return;
+ } else {
+ result[opt.dest] = value;
+ }
+ }
+ return result;
+}
+
+(function (a) {
+ function lintfile(arg, filename, options) {
+ var input = readFile(filename);
+ if (!input) {
+ print("jslint: Couldn't open file %r".format(filename));
+ quit(1);
+ }
+ oksofar &= JSLINT(filename, input, options);
+ /* The report and the error reporting should be consolidated at
+ * the end, but there isn't yet any code to merge the reports
+ * across files. :(
+ */
JSLINT.textreport(false);
- if (JSLINT.errors.length) {
+ if (JSLINT.errors && JSLINT.errors.length) {
for (var i = 0; i < JSLINT.errors.length; i += 1) {
var e = JSLINT.errors[i];
if (e) {
- var type = (e.errno >= 500)?"Warning":"Error";
- print("%s:%d,%d: %s %d:%s".format(a[0],e.line+1, e.character+1, type, e.errno,e.reason));
+ var type = JSLINT.errorlevels[e.errno] || "warning";
+ print("%s:%d,%d: %s %d:%s".format(e.filename,e.line+1, e.character+1, type, e.errno,e.reason));
+ print((e.evidence || '').
+ replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
+ print('');
}
}
quit(1);
+ } else {
+ print("%s: No problems found".format(filename));
+ }
+ filesdone++;
+ return oksofar;
+ }
+ function doextern(arg, value, result) {
+ var names = value.split(/[ ,]+/);
+ for (var i = 0; i < names.length; i++) {
+ result.extern[names[i]] = true;
+ }
+ return result.extern;
+ }
+ function readconfigfile(arg, filename, result) {
+ var data = readFile(filename);
+ if (!data) {
+ print("jslint: Couldn't open file %r".format(filename));
+ return;
+ }
+ data = data.split(/\s+/);
+ while (data.length && !data[data.length-1]) {
+ data.length--;
+ }
+ var newres = processarguments(options, data, result);
+ if (!newres) { return; }
+ for (var name in newres) {
+ result[name]=newres[name];
+ }
+ return true;
+ }
+ /* Set up default error message handling */
+ parserange("100-163", function(i) { JSLINT.errorlevels[i]='error'; });
+ parserange("501-571,1001-1006", function(i) { JSLINT.errorlevels[i]='warning'; });
+ parserange("1001,1002,1004,1005", function(i) { JSLINT.errorlevels[i]='ignore'; });
+// parserange("501,510,531,535,544,546,554,557,1001,1002,1004,1005",
+// function(i) { JSLINT.errorlevels[i]='ignore'; });
+
+ var options = {
+ browser: { help: "true if the standard browser globals should be predefined" },
+ cap: { help: "true if upper case HTML should be allowed" },
+ debug: { help: "true if debugger statements should be allowed" },
+ eqeqeq: { help: "true if === should be required" },
+ evil: { help: "true if eval should be allowed" },
+ jscript: { help: "true if jscript deviations should be allowed" },
+ laxLineEnd: { help: "true if line breaks should not be checked" },
+ passfail: { help: "true if the scan should stop on first error" },
+ plusplus: { help: "true if increment/decrement should not be allowed" },
+ redef: { help: "true if var redefinition should be allowed" },
+ undef: { help: "true if undefined variables are errors" },
+ widget: { help: "true if the Yahoo Widgets globals should be predefined" },
+ options: { hasarg: true, action: readconfigfile,
+ help: "Read additional arguments and options from a file" },
+ ignore: { hasarg: true,
+ action: function(a,r,o) { parserange(r, function(i) { JSLINT.errorlevels[i]='ignore';}); return true;},
+ help: "Specified messages are ignored" },
+ warn: { hasarg: true,
+ action: function(a,r,o) { parserange(r, function(i) { JSLINT.errorlevels[i]='warn';}); return true;},
+ help: "Specified messages are warnings" },
+ error: { hasarg: true,
+ action: function(a,r,o) { parserange(r, function(i) { JSLINT.errorlevels[i]='error';}); return true;},
+ help: "Specified messages are fatals" },
+ extern: { hasarg: true, def: {},
+ action: doextern,
+ help: "Add external names" },
+ help: { shortname: '?', action: function() { usage(options); }, help: "show usage text" },
+ '': { action: lintfile }
+ };
+ var oksofar = true;
+ var filesdone = 0;
+
+ var finalopts = processarguments(options, arguments[0]);
+
+ if (oksofar && finalopts) {
+ if (filesdone===0) {
+ usage(options, "You must give at least one filename");
+ quit(1);
}
- quit();
+ JSLINT.textreport(false);
}
+ quit();
})(arguments);
Added: kupu/trunk/kupu/jslint.opts
==============================================================================
--- (empty file)
+++ kupu/trunk/kupu/jslint.opts Mon Dec 18 16:37:15 2006
@@ -0,0 +1,16 @@
+--browser --nopassfail --redef
+--extern _,_IE_VERSION,_SARISSA_IS_IE,_SARISSA_IS_MOZ,ActiveXObject
+--extern addEventHandler,AnchorDrawer,AnchorTool,CleanupExpressionsTool
+--extern ColorchooserTool,ContextFixer,ContextMenu,ContextMenuElement
+--extern DefinitionListTool,DrawerTool,extern,getBaseTagClass,getFromSelector
+--extern IESelection,ImageLibraryDrawer,ImageTool,ImageToolBox,initKupu,kupu
+--extern KupuButton,kupuButtonDisable,kupuButtonEnable,KupuDocument,KupuEditor
+--extern KupuInspector,KupuRemoveElementButton,KupuSpellChecker,KupuStateButton
+--extern KupuUI,KupuZoomTool,LinkDrawer,LinkLibraryDrawer,LinkTool,LinkToolBox
+--extern ListTool,loadDictFromXML,MozillaSelection,newDocumentElement
+--extern newElement,Node,NodeIterator,NonXHTMLTagFilter,openPopup
+--extern parentWithStyleChecker,PlainLogger,PropertyTool,Range,Sarissa
+--extern saveOnPart,selectSelectItem,ShowPathTool,SourceEditTool,TableDrawer
+--extern TableTool,TableToolBox,timer_instance,UpdateStateCancelBubble
+--extern ViewSourceTool,XhtmlValidation,XMLSerializer,XPathResult,XSLTProcessor
+--ignore 501,510,531,535,544,546,554,557
Modified: kupu/trunk/kupu/lint.py
==============================================================================
--- kupu/trunk/kupu/lint.py (original)
+++ kupu/trunk/kupu/lint.py Mon Dec 18 16:37:15 2006
@@ -11,7 +11,7 @@
import os, sys, glob, time
import cPickle
-COMPILE_COMMAND = "java org.mozilla.javascript.tools.shell.Main %(lint)s %(file)s"
+COMPILE_COMMAND = "java org.mozilla.javascript.tools.shell.Main %(lint)s --options jslint.opts %(file)s"
def lint(name):
cmd = COMPILE_COMMAND % dict(lint=LINT, file=name)
Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js (original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern kupu */
KupuEditor.prototype._getBase = function(dom) {
var base = dom.getElementsByTagName('base');
if (base.length) {
Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js (original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js Mon Dec 18 16:37:15 2006
@@ -7,13 +7,7 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern KupuButton loadDictFromXML ListTool ImageTool SourceEditTool
- KupuSpellChecker LinkTool DrawerTool TableDrawer KupuDocument
- KupuStateButton KupuUI DefinitionListTool AnchorTool
- parentWithStyleChecker AnchorDrawer DummyLogger ColorchooserTool
- KupuEditor KupuZoomTool ImageLibraryDrawer addEventHandler KupuRemoveElementButton
- _SARISSA_IS_IE noContextMenu getFromSelector TableTool ShowPathTool
- */
+/*extern DummyLogger noContextMenu */
// $Id$
function initPloneKupu(editorId) {
Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupusaveonpart.js
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupusaveonpart.js (original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupusaveonpart.js Mon Dec 18 16:37:15 2006
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-/*extern kupu */
// $Id$
function saveOnPart(evt) {
Modified: kupu/trunk/kupu/plone/plonelibrarytool.py
==============================================================================
--- kupu/trunk/kupu/plone/plonelibrarytool.py (original)
+++ kupu/trunk/kupu/plone/plonelibrarytool.py Mon Dec 18 16:37:15 2006
@@ -325,7 +325,7 @@
if not v:
v = getver('Opera ')
if v:
- return False and v >= (9,0)
+ return v >= (9,0)
mozillaver = getver('Mozilla/')
if mozillaver > (5,0):
More information about the kupu-checkins
mailing list