[kupu-dev] Kupu 1.4 beta 3

Duncan Booth duncan.booth at suttoncourtenay.org.uk
Fri Dec 22 21:01:44 CET 2006


"Alexander Limi" <limi at plone.org> wrote:

> On Fri, 22 Dec 2006 07:04:18 -0800, Duncan Booth  
><duncan.booth at suttoncourtenay.org.uk> wrote:
>>   - The javascript files used by Plone (and some of the other ones)
>>     now run through jslint without warnings. This means they can be
>>     compressed by programs which remove line endings in an unsafe
>>     manner.
> Yay! Thanks, Duncan! This will make Kupu more lightweight for our
> users in  Plone 3.0. :)
> 

BTW, anyone else developing javascript for Plone please feel free to use
the jslint.js file to clean up javascript: I'll try to write up some
documentation at some point, but in short: you want to install rhino
from http://www.mozilla.org/rhino/, then you can run it as follows: 

java org.mozilla.javascript.tools.shell.Main jslint.js [options] [file]

The options are (* means default):

--browser, --nobrowser*
        true if the standard browser globals should be predefined
--cap, --nocap*
        true if upper case HTML should be allowed
--debug, --nodebug*
        true if debugger statements should be allowed
--eqeqeq, --noeqeqeq*
        true if === should be required
--error #
        Specified messages are fatals
--evil, --noevil*
        true if eval should be allowed
--extern #
        Add external names
--help
        show usage text
--ignore #
        Specified messages are ignored
--jscript, --nojscript*
        true if jscript deviations should be allowed
--laxLineEnd, --nolaxLineEnd*
        true if line breaks should not be checked
--options #
        Read additional arguments and options from a file
--passfail, --nopassfail*
        true if the scan should stop on first error
--plusplus, --noplusplus*
        true if increment/decrement should not be allowed
--redef, --noredef*
        true if var redefinition should be allowed
--undef, --noundef*
        true if undefined variables are errors
--warn #
        Specified messages are warnings
--widget, --nowidget*
        true if the Yahoo Widgets globals should be predefined


I run it with the options --config jslint.opts where jslint.opts
contains: 

--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

It doesn't yet handle multiple files properly: It will scan more than one file 
at a time, but it resets everything between files and I need to get it to 
remember the globals. Once it does that I should be able to get rid of almost all the
--extern options above. The errors I ignored are the ones I don't like such as
complaining about superfluous semicolons (I might clean them up sometime, but
not today), and complaining about multiple variable definitions: I like to
use the 'var' keyword a lot, in fact I added an extra warning not in the original
code to warn if you try to use a for loop variable without the var keyword.

Errors may also be ignored using comments such as /*ignore 558 */. Start without 
ignoring any errors and add ignores or fix the problems as you prefer. Some errors
aren't ignorable as jslint won't recover up when it sees them.

The differences in this jslint.js from Douglas Crockford's original are:

command line options
ability to ignore some warnings
warnings about unused local variables and undefined globals: the original 
gives these warnings on the web based version only, not the command line 
version.



More information about the kupu-dev mailing list