Introduced warning and guide to run jsLint
diff --git a/JavascriptRefactoring.wiki b/JavascriptRefactoring.wiki index ed38914..948f297 100644 --- a/JavascriptRefactoring.wiki +++ b/JavascriptRefactoring.wiki
@@ -1,8 +1,75 @@ #summary Proposal about Javascript refactoring #labels Importance-Useful,Phase-Implementation,Contents-Draft +*Warning*: this is a proposal, and references to code not yet pushed in the main repository. Current scripts and tools can be found on the [http://bitbucket.org/dhans/statistic-module-for-melange/ statistics GSoC branch], the following are links to provisional refactored code in [http://bitbucket.org/dhans/statistic-module-for-melange/src/tip/app/soc/content/js/melange.js melange.js] and [http://bitbucket.org/dhans/statistic-module-for-melange/src/tip/app/soc/content/js/melange.graph.js melange.graph.js] + +=Introduction= With more Javascript code being written and deployed, global namespace pollution is going to be a risk. So, we have two options: handle Java-like packages and dependencies between modules with projects like [http://code.google.com/p/jingo/ Jingo] or keep Python to handle all this stuff, just giving it the potential to handle dependencies. +=Tools= +==jsLint== +To run jsLint and check melange.js and melange.graph.js files, you need java installed in your local computer, just run +{{{ + +./jsLint.sh + +}}} + +in {{{ scripts/ }}} directory. +The check is based to a slightly modified source of [http://www.jslint.com/rhino/index.html Jslint rhino version]. +Following the defaults: + +{{{ + +bitwise:false, +eqeqeq:true, +immed:true, +laxbreak:false, +newcap:false, +nomen:false, +onevar:false, +plusplus:false, +regexp:false, +browser:true, +undef:true, +white:true, +indent:2, +predef:['window','jQuery'] + +}}} + +In practice: + +* check for use of == and != (always use === and !==) +* check if immediate function calling are surrounded by parenthesis +* disallow uncorrect breaking of lines +* assumes a browser +* prevent undefined variables +* check whitespaces before an anonymous function calling +* check if there are 2 whitespaces per indentation +* ignores {{{ window }} and {{{ jQuery }}} being global variables +* do not tolerate use of {{{ eval }}} statement +* do not tolerate unfiltered {{{ for...in }}} statements + +If you want to check your code copying and pasting in the [http://www.jslint.com/ online version of jsLint] (you will receive more useful infos as output), set the following [http://www.jslint.com/#options jsLint options]: + +* Strict white space +* Assume a browser +* Disallow undefined variables +* Disallow {{{ == }}} and {{{ != }}} +* Require parens around immediate invocation +* Strict white space indentation: set it to *2* + +==jsUnit== + +==jsCoverage== + +==JSDocToolkit== + +==Shrinksafe== + + +=Guidelines= In any way, we need: 1. To separate Javascript code in *modules*, and use Javascript language features to _namespace correctly_ those modules.