[javascriptlint-commit] SF.net SVN: javascriptlint:[221] trunk
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2008-08-26 15:11:01
|
Revision: 221 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=221&view=rev Author: matthiasmiller Date: 2008-08-26 15:10:59 +0000 (Tue, 26 Aug 2008) Log Message: ----------- want_assign_or_call: first cut at implementation Modified Paths: -------------- trunk/pyjsl/warnings.py trunk/tests/warnings/multiple_plus_minus.js Added Paths: ----------- trunk/tests/warnings/want_assign_or_call.js Modified: trunk/pyjsl/warnings.py =================================================================== --- trunk/pyjsl/warnings.py 2008-08-26 13:54:31 UTC (rev 220) +++ trunk/pyjsl/warnings.py 2008-08-26 15:10:59 UTC (rev 221) @@ -68,7 +68,8 @@ 'partial_option_explicit': 'the "option explicit" control comment, if used, must be in the first script tag', 'dup_option_explicit': 'duplicate "option explicit" control comment', 'invalid_fallthru': 'unexpected "fallthru" control comment', - 'invalid_pass': 'unexpected "pass" control comment' + 'invalid_pass': 'unexpected "pass" control comment', + 'want_assign_or_call': 'expected an assignment or function call' } _visitors = [] @@ -426,6 +427,25 @@ if util.isidentifier(node.atom): raise LintWarning, node +@lookfor(tok.SEMI) +def want_assign_or_call(node): + child, = node.kids + # Ignore empty statements. + if not child: + return + # NOTE: Don't handle comma-separated statements. + if child.kind in (tok.ASSIGN, tok.INC, tok.DEC, tok.DELETE, tok.COMMA): + return + # Ignore function calls. + if child.kind == tok.LP and child.opcode == op.CALL: + return + # Allow new function() { } as statements. + if child.kind == tok.NEW: + grandchild, = child.kids + if grandchild.kind == tok.FUNCTION: + return + raise LintWarning, child + @lookfor() def mismatch_ctrl_comments(node): pass Modified: trunk/tests/warnings/multiple_plus_minus.js =================================================================== --- trunk/tests/warnings/multiple_plus_minus.js 2008-08-26 13:54:31 UTC (rev 220) +++ trunk/tests/warnings/multiple_plus_minus.js 2008-08-26 15:10:59 UTC (rev 221) @@ -1,4 +1,5 @@ /*jsl:option explicit*/ +/*conf:-want_assign_or_call*/ function multiple_plus_minus() { var i, j; i = 0; Added: trunk/tests/warnings/want_assign_or_call.js =================================================================== --- trunk/tests/warnings/want_assign_or_call.js (rev 0) +++ trunk/tests/warnings/want_assign_or_call.js 2008-08-26 15:10:59 UTC (rev 221) @@ -0,0 +1,25 @@ +function want_assign_or_call() { + var a; + a; /*warning:want_assign_or_call*/ + a++; + a--; + a /= 2; + a %= 4; + a >>= 3; + a << 2; /*warning:want_assign_or_call*/ + + new function() { + }; + + function test() { + } + + function() { /*warning:want_assign_or_call*/ + return 42; + } + + delete a; + + a.b(); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |