[javascriptlint-commit] SF.net SVN: javascriptlint:[349] trunk
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2014-02-10 15:09:25
|
Revision: 349 http://sourceforge.net/p/javascriptlint/code/349 Author: matthiasmiller Date: 2014-02-10 15:09:21 +0000 (Mon, 10 Feb 2014) Log Message: ----------- Fix warning position for trailing commas. Modified Paths: -------------- trunk/javascriptlint/warnings.py trunk/tests/warnings/spidermonkey/trailing_comma.js trunk/tests/warnings/trailing_comma_in_array.js Modified: trunk/javascriptlint/warnings.py =================================================================== --- trunk/javascriptlint/warnings.py 2014-01-08 22:59:01 UTC (rev 348) +++ trunk/javascriptlint/warnings.py 2014-02-10 15:09:21 UTC (rev 349) @@ -547,12 +547,17 @@ @lookfor(tok.RC) def trailing_comma(node): if node.end_comma: - raise LintWarning(node) + # Warn on the last value in the dictionary. + last_item = node.kids[-1] + assert last_item.kind == tok.COLON + key, value = last_item.kids + raise LintWarning(value) @lookfor(tok.RB) def trailing_comma_in_array(node): if node.end_comma: - raise LintWarning(node) + # Warn on the last value in the array. + raise LintWarning(node.kids[-1]) @lookfor(tok.STRING) def useless_quotes(node): Modified: trunk/tests/warnings/spidermonkey/trailing_comma.js =================================================================== --- trunk/tests/warnings/spidermonkey/trailing_comma.js 2014-01-08 22:59:01 UTC (rev 348) +++ trunk/tests/warnings/spidermonkey/trailing_comma.js 2014-02-10 15:09:21 UTC (rev 349) @@ -1,5 +1,8 @@ /*jsl:option explicit*/ function trailing_comma() { /* illegal - trailing comma */ - return { name: 'value', }; /*warning:trailing_comma*/ + return { + name: + 'value', /*warning:trailing_comma*/ + }; } Modified: trunk/tests/warnings/trailing_comma_in_array.js =================================================================== --- trunk/tests/warnings/trailing_comma_in_array.js 2014-01-08 22:59:01 UTC (rev 348) +++ trunk/tests/warnings/trailing_comma_in_array.js 2014-02-10 15:09:21 UTC (rev 349) @@ -5,4 +5,12 @@ a = [1,,2]; a = [1,]; /*warning:trailing_comma_in_array*/ a = [1,,]; /*warning:trailing_comma_in_array*/ + a = [ + , /*warning:trailing_comma_in_array*/ + ]; + a = [ + 1, + 2, + 3, /*warning:trailing_comma_in_array*/ + ]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |