mathiasrw / closure-linter

Automatically exported from code.google.com/p/closure-linter
Apache License 2.0
0 stars 0 forks source link

fixjsstyle incorrectly adding semicolon to specific function args... #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following code will be broken after fixjsstyle:

alert(callback || function() {});

Gets 'fixed' to:

alert(callback || function() {};);

Original issue reported on code.google.com by guido.tapia@gmail.com on 3 Oct 2012 at 6:00

GoogleCodeExporter commented 9 years ago
The resulting change to the code is correct per the style guide that gjslint 
and fixjsstyle enforce. You are assigning one of two possible values based on 
the condition evaluation, the linter sees that and asserts that an expression 
should end with a semicolon per the ECMAScript rules for ASI.

While fixjsstyle 'breaks' the code, is this a case of a broken implementation? 
I don't think so, look at it like this: If you are truly trying to stringify a 
function then why not use a function expression?

var someMethod = function() {
  return 'in someMethod';
};

alert(callback || someMethod);

http://ecma-international.org/ecma-262/5.1/#sec-7.9

Original comment by harpe...@gmail.com on 24 Feb 2013 at 5:00

GoogleCodeExporter commented 9 years ago
Issue 57 has been merged into this issue.

Original comment by rum...@google.com on 15 Jan 2015 at 8:56